@payrails/web-sdk 5.8.4 → 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.d.ts +6 -1
- package/payrails.js +4 -4
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
!function(){"use strict";function e(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 t(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 i(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}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s={};!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}(s);var r={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,o=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 n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&r(e,n,t[n]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});class l{log(e,t){console.log(JSON.stringify({level:e,mssg:t.mssg,error:t.error,withMetada:t.withMetada,extra:t.extra}))}}var d=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(d||{}),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E,_={},h={};var I,p={};var f,v={};var m={};Object.defineProperty(m,"__esModule",{value:!0}),m.subscribers=m.childWindows=m.prefix=void 0,m.prefix="/*framebus*/",m.childWindows=[],m.subscribers={};var N,T={};var 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 A,L={};var R,g={};var S={};Object.defineProperty(S,"__esModule",{value:!0}),S.sendMessage=void 0,S.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var C,D={},P={};function b(){if(C)return P;C=1,Object.defineProperty(P,"__esModule",{value:!0}),P.Framebus=void 0;var e=B(),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 P.Framebus=i,P}var M,w=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)}))};var U,k={};var x={};Object.defineProperty(x,"__esModule",{value:!0});var Y,F,V={};function B(){return F||(F=1,e=_,t=c&&c.__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=c&&c.__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(E)return h;E=1,Object.defineProperty(h,"__esModule",{value:!0}),h.detach=h.attach=void 0;var e=B(),t=!1;return h.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},h.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},h}(),e),i(function(){if(I)return p;I=1,Object.defineProperty(p,"__esModule",{value:!0}),p.broadcastToChildWindows=void 0;var e=B();return p.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})}},p}(),e),i(function(){if(f)return v;f=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=B();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(m,e),i(function(){if(N)return T;N=1,Object.defineProperty(T,"__esModule",{value:!0}),T.dispatch=void 0;var e=B();return T.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)}},T}(),e),i(y,e),i(O,e),i(function(){if(A)return L;A=1,Object.defineProperty(L,"__esModule",{value:!0}),L.onMessage=void 0;var e=B();return L.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)}}},L}(),e),i(function(){if(R)return g;R=1,Object.defineProperty(g,"__esModule",{value:!0}),g.packagePayload=void 0;var e=B();return g.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},g}(),e),i(S,e),i(function(){if(M)return D;M=1;var e=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.subscribeReplier=void 0;var t=b(),i=e(w);return D.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},D}(),e),i(function(){if(U)return k;U=1,Object.defineProperty(k,"__esModule",{value:!0}),k.subscriptionArgsInvalid=void 0;var e=B();return k.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},k}(),e),i(x,e),i(function(){if(Y)return V;Y=1,Object.defineProperty(V,"__esModule",{value:!0}),V.unpackPayload=void 0;var e=B();return V.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},V}(),e)),_;var e,t,i}var G=B(),j=b();(0,G.attach)();const X=u(j.Framebus);class H{constructor(e){this.origin=null,this.listeners=[],this.bus=new X(e)}static getInstance(){return H.instance||(H.instance=new H),H.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 W{constructor(){this.bus=H.getInstance()}log(e,t){this.bus.emit(d.ERROR,{level:e,event:t})}}var z=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===K}(e)}(e)};var K="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function $(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ee((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function q(e,t,i){return e.concat(t).map((function(e){return $(e,i)}))}function J(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 Z(e,t){try{return t in e}catch(e){return!1}}function Q(e,t,i){var n={};return i.isMergeableObject(e)&&J(e).forEach((function(t){n[t]=$(e[t],i)})),J(t).forEach((function(o){(function(e,t){return Z(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(Z(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return ee;var i=t.customMerge(e);return"function"==typeof i?i:ee}(o,i)(e[o],t[o],i):n[o]=$(t[o],i))})),n}function ee(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||q,i.isMergeableObject=i.isMergeableObject||z,i.cloneUnlessOtherwiseSpecified=$;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):Q(e,t,i):$(t,i)}ee.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return ee(e,i,t)}),{})};const te=u(ee);class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),oe=()=>window&&window.navigator,se=()=>window&&window.screen,re=()=>({resolution:`${se().width}x${se().height}`,user_agent:oe().userAgent,language:oe().language});class ae{constructor(e){this.adapter=[new W],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new l)}static init(e){ae.instance=new ae(e)}static getLogger(){return ae.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){this.enabled&&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:re(),payrails:ne.getState("payrails"),sdk:ne.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=ae,e.getDeviceInfo=re}(r);for(var a,l=[],d=0;d<256;++d)l.push((d+256).toString(16).slice(1));var c=new Uint8Array(16);function u(){if(!a&&!(a="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 a(c)}var E={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _(e,t,i){if(E.randomUUID&&!t&&!e)return E.randomUUID();var n=(e=e||{}).random||(e.rng||u)();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(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}(n)}var h;!function(e){e.GET="GET",e.POST="POST"}(h||(h={}));const I=({url:t,method:i=h.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},T()),N(n)),y())};i===h.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new p(t,i);if(429===s.status)throw new v(t,i);if(!s.ok)throw new f(t,i);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class p extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class f extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class v extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class m extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const N=e=>({authorization:`Bearer ${e}`}),T=()=>({"x-idempotency-key":_()}),y=()=>{const e={version:"5.8.4",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},O=(t,i)=>e(void 0,void 0,void 0,(function*(){var e,n;if(null==t?void 0:t.onPaymentButtonClicked)try{const n=yield t.onPaymentButtonClicked(i);if(!n){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return r.PayrailsLogger.error(i.message,{error:i}),null===(e=null==t?void 0:t.onAuthorizeFailed)||void 0===e||e.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),n}}catch(e){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:e});return r.PayrailsLogger.error(i.message,{error:i}),null===(n=t.onAuthorizeFailed)||void 0===n||n.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),!1}return!0})),A={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class L{constructor(e,t,i=A,n=680,o=60,s=2e3,r=5){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}pay(t){return e(this,void 0,void 0,(function*(){try{const e=(yield this.authorize(t)).res.links.execution;return yield this.pollForAuthorizationResult(e)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(t,i={}){return e(this,void 0,void 0,(function*(){try{const e=yield I({url:t,method:h.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(e.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(e.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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(t,i,n=0){return e(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new m(t,h.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const e=yield I({url:t,token:this.sdkConfig.token});if(i){if(!e.res.status.find((({time:e})=>new Date(e)>new Date(i))))return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+1)}return e}catch(e){if(e instanceof f)return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(e instanceof v)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(t,i,n+1);throw e}}))}createApplePaySession(t){return e(this,void 0,void 0,(function*(){return I({url:t.requestUrl,method:h.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientContext:{host:t.clientDomain||window.location.host}}}})}))}authorize(t){return e(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const{success:e,error:i,cancel:n}=this.returnLinks;return I({url:this.execution.authorizeLink,method:h.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:n,error:i}}})}))}wait(t){return e(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}pollForAuthorizationResult(t,i=0){return e(this,void 0,void 0,(function*(){const e=(yield this.getExecution(t)).res,n=e.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],a=n.find((({code:e})=>"authorizeRequested"===e));if(!a&&i<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(t,i+1);if(!a){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(a.time))),d=l?l.time:a.time;let c=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d)));if(!c){const{res:e}=yield this.getExecution(t,d);return c=e.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:e}}return{finalState:c,response:e}}))}}class R{constructor(e,t,i,n,o=g.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===g.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 t=i=>e(this,void 0,void 0,(function*(){var e,n,o,a;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",t);if((yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(a=null===(o=this.options.events)||void 0===o?void 0:o.onAuthorizeSuccess)||void 0===a||a.call(o);else{const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);r.PayrailsLogger.error(t.message,{error:t}),null===(n=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===n||n.call(e,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",t)}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 g,S,C,D,P,b;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(g||(g={}));class M{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"];if(o){new R(o,this.execution,this.paymentExecutor,this.options).mount()}}}exports.PAYMENT_METHOD_CODES=void 0,(S=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",S.GOOGLE_PAY="googlePay",S.PAYPAL="payPal",S.APPLE_PAY="applePay",S.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(C||(C={}));class w{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(exports.PAYMENT_METHOD_CODES.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var e;return(null===(e=this.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var e;return null===(e=this.lookup)||void 0===e?void 0:e.body.links.authorize.href}get createSessionLink(){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"}(D||(D={})),exports.INTEGRATION_TYPE=void 0,(P=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",P.HPP="hpp";class U{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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new s.PayrailsError(s.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 s.PayrailsError(s.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 k extends U{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 L(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 t,i,n,o,a,l,d,c;return e(this,void 0,void 0,(function*(){this.setDisabled(!0),this.triggerLoading(!0);if(!(yield O(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(t=this.selectedInstrument)||void 0===t?void 0:t.id)e[0].paymentInstrumentId=null===(i=this.selectedInstrument)||void 0===i?void 0:i.id,e[0].paymentMethodCode=null===(n=this.selectedInstrument)||void 0===n?void 0:n.paymentMethod;else{if(!this.cardForm){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}e=this.sdkConfig.usePayrailsFrames?yield this.constructEncryptedPayment(e):yield this.constructTokenizedPayment(e)}const o=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(o)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof p||[401,403].includes(null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.code)?(null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===l||l.call(a),t.message="API token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),t.message="Vault token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t})):t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}}))}constructTokenizedPayment(t){return e(this,void 0,void 0,(function*(){const{storeInstrument:e,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return t[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}},t[0].storeInstrument=e,t[0].enrollInstrumentToNetworkOffers=i,t}))}constructEncryptedPayment(t){return e(this,void 0,void 0,(function*(){const{cardData:e,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData=Object.assign({},e),t[0].storeInstrument=i,t[0].enrollInstrumentToNetworkOffers=n,t}))}handleAuthorizationResult(e){var t,i,n;let o;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":if("3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)){new M({events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})},this.execution,this.paymentExecutor).handle3ds(e)}break;default:o=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),r.PayrailsLogger.error(o.message,{error:o,extra:{result:e}}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:o.message})}}}exports.AuthorizationFailureReasons=void 0,(b=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",b.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",b.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",b.UNKNOWN_ERROR="UNKNOWN_ERROR";var x={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o,s={},r={};var a,l={};var d,c={};var u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={};var 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,f={};var v,m={};var 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,y={},O={};function A(){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 L,R=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)}))};var g,S={};var C={};Object.defineProperty(C,"__esModule",{value:!0});var D,P,b={};function M(){return P||(P=1,e=s,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]}),n=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}),n(function(){if(o)return r;o=1,Object.defineProperty(r,"__esModule",{value:!0}),r.detach=r.attach=void 0;var e=M(),t=!1;return r.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},r.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},r}(),e),n(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcastToChildWindows=void 0;var e=M();return l.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})}},l}(),e),n(function(){if(d)return c;d=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),n(u,e),n(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),n(h,e),n(I,e),n(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),n(function(){if(v)return m;v=1,Object.defineProperty(m,"__esModule",{value:!0}),m.packagePayload=void 0;var e=M();return m.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},m}(),e),n(N,e),n(function(){if(L)return y;L=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(y,"__esModule",{value:!0}),y.subscribeReplier=void 0;var i=A(),n=e(R);return y.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},y}(),e),n(function(){if(g)return S;g=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),n(C,e),n(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)),s;var e,i,n}var w=M(),U=A();(0,w.attach)();const k=i(U.Framebus);class x{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return x.instance||(x.instance=new x),x.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=x,e.getEventBus=()=>x.getInstance()}(x);const Y={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."},F={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."},V={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."},B="collect_controller",G="element",j={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},X="FRAME_READY",H="TOKENIZATION_REQUEST",W="INPUT_EVENT",z="DESTROY FRAME",K="SET_VALUE",$="GET_BEARER_TOKEN",q="COLLECT_ELEMENT_SET_ERROR",J="COMPOSABLE_UPDATE_OPTIONS",Z="COMPOSABLE_CONTAINER_MOUNTED",Q="COLLECT_CONTAINER_MOUNTED";var ee,te;!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"}(ee||(ee={})),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"}(te||(te={}));const ie={[te.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[te.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[te.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[te.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[te.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[te.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},ne={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},[ee.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ee.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:ie[te.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ee.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ee.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ee.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ee.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ee.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ee.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},oe="XXXX-XXXX-XXXX-XXXX",se={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},re={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},ae={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},le={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};le.BASE,le.REQUIRED_ASTERISK;const de={[te.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[te.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[te.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[te.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[te.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[te.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[te.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[te.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[te.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]}};te.DEFAULT,te.AMEX,te.DINERS_CLUB,te.DISCOVER,te.HIPERCARD,te.JCB,te.MAESTRO,te.MASTERCARD,te.UNIONPAY,te.VISA;const ce="MM/YY",ue=[ce,"YYYY/MM","YY/MM","MM/YYYY"],Ee=["YY","YYYY"];var _e;!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"}(_e||(_e={})),ee.CARD_NUMBER,ee.EXPIRATION_DATE,ee.EXPIRATION_MONTH,ee.EXPIRATION_YEAR,ee.CVV,ee.EXPIRATION_DATE,ee.CARD_NUMBER,ee.CARDHOLDER_NAME,ee.INPUT_FIELD,F.INVALID_COLLECT_VALUE,ee.PIN,ee.EXPIRATION_MONTH,ee.EXPIRATION_YEAR,ee.CVV,ee.EXPIRATION_DATE,ee.CARD_NUMBER,ee.CARDHOLDER_NAME,ee.INPUT_FIELD,F.DEFAULT_REQUIRED_COLLECT_VALUE,ee.PIN,ee.EXPIRATION_MONTH,ee.EXPIRATION_YEAR;const he=[ee.CARDHOLDER_NAME,ee.EXPIRATION_MONTH,ee.PIN,ee.CVV],Ie={X:"[0-9]"};class pe{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(pe.prototype,{constructor:e})}}
|
|
1
|
+
!function(){"use strict";function e(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 t(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 i(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}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s={};!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}(s);var r={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,o=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 n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&r(e,n,t[n]);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!==n?n:"undefined"!=typeof self?self:{};function E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _,h={},I={};var p,f={};var m,v={};var 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={};var 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={};var g,S={};var 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=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)}))};var k,x={};var Y={};Object.defineProperty(Y,"__esModule",{value:!0});var F,V,B={};function G(){return V||(V=1,e=h,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 I;_=1,Object.defineProperty(I,"__esModule",{value:!0}),I.detach=I.attach=void 0;var e=G(),t=!1;return I.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},I.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},I}(),e),i(function(){if(p)return f;p=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(m)return v;m=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 L;R=1,Object.defineProperty(L,"__esModule",{value:!0}),L.onMessage=void 0;var e=G();return L.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)}}},L}(),e),i(function(){if(g)return S;g=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(U);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(k)return x;k=1,Object.defineProperty(x,"__esModule",{value:!0}),x.subscriptionArgsInvalid=void 0;var e=G();return x.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},x}(),e),i(Y,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)),h;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)};var $="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}(r);for(var a,l=[],d=0;d<256;++d)l.push((d+256).toString(16).slice(1));var c=new Uint8Array(16);function u(){if(!a&&!(a="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 a(c)}var E={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _(e,t,i){if(E.randomUUID&&!t&&!e)return E.randomUUID();var n=(e=e||{}).random||(e.rng||u)();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(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}(n)}var h;!function(e){e.GET="GET",e.POST="POST"}(h||(h={}));const I=({url:t,method:i=h.GET,token:n,body:o})=>e(void 0,void 0,void 0,(function*(){const e={method:i,headers:Object.assign(Object.assign(Object.assign({},T()),N(n)),A())};i===h.POST&&(e.body=JSON.stringify(o||{}));const s=yield fetch(t,e),r=yield s.json();if([401,403].includes(s.status))throw new p(t,i);if(429===s.status)throw new m(t,i);if(!s.ok)throw new f(t,i);return{ok:s.ok,req:Object.assign({url:t},e),res:r}}));class p extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class f extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class m extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class v extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const N=e=>({authorization:`Bearer ${e}`}),T=()=>({"x-idempotency-key":_()}),A=()=>{const e={version:"5.10.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},O=(t,i)=>e(void 0,void 0,void 0,(function*(){var e,n;if(null==t?void 0:t.onPaymentButtonClicked)try{const n=yield t.onPaymentButtonClicked(i);if(!n){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return r.PayrailsLogger.error(i.message,{error:i}),null===(e=null==t?void 0:t.onAuthorizeFailed)||void 0===e||e.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),n}}catch(e){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:e});return r.PayrailsLogger.error(i.message,{error:i}),null===(n=t.onAuthorizeFailed)||void 0===n||n.call(t,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),!1}return!0})),y={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class R{static getInstance(){return this.instance||(this.instance=new R),this.instance}constructor(e=""){this.lastActionRequestTime=e,R.instance=this}}class L{constructor(e,t,i=y,n=680,o=60,s=2e3,r=5,a=R.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(t){return e(this,void 0,void 0,(function*(){try{const e=(yield this.authorize(t)).res.links.execution;return yield this.pollForAuthorizationResult(e)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(t,i={}){return e(this,void 0,void 0,(function*(){try{const e=yield I({url:t,method:h.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(e.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(e.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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(t,i,n=0){return e(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new v(t,h.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const e=yield I({url:t,token:this.sdkConfig.token});if(i){if(!e.res.status.find((({time:e})=>new Date(e)>new Date(i))))return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+1)}return e}catch(e){if(e instanceof f)return yield this.wait(this.POLL_INTERVAL),this.getExecution(t,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(e instanceof m)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(t,i,n+1);throw e}}))}createApplePaySession(t){return e(this,void 0,void 0,(function*(){return I({url:t.requestUrl,method:h.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientContext:{host:t.clientDomain||window.location.host}}}})}))}authorize(t){return e(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const{success:e,error:i,cancel:n}=this.returnLinks;return I({url:this.execution.authorizeLink,method:h.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:n,error:i}}})}))}wait(t){return e(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}pollForAuthorizationResult(t,i=0){return e(this,void 0,void 0,(function*(){const e=(yield this.getExecution(t)).res,n=e.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],a=n.find((({code:e})=>"authorizeRequested"===e));if(!a&&i<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(t,i+1);if(!a){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(a.time))),d=l?l.time:a.time;if(d===this.paymentStatus.lastActionRequestTime)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(t,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:e}=yield this.getExecution(t,d);return c=e.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:e}}return{finalState:c,response:e}}))}}class g{constructor(e,t,i,n,o=S.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===S.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 t=i=>e(this,void 0,void 0,(function*(){var e,n,o,a;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",t);if((yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(a=null===(o=this.options.events)||void 0===o?void 0:o.onAuthorizeSuccess)||void 0===a||a.call(o);else{const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);r.PayrailsLogger.error(t.message,{error:t}),null===(n=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===n||n.call(e,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",t)}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 S,C,D,P,b,M;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(S||(S={}));class w{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"];if(o)if(this.options.redirectFor3DS)window.location.assign(o);else{new g(o,this.execution,this.paymentExecutor,this.options).mount()}}}exports.PAYMENT_METHOD_CODES=void 0,(C=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",C.GOOGLE_PAY="googlePay",C.PAYPAL="payPal",C.APPLE_PAY="applePay",C.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(D||(D={}));class U{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(exports.PAYMENT_METHOD_CODES.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY));if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return e.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var e;return(null===(e=this.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var e;return null===(e=this.lookup)||void 0===e?void 0:e.body.links.authorize.href}get createSessionLink(){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"}(P||(P={})),exports.INTEGRATION_TYPE=void 0,(b=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",b.HPP="hpp";class k{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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new s.PayrailsError(s.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 s.PayrailsError(s.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 k{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 L(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 t,i,n,o,a,l,d,c;return e(this,void 0,void 0,(function*(){this.setDisabled(!0),this.triggerLoading(!0);if(!(yield O(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(t=this.selectedInstrument)||void 0===t?void 0:t.id)e[0].paymentInstrumentId=null===(i=this.selectedInstrument)||void 0===i?void 0:i.id,e[0].paymentMethodCode=null===(n=this.selectedInstrument)||void 0===n?void 0:n.paymentMethod;else{if(!this.cardForm){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}e=this.sdkConfig.usePayrailsFrames?yield this.constructEncryptedPayment(e):yield this.constructTokenizedPayment(e)}const o=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(o)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof p||[401,403].includes(null===(o=null==e?void 0:e.error)||void 0===o?void 0:o.code)?(null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===l||l.call(a),t.message="API token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),t.message="Vault token is not valid or expired.",r.PayrailsLogger.error(t.message,{error:t})):t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}}))}constructTokenizedPayment(t){return e(this,void 0,void 0,(function*(){const{storeInstrument:e,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return t[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}},t[0].storeInstrument=e,t[0].enrollInstrumentToNetworkOffers=i,t}))}constructEncryptedPayment(t){return e(this,void 0,void 0,(function*(){const{cardData:e,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return t[0].paymentInstrumentData=Object.assign({},e),t[0].storeInstrument=i,t[0].enrollInstrumentToNetworkOffers=n,t}))}handleAuthorizationResult(e){var t,i,n;let o;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":if("3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)){new w(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.execution,this.paymentExecutor).handle3ds(e)}break;default:o=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),r.PayrailsLogger.error(o.message,{error:o,extra:{result:e}}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:o.message})}}}exports.AuthorizationFailureReasons=void 0,(M=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",M.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",M.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",M.UNKNOWN_ERROR="UNKNOWN_ERROR";var Y={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o,s={},r={};var a,l={};var d,c={};var u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={};var 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,f={};var m,v={};var 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=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)}))};var g,S={};var C={};Object.defineProperty(C,"__esModule",{value:!0});var D,P,b={};function M(){return P||(P=1,e=s,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]}),n=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}),n(function(){if(o)return r;o=1,Object.defineProperty(r,"__esModule",{value:!0}),r.detach=r.attach=void 0;var e=M(),t=!1;return r.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},r.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},r}(),e),n(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcastToChildWindows=void 0;var e=M();return l.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})}},l}(),e),n(function(){if(d)return c;d=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),n(u,e),n(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),n(h,e),n(I,e),n(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),n(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),n(N,e),n(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(L);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),n(function(){if(g)return S;g=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),n(C,e),n(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)),s;var e,i,n}var w=M(),U=y();(0,w.attach)();const k=i(U.Framebus);class x{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return x.instance||(x.instance=new x),x.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=x,e.getEventBus=()=>x.getInstance()}(Y);const F={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."},V={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."},B={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."},G="collect_controller",j="element",X={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},H="FRAME_READY",W="TOKENIZATION_REQUEST",z="INPUT_EVENT",K="DESTROY FRAME",$="SET_VALUE",q="GET_BEARER_TOKEN",J="COLLECT_ELEMENT_SET_ERROR",Z="COMPOSABLE_UPDATE_OPTIONS",Q="COMPOSABLE_CONTAINER_MOUNTED",ee="COLLECT_CONTAINER_MOUNTED";var te,ie;!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"}(te||(te={})),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"}(ie||(ie={}));const ne={[ie.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[ie.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ie.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ie.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ie.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[ie.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ie.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ie.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ie.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ie.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ie.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},oe={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},[te.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[te.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:ne[ie.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[te.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[te.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[te.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[te.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[te.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[te.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},se="XXXX-XXXX-XXXX-XXXX",re={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},ae={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},le={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},de={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};de.BASE,de.REQUIRED_ASTERISK;const ce={[ie.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[ie.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[ie.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[ie.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[ie.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[ie.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ie.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[ie.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ie.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]}};ie.DEFAULT,ie.AMEX,ie.DINERS_CLUB,ie.DISCOVER,ie.HIPERCARD,ie.JCB,ie.MAESTRO,ie.MASTERCARD,ie.UNIONPAY,ie.VISA;const ue="MM/YY",Ee=[ue,"YYYY/MM","YY/MM","MM/YYYY"],_e=["YY","YYYY"];var he;!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"}(he||(he={})),te.CARD_NUMBER,te.EXPIRATION_DATE,te.EXPIRATION_MONTH,te.EXPIRATION_YEAR,te.CVV,te.EXPIRATION_DATE,te.CARD_NUMBER,te.CARDHOLDER_NAME,te.INPUT_FIELD,V.INVALID_COLLECT_VALUE,te.PIN,te.EXPIRATION_MONTH,te.EXPIRATION_YEAR,te.CVV,te.EXPIRATION_DATE,te.CARD_NUMBER,te.CARDHOLDER_NAME,te.INPUT_FIELD,V.DEFAULT_REQUIRED_COLLECT_VALUE,te.PIN,te.EXPIRATION_MONTH,te.EXPIRATION_YEAR;const Ie=[te.CARDHOLDER_NAME,te.EXPIRATION_MONTH,te.PIN,te.CVV],pe={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 fe={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ve="https://assets.payrails.io/fad57d9/card/index.html",me="https://assets.payrails.io",Ne={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Te=(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({},Ne),e);return Object.assign(t.style,se),Te(t,i),t.getAttribute("id")||(t.id=t.name),t};const Oe=()=>fe.IFRAME_SECURE_SITE,Ae=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Le(e){return JSON.parse(JSON.stringify(e))}var Re,ge,Se,Ce,De,Pe,be;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Re||(Re={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(ge||(ge={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Se||(Se={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Ce||(Ce={})),function(e){e.DEV="DEV",e.PROD="PROD"}(De||(De={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(Pe||(Pe={})),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"}(be||(be={}));const Me={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}},we={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Ue="[Skyflow]",ke=(e,t,i)=>{if(i&&Me[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Me[i];t===Pe.LOG&&n?console.log(`${Ce.DEBUG}: ${Ue} ${e}`):t===Pe.LOG&&o?console.log(`${Ce.INFO}: ${Ue} ${e}`):t===Pe.WARN&&s?console.warn(`${Ce.WARN}: ${Ue} ${e}`):t===Pe.ERROR&&r&&console.error(`${Ce.ERROR}: ${Ue} ${e}`)}},xe=(...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]})):""},Ye=(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 Fe extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?xe(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Ve={INVALID_FIELD:{code:400,description:F.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:F.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:F.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:F.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:F.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:F.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:F.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:F.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:F.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:F.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:F.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:F.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:F.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:F.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:F.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:F.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:F.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:F.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:F.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:F.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:F.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:F.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:F.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:F.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:F.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:F.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:F.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:F.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:F.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:F.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:F.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:F.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:F.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:F.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:F.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:F.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:F.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:F.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:F.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:F.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:F.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:F.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:F.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:F.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:F.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:F.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:F.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:F.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:F.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:F.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:F.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:F.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:F.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:F.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:F.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:F.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:F.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:F.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:F.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:F.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:F.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:F.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:F.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:F.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:F.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:F.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:F.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:F.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:F.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:F.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:F.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:F.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:F.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:F.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:F.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:F.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:F.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:F.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:F.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:F.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:F.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:F.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:F.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:F.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:F.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:F.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:F.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:F.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:F.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:F.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:F.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:F.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:F.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:F.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:F.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:F.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:F.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:F.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:F.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:F.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:F.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:F.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:F.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:F.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:F.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:F.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:F.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:F.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:F.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:F.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:F.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:F.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:F.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:F.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:F.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:F.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:F.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:F.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:F.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:F.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:F.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:F.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:F.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:F.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:F.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:F.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:F.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:F.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:F.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:F.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:F.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:F.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:F.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:F.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:F.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:F.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:F.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:F.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:F.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:F.INVALID_INPUT_OPTIONS_TRANSLATION}},Be=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Fe(Ve.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Fe(Ve.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Fe(Ve.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 Fe(Ve.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Fe(Ve.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 Fe(Ve.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 Fe(Ve.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Fe(Ve.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Fe(Ve.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Fe(Ve.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Fe(Ve.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Ge=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},je=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Fe(Ve.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Xe=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Fe(Ve.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Fe(Ve.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&ke(V.COLLECT_ALT_TEXT_DEPERECATED,Pe.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Fe(Ve.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},He=e=>{if(!e||!Array.isArray(e))throw new Fe(Ve.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Fe(Ve.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Fe(Ve.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Fe(Ve.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Fe(Ve.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Fe(Ve.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Fe(Ve.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},We=e=>"boolean"==typeof e;function ze(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Ke=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ee.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=te.DEFAULT;return Object.entries(de).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==te.DEFAULT&&t===te.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 $e(e){var t,i,n,o,a;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}`;fe.IFRAME_SECURE_ORGIN=s,fe.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}if(null===(a=e.options)||void 0===a?void 0:a.deserializedData.usePayrailsFrames){if(!fe.IFRAME_SECURE_ORGIN||!fe.IFRAME_SECURE_SITE){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:fe.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:fe.IFRAME_SECURE_SITE}}),e}fe.IFRAME_SECURE_ORGIN=me,fe.IFRAME_SECURE_SITE=ve}}class qe{constructor(e,t,i,n){this.setAttributess=e=>{Te(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 Fe(Ve.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Fe(Ve.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}Te(this.iframe,{src:Oe()}),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 Je{}var Ze,Qe,et,tt,it,nt,ot,st,rt,at,lt,dt,ct,ut,Et,_t,ht,It,pt,ft;const vt="Element";class mt extends Je{constructor(e,n,o,s,r=!1,a,l,d,c){var u;super(),this.type=Di.COLLECT,Ze.set(this,void 0),Qe.set(this,!1),et.set(this,void 0),tt.set(this,void 0),it.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),nt.set(this,void 0),ot.set(this,new pe),st.set(this,void 0),rt.set(this,x.getEventBus()),at.set(this,void 0),lt.set(this,[]),dt.set(this,!1),ct.set(this,void 0),ut.set(this,void 0),Et.set(this,!1),this.getID=()=>t(this,Ze,"f"),this.mount=e=>{var n;if(!e)throw new Fe(Ve.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,at,"f").name){n(t(this,nt,"f")),t(this,ft,"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}(t(this,et,"f")[0],["name"]);t(this,tt,"f").length>1?t(this,tt,"f").forEach(((e,i)=>{t(this,st,"f")&&t(this,st,"f")._emit(`${j.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,et,"f")[i]),{elementType:e.elementType}))})):t(this,ot,"f")._emit(j.READY,Object.assign({},e)),t(this,rt,"f").off(X+this.containerId,o),ke(`${xe(Y.ELEMENT_MOUNTED,vt,Ye(t(this,at,"f").name))} `,Pe.LOG,t(this,ct,"f").logLevel),t(this,lt,"f").forEach((e=>e())),i(this,lt,[],"f")}};if(t(this,tt,"f").length>1)t(this,at,"f").mount(e),t(this,rt,"f").on(X+this.containerId,o);else{if(t(this,Et,"f"))return t(this,at,"f").mount(e),void t(this,rt,"f").on(X+this.containerId,o);null===(n=t(this,st,"f"))||void 0===n||n.on(Q,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,at,"f").mount(e),t(this,rt,"f").on(X+this.containerId,o))}))}},this.unmount=()=>{t(this,at,"f").unmount()},this.update=e=>{let n=Le(e);const o=()=>{t(this,Qe,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,nt,Tt(t(this,nt,"f"),n),"f"),i(this,tt,yt(t(this,nt,"f")),"f"),t(this,Qe,"f")?t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:t(this,tt,"f")[0],isSingleElementAPI:!0}):(t(this,tt,"f").forEach((e=>{t(this,rt,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:t(this,nt,"f"),isSingleElementAPI:!1})),t(this,ft,"f").call(this)};t(this,dt,"f")?o():t(this,lt,"f").push(o)},_t.set(this,(e=>{t(this,Qe,"f")||t(this,ot,"f").on(K,(()=>{e(t(this,tt,"f"))}),!0)})),this.updateElement=e=>{t(this,rt,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})},ht.set(this,(()=>{t(this,et,"f").forEach(((e,i)=>{if(0===i){t(this,it,"f").isEmpty=e.isEmpty,t(this,it,"f").isComplete=e.isComplete,t(this,it,"f").isValid=e.isValid,t(this,it,"f").isFocused=e.isFocused,t(this,it,"f").isRequired=e.isRequired,t(this,it,"f").value={};const n=t(this,tt,"f")[i].elementName,o=e.value&&Ke(e.value,e.elementType,t(this,ut,"f"));t(this,Qe,"f")?t(this,it,"f").value=o:t(this,it,"f").value[n]=o}else t(this,it,"f").isEmpty=t(this,it,"f").isEmpty||e.isEmpty,t(this,it,"f").isComplete=t(this,it,"f").isComplete&&e.isComplete,t(this,it,"f").isValid=t(this,it,"f").isValid&&e.isValid,t(this,it,"f").isFocused=t(this,it,"f").isFocused||e.isFocused,t(this,it,"f").isRequired=t(this,it,"f").isRequired||e.isRequired,t(this,it,"f").value||(t(this,it,"f").value={}),t(this,tt,"f")[i].sensitive||(t(this,it,"f").value[t(this,tt,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,it,"f").isEmpty,isComplete:t(this,it,"f").isComplete,isValid:t(this,it,"f").isValid,isFocused:t(this,it,"f").isFocused,value:t(this,it,"f").value,required:t(this,it,"f").isRequired}),this.getOptions=()=>{let e=Le(t(this,nt,"f"));return t(this,Qe,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},It.set(this,(e=>{t(this,ot,"f").on(z,(()=>{const i=t(this,tt,"f").map((e=>e.elementName));t(this,Qe,"f")||i.push(t(this,at,"f").name),e(i)}),!0)})),pt.set(this,(()=>{t(this,rt,"f").on(W,(e=>{if(t(this,Qe,"f")&&e.event===j.READY&&e.name===t(this,at,"f").name)t(this,ot,"f")._emit(j.READY);else{const i=t(this,tt,"f").length>1;t(this,tt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case j.FOCUS:r=j.FOCUS;break;case j.BLUR:r=j.BLUR;break;case j.CHANGE:r=j.CHANGE;break;case j.READY:r=j.READY;break;case j.SUBMIT:return void(null===(s=t(this,st,"f"))||void 0===s||s._emit(j.SUBMIT));default:throw new Fe(Ve.INVALID_EVENT_TYPE,[],!0)}t(this,et,"f")[o].isEmpty=e.value.isEmpty,t(this,et,"f")[o].isValid=e.value.isValid,t(this,et,"f")[o].isComplete=e.value.isComplete,t(this,et,"f")[o].isFocused=e.value.isFocused,t(this,et,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,et,"f")[o].value=e.value.value:t(this,et,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,rt,"f").emit(j.HEIGHT+t(this,at,"f").name,{},(e=>{t(this,at,"f").setIframeHeight(e.height)})),t(this,ht,"f").call(this);const a=Object.assign(Object.assign({},t(this,et,"f")[o]),{elementType:n.elementType});i&&t(this,st,"f")?t(this,st,"f")._emit(r,a):t(this,ot,"f")._emit(r,a)}}))}}))})),ft.set(this,(()=>{const{rows:e}=t(this,nt,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==ne.radio.name&&e.elementType!==ne.checkbox.name&&(e.value=void 0)}))})),i(this,tt,yt(t(this,nt,"f")),"f")})),this.containerId=s.containerId,i(this,Ze,e,"f"),i(this,ct,d,"f"),i(this,nt,Tt(n),"f"),i(this,tt,yt(n),"f"),i(this,Qe,r,"f"),c&&i(this,st,c,"f"),i(this,ut,we[t(this,ct,"f").env].doesReturnValue,"f"),this.elementType=t(this,Qe,"f")?t(this,tt,"f")[0].elementType:"group",i(this,et,[],"f"),t(this,tt,"f").forEach((e=>{t(this,et,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,ut,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,at,new qe(t(this,nt,"f").elementName,o,this.containerId,t(this,ct,"f").logLevel),"f"),t(this,pt,"f").call(this),t(this,It,"f").call(this,a),t(this,_t,"f").call(this,l),ke(xe(Y.CREATED_ELEMENT,vt,Ye(t(this,at,"f").name)),Pe.LOG,t(this,ct,"f").logLevel),i(this,Et,s.isMounted,"f"),null===(u=t(this,st,"f"))||void 0===u||u.on(Q,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,Et,!0,"f")}));const E=e=>{e.height&&e.height>0&&t(this,at,"f").setIframeHeight(e.height)};t(this,rt,"f").on(j.MOUNTED,(e=>{s.type===Di.COMPOSABLE?t(this,tt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,dt,!0,"f"))})):e.name===t(this,tt,"f")[0].elementName&&(t(this,tt,"f")[0].isMounted=!0,i(this,dt,!0,"f")),t(this,rt,"f").emit(j.HEIGHT+t(this,at,"f").name,{},E)}))}on(e,i){if(!Object.values(j).includes(e))throw new Fe(Ve.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Fe(Ve.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Fe(Ve.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,ot,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,at,"f").name}isMounted(){return t(this,dt,"f")}isValidElement(){for(let e=0;e<t(this,tt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,tt,"f")[e],"table"))throw new Fe(Ve.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,tt,"f")[e].table)throw new Fe(Ve.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,tt,"f")[e].table||t(this,tt,"f")[e].table instanceof String))throw new Fe(Ve.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,tt,"f")[e],"column"))throw new Fe(Ve.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,tt,"f")[e].column)throw new Fe(Ve.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,tt,"f")[e].column||t(this,tt,"f")[e].column instanceof String))throw new Fe(Ve.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,tt,"f")[e].skyflowID&&!t(this,tt,"f")[e].skyflowID)throw new Fe(Ve.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,rt,"f").emit(q,{name:ze(t(this,at,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,rt,"f").emit(q,{name:ze(t(this,at,"f").name),isTriggerError:!1})}setValue(e){t(this,ct,"f").env!==De.PROD?t(this,Qe,"f")&&t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:Object.assign(Object.assign({},t(this,tt,"f")[0]),{value:e}),isSingleElementAPI:!0}):ke(xe(V.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,tt,"f")[0].elementType),Pe.WARN,t(this,ct,"f").logLevel)}clearValue(){t(this,ct,"f").env!==De.PROD?t(this,Qe,"f")&&t(this,rt,"f").emit(K,{name:t(this,at,"f").name,options:Object.assign(Object.assign({},t(this,tt,"f")[0]),{value:""}),isSingleElementAPI:!0}):ke(xe(V.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,tt,"f")[0].elementType),Pe.WARN,t(this,ct,"f").logLevel)}}function Nt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(ne,e))throw new Fe(Ve.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Fe(Ve.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Fe(Ve.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(be).includes(e.type))throw new Fe(Ve.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Fe(Ve.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Fe(Ve.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===be.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Fe(Ve.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===be.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Fe(Ve.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}=ne[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===ne.radio.name||e===ne.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==ne.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 Tt(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(F.CANNOT_CHANGE_ELEMENT);Nt(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({},ae),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(le).forEach((i=>{if(e[i]||t[i])switch(i){case le.BASE:t[i]=Object.assign({},t[i]);break;case le.FOCUS:t[le.BASE]=Object.assign(Object.assign({},t[le.BASE]),{":focus":Object.assign({},t[le.BASE]&&t[le.BASE][":focus"])});break;case le.WEBPACKAUTOFILL:t[le.BASE]=Object.assign(Object.assign({},t[le.BASE]),{":-webkit-autofill":Object.assign({},t[le.BASE]&&t[le.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[le.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}Ze=new WeakMap,Qe=new WeakMap,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,ft=new WeakMap;const yt=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Ot=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===be.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Fe(Ve.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof mt)))throw new Fe(Ve.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof mt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===be.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ge(e.params.regex))throw new Fe(Ve.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Ge(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},At=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(he.includes(e)?(ke(xe(V.INPUT_FORMATTING_NOT_SUPPROTED,e),Pe.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===ne.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Fe(Ve.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 Fe(Ve.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:Ie]}),null==n||delete n.format,null==n||delete n.translation)),e===ne.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)===oe&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===ne.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&ue.includes(o),e||ke(xe(V.INVALID_EXPIRATION_DATE_FORMAT,ue.toString()),Pe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():ce}),null==n||delete n.translation}else if(e===ne.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&Ee.includes(e))(n.format.toUpperCase()),e||ke(xe(V.INVALID_EXPIRATION_YEAR_FORMAT,Ee.toString()),Pe.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")&&!We(n.enableCardIcon))throw new Fe(Ve.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!We(n.enableCopy))throw new Fe(Ve.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!We(n.required))throw new Fe(Ve.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function Lt(){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 Rt{}var gt,St,Ct,Dt,Pt,bt,Mt,wt,Ut,kt,xt,Yt;const Ft="CollectContainer";class Vt extends Rt{constructor(e,n,o,s){super(),gt.set(this,void 0),St.set(this,{}),Ct.set(this,void 0),Dt.set(this,void 0),Pt.set(this,void 0),this.type=Di.COLLECT,bt.set(this,void 0),Mt.set(this,!1),this.create=(e,i={required:!1})=>{Xe(e,t(this,Dt,"f").logLevel);const n=Ot(e),o=At(e.type,i,t(this,Dt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:i.allowedFileType},e),o),{validations:n})]}]};return t(this,wt,"f").call(this,s,!0)},wt.set(this,((e,i=!1)=>{const n=[],o=Le(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Nt(i,t),t.sensitive=t.sensitive||ne[i].sensitive,t.replacePattern=t.replacePattern||ne[i].replacePattern,t.mask=t.mask||ne[i].mask,t.isMounted=!1,t.elementType!==ne.radio.name&&t.elementType!==ne.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${G}:${t.elementType}:${btoa(Lt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${G}:group:${btoa(o.name)}`,i&&!t(this,St,"f")[n[0].elementName]&&t(this,Yt,"f").call(this,n[0].name))throw new Fe(Ve.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,St,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=Lt();s=new mt(e,o,t(this,Ct,"f"),{containerId:t(this,gt,"f"),isMounted:t(this,Mt,"f"),type:this.type},i,t(this,kt,"f"),t(this,xt,"f"),t(this,Dt,"f"),t(this,bt,"f")),t(this,St,"f")[o.elementName]=s,t(this,Pt,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,St,"f")[i]?t(this,St,"f")[i].update(e):t(this,St,"f")[i]=this.create(e.elementType,s)})),s})),Ut.set(this,(e=>{Object.keys(t(this,St,"f")).forEach((i=>{i===e&&delete t(this,St,"f")[i]}))})),kt.set(this,(e=>{e.forEach((e=>{t(this,Ut,"f").call(this,e)}))})),xt.set(this,(e=>{e.forEach((e=>{t(this,St,"f")[e.elementName]&&t(this,St,"f")[e.elementName].update(e)}))})),Yt.set(this,(e=>{const i=Object.keys(t(this,St,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{je(t(this,Ct,"f").clientJSON.config);if(Object.values(t(this,St,"f")).forEach((e=>{if(!e.isMounted())throw new Fe(Ve.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!We(e.tokens))throw new Fe(Ve.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Be(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(H+t(this,gt,"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)?(ke(`${JSON.stringify(null==e?void 0:e.error)}`,Pe.ERROR,t(this,Dt,"f").logLevel),n(null==e?void 0:e.error)):(ke(xe(Y.COLLECT_SUBMIT_SUCCESS,Ft),Pe.LOG,t(this,Dt,"f").logLevel),i(e))})),ke(xe(Y.EMIT_EVENT,Ft,H),Pe.LOG,t(this,Dt,"f").logLevel)}catch(e){ke(`${e.message}`,Pe.ERROR,t(this,Dt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=x.getEventBus(),i(this,gt,Lt(),"f"),i(this,Ct,n,"f"),i(this,Pt,o,"f"),i(this,Dt,s,"f"),i(this,bt,new pe,"f"),this.iframe=ye({name:`${B}:${t(this,gt,"f")}:${t(this,Dt,"f").logLevel}`}),Te(this.iframe,{src:Oe()}),Ae(this.iframe,Object.assign({},re)),ke(xe(Y.CREATE_COLLECT_CONTAINER,Ft),Pe.LOG,t(this,Dt,"f").logLevel);const r=(e,o)=>{e.name===B+t(this,gt,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,Mt,!0,"f"),t(this,bt,"f")._emit(Q,{containerId:t(this,gt,"f")}),this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).off(X+t(this,gt,"f"),r))};this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).on(X+t(this,gt,"f"),r),document.body.append(this.iframe)}}gt=new WeakMap,St=new WeakMap,Ct=new WeakMap,Dt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,xt=new WeakMap,Yt=new WeakMap;var Bt=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},Gt=function(e){return e};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=o((function(e){return e&&e.length?Bt(e,Gt):0}));class _i{constructor(e,n){jt.set(this,void 0),Xt.set(this,void 0),this.type=Di.COMPOSABLE,Ht.set(this,!1),Wt.set(this,!1),this.update=e=>{i(this,Wt,!0,"f"),t(this,Ht,"f")?(t(this,Xt,"f")._emit(J,{elementName:t(this,jt,"f"),elementOptions:e}),i(this,Wt,!1,"f")):t(this,Wt,"f")&&t(this,Xt,"f").on(`${Se.READY}:${t(this,jt,"f")}`,(()=>{t(this,Xt,"f")._emit(J,{elementName:t(this,jt,"f"),elementOptions:e}),i(this,Ht,!0,"f"),i(this,Wt,!1,"f")}))},i(this,jt,e,"f"),i(this,Xt,n,"f"),t(this,Xt,"f").on(`${Se.READY}:${t(this,jt,"f")}`,(()=>{i(this,Ht,!0,"f")}))}on(e,i){if(!Object.values(j).includes(e))throw new Fe(Ve.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Fe(Ve.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Fe(Ve.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Xt,"f").on(`${e}:${t(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,i(e)}))}}jt=new WeakMap,Xt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap;const hi="CollectContainer";class Ii extends Rt{constructor(e,n,o,a){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=Di.COMPOSABLE,oi.set(this,!1),si.set(this,{}),this.create=(e,i={required:!1})=>{Xe(e,t(this,Zt,"f").logLevel);const n=Ot(e),o=At(e.type,i,t(this,Zt,"f").logLevel),s=`${G}:${e.type}:${btoa(Lt())}`;return t(this,Jt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new _i(s,t(this,ei,"f"))},ri.set(this,((e,n=!1)=>{const o=[];if(i(this,si,Le(e),"f"),t(this,si,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Nt(i,t),t.sensitive=t.sensitive||ne[i].sensitive,t.replacePattern=t.replacePattern||ne[i].replacePattern,t.mask=t.mask||ne[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,si,"f").elementName=n?o[0].elementName:`${G}:group:${btoa(t(this,si,"f").name)}`,n&&!t(this,Kt,"f")[o[0].elementName]&&t(this,ci,"f").call(this,o[0].name))throw new Fe(Ve.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,Kt,"f")[t(this,si,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,si,"f"));else{const e=Lt();s=new mt(e,t(this,si,"f"),t(this,$t,"f"),{containerId:t(this,zt,"f"),isMounted:t(this,oi,"f"),type:this.type},!0,t(this,li,"f"),t(this,di,"f"),t(this,Zt,"f"),t(this,ei,"f")),t(this,Kt,"f")[t(this,si,"f").elementName]=s,t(this,Qt,"f")[e]=s}return s})),ai.set(this,(e=>{Object.keys(t(this,Kt,"f")).forEach((i=>{i===e&&delete t(this,Kt,"f")[i]}))})),li.set(this,(e=>{e.forEach((e=>{t(this,ai,"f").call(this,e)}))})),di.set(this,(e=>{e.forEach((e=>{t(this,Kt,"f")[e.elementName]&&t(this,Kt,"f")[e.elementName].update(e)}))})),ci.set(this,(e=>{const i=Object.keys(t(this,Kt,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.on=(e,i)=>{if(!Object.values(j).includes(e))throw new Fe(Ve.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Fe(Ve.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Fe(Ve.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,ei,"f").on(j.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new Fe(Ve.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,ii,"f");if(Ei(n)!==t(this,Jt,"f").length)throw new Fe(Ve.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,qt,"f").rows=[...t(this,qt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,qt,"f").rows[i].elements.push(t(this,Jt,"f")[o]),o++})),t(this,ii,"f").styles&&(t(this,qt,"f").styles=Object.assign({},t(this,ii,"f").styles)),t(this,ii,"f").errorTextStyles&&(t(this,qt,"f").errorTextStyles=Object.assign({},t(this,ii,"f").errorTextStyles)),t(this,oi,"f"))return i(this,ni,t(this,ri,"f").call(this,t(this,qt,"f"),!1),"f"),t(this,ni,"f").mount(e),void i(this,ti,!0,"f");t(this,ei,"f").on(Z+t(this,zt,"f"),(()=>{i(this,ni,t(this,ri,"f").call(this,t(this,qt,"f"),!1),"f"),t(this,ni,"f").mount(e),i(this,ti,!0,"f")}))},this.unmount=()=>{var e;null===(e=t(this,ni,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(je(t(this,$t,"f").clientJSON.config),!t(this,ti,"f")){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}yt(t(this,si,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Fe(Ve.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,Kt,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Fe(Ve.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Be(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(H+t(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)?(ke(`${JSON.stringify(null==e?void 0:e.error)}`,Pe.ERROR,t(this,Zt,"f").logLevel),n(null==e?void 0:e.error)):(ke(xe(Y.COLLECT_SUBMIT_SUCCESS,hi),Pe.LOG,t(this,Zt,"f").logLevel),i(e))})),ke(xe(Y.EMIT_EVENT,hi,H),Pe.LOG,t(this,Zt,"f").logLevel)}catch(e){ke(`${e.message}`,Pe.ERROR,t(this,Zt,"f").logLevel),n(e)}})),ui.set(this,(()=>{t(this,ei,"f").on(J,(e=>{let i;const n=t(this,Jt,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,ni,"f")&&t(this,ni,"f").updateElement(Object.assign({},n[i]))}))})),this.bus=x.getEventBus(),i(this,zt,Lt(),"f"),i(this,$t,n,"f"),i(this,Qt,o,"f"),i(this,Zt,a,"f"),i(this,ii,e,"f"),i(this,ei,new pe,"f"),this.iframe=ye({name:`${B}:${t(this,zt,"f")}:${t(this,Zt,"f").logLevel}`}),Te(this.iframe,{src:Oe()}),Ae(this.iframe,Object.assign({},re)),ke(xe(Y.CREATE_COLLECT_CONTAINER,hi),Pe.LOG,t(this,Zt,"f").logLevel);const l=(e,o)=>{e.name===B+t(this,zt,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:a})),i(this,oi,!0,"f"),t(this,ei,"f")._emit(Z+t(this,zt,"f"),{containerId:t(this,zt,"f")}),this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).off(X+t(this,zt,"f"),l))};this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).on(X+t(this,zt,"f"),l),document.body.append(this.iframe),t(this,ui,"f").call(this)}}function pi(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,pi.prototype=new Error,pi.prototype.name="InvalidCharacterError";var fi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new pi("'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 vi(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(fi(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 fi(t)}}function mi(e){this.message=e}mi.prototype=new Error,mi.prototype.name="InvalidTokenError";const Ni=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 mi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(vi(e.split(".")[i]))}catch(e){throw new mi("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 Ti,yi,Oi,Ai,Li,Ri,gi,Si,Ci,Di,Pi={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class bi{constructor(e,n){Ti.set(this,void 0),this.request=e=>new Promise(((i,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const i=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:""}`}}(Pi,t(this,Ti,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(i);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(_e.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(_e.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(_e.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,t,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 i=JSON.parse(l.response);(null===(e=null==i?void 0:i.error)||void 0===e?void 0:e.message)&&(i=d?`${null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message} - requestId: ${d}`:null===(o=null==i?void 0:i.error)||void 0===o?void 0:o.message),n(new Fe({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new Fe({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Fe({code:l.status,description:d?`${F.ERROR_OCCURED} - requestId: ${d}`:F.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new Fe(Ve.NETWORK_ERROR,[],!0))}}else n(new Fe(Ve.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,Ti,n,"f")}toJSON(){return{config:this.config,metaData:t(this,Ti,"f")}}static fromJSON(e){return new bi(e.config,e.metaData)}}Ti=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Di||(Di={}));const Mi="Skyflow";class wi{constructor(e){var n,o;yi.set(this,void 0),Oi.set(this,Lt()),Ai.set(this,{uuid:t(this,Oi,"f"),clientDomain:window.location.origin}),Li.set(this,""),Ri.set(this,void 0),gi.set(this,void 0),Si.set(this,void 0),Ci.set(this,void 0),this.bus=x.getEventBus();const s=localStorage.getItem("sdk_version")||"";t(this,Ai,"f").sdkVersion=s,i(this,yi,new bi(Object.assign({},e),t(this,Ai,"f")),"f"),i(this,gi,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||Ce.ERROR,"f"),i(this,Si,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||De.PROD,"f"),i(this,Ci,{},"f");this.bus.target({origin:fe.IFRAME_SECURE_ORGIN}).on($+t(this,Oi,"f"),((e,n)=>{ke(xe(Y.CAPTURED_BEARER_TOKEN_EVENT,Mi),Pe.LOG,t(this,gi,"f")),!t(this,yi,"f").config.getBearerToken||t(this,Li,"f")&&Ni(t(this,Li,"f"))?(ke(xe(Y.REUSE_BEARER_TOKEN,Mi),Pe.LOG,t(this,gi,"f")),n({authToken:t(this,Li,"f")})):t(this,yi,"f").config.getBearerToken().then((e=>{Ni(e)?(ke(xe(Y.BEARER_TOKEN_RESOLVED,Mi),Pe.LOG,t(this,gi,"f")),i(this,Li,e,"f"),n({authToken:t(this,Li,"f")})):(ke(F.INVALID_BEARER_TOKEN,Pe.ERROR,t(this,gi,"f")),n({error:F.INVALID_BEARER_TOKEN}))})).catch((e=>{ke(F.BEARER_TOKEN_REJECTED,Pe.ERROR,t(this,gi,"f")),n({error:e})}))})),ke(xe(Y.BEARER_TOKEN_LISTENER,Mi),Pe.LOG,t(this,gi,"f")),ke(xe(Y.CURRENT_ENV,Mi,t(this,Si,"f")),Pe.LOG,t(this,gi,"f")),ke(xe(Y.CURRENT_LOG_LEVEL,Mi,t(this,gi,"f")),Pe.LOG,t(this,gi,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Ce.ERROR;$e(e),ke(xe(Y.INITIALIZE_CLIENT,Mi),Pe.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 wi(n);return ke(xe(Y.CLIENT_INITIALIZED,Mi),Pe.LOG,i),s}container(e,i){switch(e){case Di.COLLECT:{const n=new Vt(i,Object.assign(Object.assign({},t(this,Ai,"f")),{clientJSON:t(this,yi,"f").toJSON(),containerType:e}),t(this,Ci,"f"),{logLevel:t(this,gi,"f"),env:t(this,Si,"f")});return ke(xe(Y.COLLECT_CONTAINER_CREATED,Mi),Pe.LOG,t(this,gi,"f")),n}case Di.COMPOSABLE:{(e=>{if(!e)throw new Fe(Ve.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Fe(Ve.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Fe(Ve.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Fe(Ve.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Fe(Ve.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Fe(Ve.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Fe(Ve.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Fe(Ve.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new Ii(i,Object.assign(Object.assign({},t(this,Ai,"f")),{clientJSON:t(this,yi,"f").toJSON(),containerType:e}),t(this,Ci,"f"),{logLevel:t(this,gi,"f"),env:t(this,Si,"f")});return ke(xe(Y.COLLECT_CONTAINER_CREATED,Mi),Pe.LOG,t(this,gi,"f")),n}default:if(!e)throw new Fe(Ve.EMPTY_CONTAINER_TYPE,[],!0);throw new Fe(Ve.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return Di}static get ElementType(){return ee}static get RedactionType(){return Re}static get RequestMethod(){return ge}static get LogLevel(){return Ce}static get EventName(){return Se}static get Env(){return De}static get ValidationRuleType(){return be}}function Ui(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(ki(n)),dataAttributes:o}}function ki(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}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 Yi(e,t){if(void 0===t&&(t=Fi()),Bi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Ui(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Vi(s);
|
|
4
|
+
*/const me={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ve="https://assets.payrails.io/2ab28a7/card/index.html",Ne="https://assets.payrails.io",Te={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Ae=(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({},Te),e);return Object.assign(t.style,re),Ae(t,i),t.getAttribute("id")||(t.id=t.name),t};const ye=()=>me.IFRAME_SECURE_SITE,Re=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Le(e){return JSON.parse(JSON.stringify(e))}var ge,Se,Ce,De,Pe,be,Me;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(ge||(ge={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Se||(Se={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Ce||(Ce={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(De||(De={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Pe||(Pe={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(be||(be={})),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"}(Me||(Me={}));const we={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}},Ue={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},ke="[Skyflow]",xe=(e,t,i)=>{if(i&&we[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=we[i];t===be.LOG&&n?console.log(`${De.DEBUG}: ${ke} ${e}`):t===be.LOG&&o?console.log(`${De.INFO}: ${ke} ${e}`):t===be.WARN&&s?console.warn(`${De.WARN}: ${ke} ${e}`):t===be.ERROR&&r&&console.error(`${De.ERROR}: ${ke} ${e}`)}},Ye=(...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]})):""},Fe=(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 Ve extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Ye(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Be={INVALID_FIELD:{code:400,description:V.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:V.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:V.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:V.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:V.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:V.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:V.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:V.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:V.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:V.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:V.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:V.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:V.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:V.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:V.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:V.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:V.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:V.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:V.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:V.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:V.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:V.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:V.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:V.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:V.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:V.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:V.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:V.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:V.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:V.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:V.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:V.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:V.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:V.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:V.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:V.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:V.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:V.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:V.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:V.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:V.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:V.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:V.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:V.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:V.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:V.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:V.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:V.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:V.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:V.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:V.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:V.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:V.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:V.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:V.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:V.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:V.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:V.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:V.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:V.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:V.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:V.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:V.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:V.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:V.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:V.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:V.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:V.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:V.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:V.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:V.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:V.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:V.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:V.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:V.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:V.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:V.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:V.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:V.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:V.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:V.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:V.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:V.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:V.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:V.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:V.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:V.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:V.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:V.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:V.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:V.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:V.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:V.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:V.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:V.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:V.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:V.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:V.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:V.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:V.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:V.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:V.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:V.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:V.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:V.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:V.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:V.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:V.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:V.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:V.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:V.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:V.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:V.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:V.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:V.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:V.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:V.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:V.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:V.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:V.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:V.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:V.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:V.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:V.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:V.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:V.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:V.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:V.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:V.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:V.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:V.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:V.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:V.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:V.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:V.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:V.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:V.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:V.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:V.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:V.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:V.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:V.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:V.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:V.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:V.INVALID_INPUT_OPTIONS_TRANSLATION}},Ge=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Ve(Be.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Ve(Be.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Ve(Be.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 Ve(Be.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Ve(Be.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 Ve(Be.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 Ve(Be.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Ve(Be.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Ve(Be.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Ve(Be.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Ve(Be.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},je=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Xe=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Ve(Be.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},He=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Ve(Be.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Ve(Be.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&xe(B.COLLECT_ALT_TEXT_DEPERECATED,be.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Ve(Be.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},We=e=>{if(!e||!Array.isArray(e))throw new Ve(Be.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Ve(Be.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Ve(Be.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Ve(Be.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Ve(Be.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Ve(Be.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Ve(Be.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},ze=e=>"boolean"==typeof e;function Ke(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const $e=(e,t,i)=>{if("string"!=typeof e)return e;if(t===te.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=ie.DEFAULT;return Object.entries(ce).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==ie.DEFAULT&&t===ie.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 qe(e){var t,i,n,o,a;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}`;me.IFRAME_SECURE_ORGIN=s,me.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}if(null===(a=e.options)||void 0===a?void 0:a.deserializedData.usePayrailsFrames){if(!me.IFRAME_SECURE_ORGIN||!me.IFRAME_SECURE_SITE){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:me.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:me.IFRAME_SECURE_SITE}}),e}me.IFRAME_SECURE_ORGIN=Ne,me.IFRAME_SECURE_SITE=ve}}class Je{constructor(e,t,i,n){this.setAttributess=e=>{Ae(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 Ve(Be.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Ve(Be.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}Ae(this.iframe,{src:ye()}),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 Ze{}var Qe,et,tt,it,nt,ot,st,rt,at,lt,dt,ct,ut,Et,_t,ht,It,pt,ft,mt;const vt="Element";class Nt extends Ze{constructor(e,n,o,s,r=!1,a,l,d,c){var u;super(),this.type=Pi.COLLECT,Qe.set(this,void 0),et.set(this,!1),tt.set(this,void 0),it.set(this,void 0),nt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),ot.set(this,void 0),st.set(this,new fe),rt.set(this,void 0),at.set(this,Y.getEventBus()),lt.set(this,void 0),dt.set(this,[]),ct.set(this,!1),ut.set(this,void 0),Et.set(this,void 0),_t.set(this,!1),this.getID=()=>t(this,Qe,"f"),this.mount=e=>{var n;if(!e)throw new Ve(Be.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,n)=>{if(e.name===t(this,lt,"f").name){n(t(this,ot,"f")),t(this,mt,"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}(t(this,tt,"f")[0],["name"]);t(this,it,"f").length>1?t(this,it,"f").forEach(((e,i)=>{t(this,rt,"f")&&t(this,rt,"f")._emit(`${X.READY}:${e.elementName}`,Object.assign(Object.assign({},t(this,tt,"f")[i]),{elementType:e.elementType}))})):t(this,st,"f")._emit(X.READY,Object.assign({},e)),t(this,at,"f").off(H+this.containerId,o),xe(`${Ye(F.ELEMENT_MOUNTED,vt,Fe(t(this,lt,"f").name))} `,be.LOG,t(this,ut,"f").logLevel),t(this,dt,"f").forEach((e=>e())),i(this,dt,[],"f")}};if(t(this,it,"f").length>1)t(this,lt,"f").mount(e),t(this,at,"f").on(H+this.containerId,o);else{if(t(this,_t,"f"))return t(this,lt,"f").mount(e),void t(this,at,"f").on(H+this.containerId,o);null===(n=t(this,rt,"f"))||void 0===n||n.on(ee,(i=>{(null==i?void 0:i.containerId)===this.containerId&&(t(this,lt,"f").mount(e),t(this,at,"f").on(H+this.containerId,o))}))}},this.unmount=()=>{t(this,lt,"f").unmount()},this.update=e=>{let n=Le(e);const o=()=>{t(this,et,"f")&&(n={rows:[{elements:[Object.assign({},n)]}]}),i(this,ot,At(t(this,ot,"f"),n),"f"),i(this,it,Ot(t(this,ot,"f")),"f"),t(this,et,"f")?t(this,at,"f").emit($,{name:t(this,lt,"f").name,options:t(this,it,"f")[0],isSingleElementAPI:!0}):(t(this,it,"f").forEach((e=>{t(this,at,"f").emit($,{name:e.elementName,options:e,isSingleElementAPI:!0})})),t(this,at,"f").emit($,{name:t(this,lt,"f").name,options:t(this,ot,"f"),isSingleElementAPI:!1})),t(this,mt,"f").call(this)};t(this,ct,"f")?o():t(this,dt,"f").push(o)},ht.set(this,(e=>{t(this,et,"f")||t(this,st,"f").on($,(()=>{e(t(this,it,"f"))}),!0)})),this.updateElement=e=>{t(this,at,"f").emit($,{name:e.elementName,options:e,isSingleElementAPI:!0})},It.set(this,(()=>{t(this,tt,"f").forEach(((e,i)=>{if(0===i){t(this,nt,"f").isEmpty=e.isEmpty,t(this,nt,"f").isComplete=e.isComplete,t(this,nt,"f").isValid=e.isValid,t(this,nt,"f").isFocused=e.isFocused,t(this,nt,"f").isRequired=e.isRequired,t(this,nt,"f").value={};const n=t(this,it,"f")[i].elementName,o=e.value&&$e(e.value,e.elementType,t(this,Et,"f"));t(this,et,"f")?t(this,nt,"f").value=o:t(this,nt,"f").value[n]=o}else t(this,nt,"f").isEmpty=t(this,nt,"f").isEmpty||e.isEmpty,t(this,nt,"f").isComplete=t(this,nt,"f").isComplete&&e.isComplete,t(this,nt,"f").isValid=t(this,nt,"f").isValid&&e.isValid,t(this,nt,"f").isFocused=t(this,nt,"f").isFocused||e.isFocused,t(this,nt,"f").isRequired=t(this,nt,"f").isRequired||e.isRequired,t(this,nt,"f").value||(t(this,nt,"f").value={}),t(this,it,"f")[i].sensitive||(t(this,nt,"f").value[t(this,it,"f")[i].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:t(this,nt,"f").isEmpty,isComplete:t(this,nt,"f").isComplete,isValid:t(this,nt,"f").isValid,isFocused:t(this,nt,"f").isFocused,value:t(this,nt,"f").value,required:t(this,nt,"f").isRequired}),this.getOptions=()=>{let e=Le(t(this,ot,"f"));return t(this,et,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},pt.set(this,(e=>{t(this,st,"f").on(K,(()=>{const i=t(this,it,"f").map((e=>e.elementName));t(this,et,"f")||i.push(t(this,lt,"f").name),e(i)}),!0)})),ft.set(this,(()=>{t(this,at,"f").on(z,(e=>{if(t(this,et,"f")&&e.event===X.READY&&e.name===t(this,lt,"f").name)t(this,st,"f")._emit(X.READY);else{const i=t(this,it,"f").length>1;t(this,it,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case X.FOCUS:r=X.FOCUS;break;case X.BLUR:r=X.BLUR;break;case X.CHANGE:r=X.CHANGE;break;case X.READY:r=X.READY;break;case X.SUBMIT:return void(null===(s=t(this,rt,"f"))||void 0===s||s._emit(X.SUBMIT));default:throw new Ve(Be.INVALID_EVENT_TYPE,[],!0)}t(this,tt,"f")[o].isEmpty=e.value.isEmpty,t(this,tt,"f")[o].isValid=e.value.isValid,t(this,tt,"f")[o].isComplete=e.value.isComplete,t(this,tt,"f")[o].isFocused=e.value.isFocused,t(this,tt,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?t(this,tt,"f")[o].value=e.value.value:t(this,tt,"f")[o].value=void 0,r=i?`${r}:${e.name}`:r,t(this,at,"f").emit(X.HEIGHT+t(this,lt,"f").name,{},(e=>{t(this,lt,"f").setIframeHeight(e.height)})),t(this,It,"f").call(this);const a=Object.assign(Object.assign({},t(this,tt,"f")[o]),{elementType:n.elementType});i&&t(this,rt,"f")?t(this,rt,"f")._emit(r,a):t(this,st,"f")._emit(r,a)}}))}}))})),mt.set(this,(()=>{const{rows:e}=t(this,ot,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==oe.radio.name&&e.elementType!==oe.checkbox.name&&(e.value=void 0)}))})),i(this,it,Ot(t(this,ot,"f")),"f")})),this.containerId=s.containerId,i(this,Qe,e,"f"),i(this,ut,d,"f"),i(this,ot,At(n),"f"),i(this,it,Ot(n),"f"),i(this,et,r,"f"),c&&i(this,rt,c,"f"),i(this,Et,Ue[t(this,ut,"f").env].doesReturnValue,"f"),this.elementType=t(this,et,"f")?t(this,it,"f")[0].elementType:"group",i(this,tt,[],"f"),t(this,it,"f").forEach((e=>{t(this,tt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:t(this,Et,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),i(this,lt,new Je(t(this,ot,"f").elementName,o,this.containerId,t(this,ut,"f").logLevel),"f"),t(this,ft,"f").call(this),t(this,pt,"f").call(this,a),t(this,ht,"f").call(this,l),xe(Ye(F.CREATED_ELEMENT,vt,Fe(t(this,lt,"f").name)),be.LOG,t(this,ut,"f").logLevel),i(this,_t,s.isMounted,"f"),null===(u=t(this,rt,"f"))||void 0===u||u.on(ee,(e=>{(null==e?void 0:e.containerId)===this.containerId&&i(this,_t,!0,"f")}));const E=e=>{e.height&&e.height>0&&t(this,lt,"f").setIframeHeight(e.height)};t(this,at,"f").on(X.MOUNTED,(e=>{s.type===Pi.COMPOSABLE?t(this,it,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,i(this,ct,!0,"f"))})):e.name===t(this,it,"f")[0].elementName&&(t(this,it,"f")[0].isMounted=!0,i(this,ct,!0,"f")),t(this,at,"f").emit(X.HEIGHT+t(this,lt,"f").name,{},E)}))}on(e,i){if(!Object.values(X).includes(e))throw new Ve(Be.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Ve(Be.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Ve(Be.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,st,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,i(e)}))}iframeName(){return t(this,lt,"f").name}isMounted(){return t(this,ct,"f")}isValidElement(){for(let e=0;e<t(this,it,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(t(this,it,"f")[e],"table"))throw new Ve(Be.MISSING_TABLE_IN_COLLECT,[],!0);if(!t(this,it,"f")[e].table)throw new Ve(Be.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof t(this,it,"f")[e].table||t(this,it,"f")[e].table instanceof String))throw new Ve(Be.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(t(this,it,"f")[e],"column"))throw new Ve(Be.MISSING_COLUMN_IN_COLLECT,[],!0);if(!t(this,it,"f")[e].column)throw new Ve(Be.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof t(this,it,"f")[e].column||t(this,it,"f")[e].column instanceof String))throw new Ve(Be.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==t(this,it,"f")[e].skyflowID&&!t(this,it,"f")[e].skyflowID)throw new Ve(Be.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){t(this,at,"f").emit(J,{name:Ke(t(this,lt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){t(this,at,"f").emit(J,{name:Ke(t(this,lt,"f").name),isTriggerError:!1})}setValue(e){t(this,ut,"f").env!==Pe.PROD?t(this,et,"f")&&t(this,at,"f").emit($,{name:t(this,lt,"f").name,options:Object.assign(Object.assign({},t(this,it,"f")[0]),{value:e}),isSingleElementAPI:!0}):xe(Ye(B.UNABLE_TO_SET_VALUE_IN_PROD_ENV,t(this,it,"f")[0].elementType),be.WARN,t(this,ut,"f").logLevel)}clearValue(){t(this,ut,"f").env!==Pe.PROD?t(this,et,"f")&&t(this,at,"f").emit($,{name:t(this,lt,"f").name,options:Object.assign(Object.assign({},t(this,it,"f")[0]),{value:""}),isSingleElementAPI:!0}):xe(Ye(B.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,t(this,it,"f")[0].elementType),be.WARN,t(this,ut,"f").logLevel)}}function Tt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(oe,e))throw new Ve(Be.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Ve(Be.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Ve(Be.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(Me).includes(e.type))throw new Ve(Be.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Ve(Be.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Ve(Be.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===Me.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Ve(Be.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===Me.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Ve(Be.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}=oe[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===oe.radio.name||e===oe.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==oe.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 At(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(V.CANNOT_CHANGE_ELEMENT);Tt(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({},le),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(de).forEach((i=>{if(e[i]||t[i])switch(i){case de.BASE:t[i]=Object.assign({},t[i]);break;case de.FOCUS:t[de.BASE]=Object.assign(Object.assign({},t[de.BASE]),{":focus":Object.assign({},t[de.BASE]&&t[de.BASE][":focus"])});break;case de.WEBPACKAUTOFILL:t[de.BASE]=Object.assign(Object.assign({},t[de.BASE]),{":-webkit-autofill":Object.assign({},t[de.BASE]&&t[de.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[de.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}Qe=new WeakMap,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,ft=new WeakMap,mt=new WeakMap;const Ot=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},yt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===Me.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Ve(Be.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof Nt)))throw new Ve(Be.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof Nt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===Me.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!je(e.params.regex))throw new Ve(Be.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&je(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Rt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(Ie.includes(e)?(xe(Ye(B.INPUT_FORMATTING_NOT_SUPPROTED,e),be.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===oe.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Ve(Be.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 Ve(Be.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:pe]}),null==n||delete n.format,null==n||delete n.translation)),e===oe.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)===se&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===oe.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&Ee.includes(o),e||xe(Ye(B.INVALID_EXPIRATION_DATE_FORMAT,Ee.toString()),be.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():ue}),null==n||delete n.translation}else if(e===oe.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&_e.includes(e))(n.format.toUpperCase()),e||xe(Ye(B.INVALID_EXPIRATION_YEAR_FORMAT,_e.toString()),be.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")&&!ze(n.enableCardIcon))throw new Ve(Be.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!ze(n.enableCopy))throw new Ve(Be.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!ze(n.required))throw new Ve(Be.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function Lt(){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 gt{}var St,Ct,Dt,Pt,bt,Mt,wt,Ut,kt,xt,Yt,Ft;const Vt="CollectContainer";class Bt extends gt{constructor(e,n,o,s){super(),St.set(this,void 0),Ct.set(this,{}),Dt.set(this,void 0),Pt.set(this,void 0),bt.set(this,void 0),this.type=Pi.COLLECT,Mt.set(this,void 0),wt.set(this,!1),this.create=(e,i={required:!1})=>{He(e,t(this,Pt,"f").logLevel);const n=yt(e),o=Rt(e.type,i,t(this,Pt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:i.allowedFileType},e),o),{validations:n})]}]};return t(this,Ut,"f").call(this,s,!0)},Ut.set(this,((e,i=!1)=>{const n=[],o=Le(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Tt(i,t),t.sensitive=t.sensitive||oe[i].sensitive,t.replacePattern=t.replacePattern||oe[i].replacePattern,t.mask=t.mask||oe[i].mask,t.isMounted=!1,t.elementType!==oe.radio.name&&t.elementType!==oe.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${j}:${t.elementType}:${btoa(Lt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=i?n[0].elementName:`${j}:group:${btoa(o.name)}`,i&&!t(this,Ct,"f")[n[0].elementName]&&t(this,Ft,"f").call(this,n[0].name))throw new Ve(Be.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=t(this,Ct,"f")[o.elementName];if(s)i?s.update(n[0]):s.update(o);else{const e=Lt();s=new Nt(e,o,t(this,Dt,"f"),{containerId:t(this,St,"f"),isMounted:t(this,wt,"f"),type:this.type},i,t(this,xt,"f"),t(this,Yt,"f"),t(this,Pt,"f"),t(this,Mt,"f")),t(this,Ct,"f")[o.elementName]=s,t(this,bt,"f")[e]=s}return i||n.forEach((e=>{const i=e.elementName;t(this,Ct,"f")[i]?t(this,Ct,"f")[i].update(e):t(this,Ct,"f")[i]=this.create(e.elementType,s)})),s})),kt.set(this,(e=>{Object.keys(t(this,Ct,"f")).forEach((i=>{i===e&&delete t(this,Ct,"f")[i]}))})),xt.set(this,(e=>{e.forEach((e=>{t(this,kt,"f").call(this,e)}))})),Yt.set(this,(e=>{e.forEach((e=>{t(this,Ct,"f")[e.elementName]&&t(this,Ct,"f")[e.elementName].update(e)}))})),Ft.set(this,(e=>{const i=Object.keys(t(this,Ct,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{Xe(t(this,Dt,"f").clientJSON.config);if(Object.values(t(this,Ct,"f")).forEach((e=>{if(!e.isMounted())throw new Ve(Be.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!ze(e.tokens))throw new Ve(Be.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Ge(e.additionalFields),(null==e?void 0:e.upsert)&&We(null==e?void 0:e.upsert),this.bus.emit(W+t(this,St,"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)}`,be.ERROR,t(this,Pt,"f").logLevel),n(null==e?void 0:e.error)):(xe(Ye(F.COLLECT_SUBMIT_SUCCESS,Vt),be.LOG,t(this,Pt,"f").logLevel),i(e))})),xe(Ye(F.EMIT_EVENT,Vt,W),be.LOG,t(this,Pt,"f").logLevel)}catch(e){xe(`${e.message}`,be.ERROR,t(this,Pt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=Y.getEventBus(),i(this,St,Lt(),"f"),i(this,Dt,n,"f"),i(this,bt,o,"f"),i(this,Pt,s,"f"),i(this,Mt,new fe,"f"),this.iframe=Oe({name:`${G}:${t(this,St,"f")}:${t(this,Pt,"f").logLevel}`}),Ae(this.iframe,{src:ye()}),Re(this.iframe,Object.assign({},ae)),xe(Ye(F.CREATE_COLLECT_CONTAINER,Vt),be.LOG,t(this,Pt,"f").logLevel);const r=(e,o)=>{e.name===G+t(this,St,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:s})),i(this,wt,!0,"f"),t(this,Mt,"f")._emit(ee,{containerId:t(this,St,"f")}),this.bus.target({origin:me.IFRAME_SECURE_ORGIN}).off(H+t(this,St,"f"),r))};this.bus.target({origin:me.IFRAME_SECURE_ORGIN}).on(H+t(this,St,"f"),r),document.body.append(this.iframe)}}St=new WeakMap,Ct=new WeakMap,Dt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,xt=new WeakMap,Yt=new WeakMap,Ft=new WeakMap;var Gt=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},jt=function(e){return e};var Xt,Ht,Wt,zt,Kt,$t,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,di,ci,ui,Ei,_i=o((function(e){return e&&e.length?Gt(e,jt):0}));class hi{constructor(e,n){Xt.set(this,void 0),Ht.set(this,void 0),this.type=Pi.COMPOSABLE,Wt.set(this,!1),zt.set(this,!1),this.update=e=>{i(this,zt,!0,"f"),t(this,Wt,"f")?(t(this,Ht,"f")._emit(Z,{elementName:t(this,Xt,"f"),elementOptions:e}),i(this,zt,!1,"f")):t(this,zt,"f")&&t(this,Ht,"f").on(`${Ce.READY}:${t(this,Xt,"f")}`,(()=>{t(this,Ht,"f")._emit(Z,{elementName:t(this,Xt,"f"),elementOptions:e}),i(this,Wt,!0,"f"),i(this,zt,!1,"f")}))},i(this,Xt,e,"f"),i(this,Ht,n,"f"),t(this,Ht,"f").on(`${Ce.READY}:${t(this,Xt,"f")}`,(()=>{i(this,Wt,!0,"f")}))}on(e,i){if(!Object.values(X).includes(e))throw new Ve(Be.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Ve(Be.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Ve(Be.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,Ht,"f").on(`${e}:${t(this,Xt,"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,i(e)}))}}Xt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,zt=new WeakMap;const Ii="CollectContainer";class pi extends gt{constructor(e,n,o,a){super(),Kt.set(this,void 0),$t.set(this,{}),qt.set(this,void 0),Jt.set(this,{rows:[]}),Zt.set(this,[]),Qt.set(this,void 0),ei.set(this,void 0),ti.set(this,void 0),ii.set(this,!1),ni.set(this,void 0),oi.set(this,void 0),this.type=Pi.COMPOSABLE,si.set(this,!1),ri.set(this,{}),this.create=(e,i={required:!1})=>{He(e,t(this,Qt,"f").logLevel);const n=yt(e),o=Rt(e.type,i,t(this,Qt,"f").logLevel),s=`${j}:${e.type}:${btoa(Lt())}`;return t(this,Zt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new hi(s,t(this,ti,"f"))},ai.set(this,((e,n=!1)=>{const o=[];if(i(this,ri,Le(e),"f"),t(this,ri,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;Tt(i,t),t.sensitive=t.sensitive||oe[i].sensitive,t.replacePattern=t.replacePattern||oe[i].replacePattern,t.mask=t.mask||oe[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),t(this,ri,"f").elementName=n?o[0].elementName:`${j}:group:${btoa(t(this,ri,"f").name)}`,n&&!t(this,$t,"f")[o[0].elementName]&&t(this,ui,"f").call(this,o[0].name))throw new Ve(Be.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=t(this,$t,"f")[t(this,ri,"f").elementName];if(s)n?s.update(o[0]):s.update(t(this,ri,"f"));else{const e=Lt();s=new Nt(e,t(this,ri,"f"),t(this,qt,"f"),{containerId:t(this,Kt,"f"),isMounted:t(this,si,"f"),type:this.type},!0,t(this,di,"f"),t(this,ci,"f"),t(this,Qt,"f"),t(this,ti,"f")),t(this,$t,"f")[t(this,ri,"f").elementName]=s,t(this,ei,"f")[e]=s}return s})),li.set(this,(e=>{Object.keys(t(this,$t,"f")).forEach((i=>{i===e&&delete t(this,$t,"f")[i]}))})),di.set(this,(e=>{e.forEach((e=>{t(this,li,"f").call(this,e)}))})),ci.set(this,(e=>{e.forEach((e=>{t(this,$t,"f")[e.elementName]&&t(this,$t,"f")[e.elementName].update(e)}))})),ui.set(this,(e=>{const i=Object.keys(t(this,$t,"f"));for(let t=0;t<i.length;t+=1)if(atob(i[t].split(":")[2])===e)return!0;return!1})),this.on=(e,i)=>{if(!Object.values(X).includes(e))throw new Ve(Be.INVALID_EVENT_LISTENER,[],!0);if(!i)throw new Ve(Be.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof i)throw new Ve(Be.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);t(this,ti,"f").on(X.SUBMIT,(()=>{i()}))},this.mount=e=>{if(!e)throw new Ve(Be.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:n}=t(this,ni,"f");if(_i(n)!==t(this,Zt,"f").length)throw new Ve(Be.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(n.forEach(((e,i)=>{t(this,Jt,"f").rows=[...t(this,Jt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)t(this,Jt,"f").rows[i].elements.push(t(this,Zt,"f")[o]),o++})),t(this,ni,"f").styles&&(t(this,Jt,"f").styles=Object.assign({},t(this,ni,"f").styles)),t(this,ni,"f").errorTextStyles&&(t(this,Jt,"f").errorTextStyles=Object.assign({},t(this,ni,"f").errorTextStyles)),t(this,si,"f"))return i(this,oi,t(this,ai,"f").call(this,t(this,Jt,"f"),!1),"f"),t(this,oi,"f").mount(e),void i(this,ii,!0,"f");t(this,ti,"f").on(Q+t(this,Kt,"f"),(()=>{i(this,oi,t(this,ai,"f").call(this,t(this,Jt,"f"),!1),"f"),t(this,oi,"f").mount(e),i(this,ii,!0,"f")}))},this.unmount=()=>{var e;null===(e=t(this,oi,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((i,n)=>{try{if(Xe(t(this,qt,"f").clientJSON.config),!t(this,ii,"f")){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}Ot(t(this,ri,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Ve(Be.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(t(this,$t,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Ve(Be.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Ge(e.additionalFields),(null==e?void 0:e.upsert)&&We(null==e?void 0:e.upsert),this.bus.emit(W+t(this,Kt,"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)}`,be.ERROR,t(this,Qt,"f").logLevel),n(null==e?void 0:e.error)):(xe(Ye(F.COLLECT_SUBMIT_SUCCESS,Ii),be.LOG,t(this,Qt,"f").logLevel),i(e))})),xe(Ye(F.EMIT_EVENT,Ii,W),be.LOG,t(this,Qt,"f").logLevel)}catch(e){xe(`${e.message}`,be.ERROR,t(this,Qt,"f").logLevel),n(e)}})),Ei.set(this,(()=>{t(this,ti,"f").on(Z,(e=>{let i;const n=t(this,Zt,"f").map(((t,n)=>t.elementName===e.elementName?(i=n,Object.assign({elementName:t.elementName},e.elementOptions)):t));t(this,oi,"f")&&t(this,oi,"f").updateElement(Object.assign({},n[i]))}))})),this.bus=Y.getEventBus(),i(this,Kt,Lt(),"f"),i(this,qt,n,"f"),i(this,ei,o,"f"),i(this,Qt,a,"f"),i(this,ni,e,"f"),i(this,ti,new fe,"f"),this.iframe=Oe({name:`${G}:${t(this,Kt,"f")}:${t(this,Qt,"f").logLevel}`}),Ae(this.iframe,{src:ye()}),Re(this.iframe,Object.assign({},ae)),xe(Ye(F.CREATE_COLLECT_CONTAINER,Ii),be.LOG,t(this,Qt,"f").logLevel);const l=(e,o)=>{e.name===G+t(this,Kt,"f")&&(o(Object.assign(Object.assign({},n),{clientJSON:Object.assign(Object.assign({},n.clientJSON),{config:Object.assign({},n.clientJSON.config)}),context:a})),i(this,si,!0,"f"),t(this,ti,"f")._emit(Q+t(this,Kt,"f"),{containerId:t(this,Kt,"f")}),this.bus.target({origin:me.IFRAME_SECURE_ORGIN}).off(H+t(this,Kt,"f"),l))};this.bus.target({origin:me.IFRAME_SECURE_ORGIN}).on(H+t(this,Kt,"f"),l),document.body.append(this.iframe),t(this,Ei,"f").call(this)}}function fi(e){this.message=e}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,Ei=new WeakMap,fi.prototype=new Error,fi.prototype.name="InvalidCharacterError";var mi="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 vi(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(mi(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 mi(t)}}function Ni(e){this.message=e}Ni.prototype=new Error,Ni.prototype.name="InvalidTokenError";const Ti=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 Ni("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(vi(e.split(".")[i]))}catch(e){throw new Ni("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 Ai,Oi,yi,Ri,Li,gi,Si,Ci,Di,Pi,bi={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Mi{constructor(e,n){Ai.set(this,void 0),this.request=e=>new Promise(((i,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const i=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:""}`}}(bi,t(this,Ai,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(i);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(he.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(he.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(he.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,t,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 i=JSON.parse(l.response);(null===(e=null==i?void 0:i.error)||void 0===e?void 0:e.message)&&(i=d?`${null===(t=null==i?void 0:i.error)||void 0===t?void 0:t.message} - requestId: ${d}`:null===(o=null==i?void 0:i.error)||void 0===o?void 0:o.message),n(new Ve({code:l.status,description:i},[],!0))}else a&&a.includes("text/plain")?n(new Ve({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Ve({code:l.status,description:d?`${V.ERROR_OCCURED} - requestId: ${d}`:V.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&i(JSON.parse(l.response)),i(l.response)},l.onerror=()=>{n(new Ve(Be.NETWORK_ERROR,[],!0))}}else n(new Ve(Be.CONNECTION_ERROR,[],!0))})),this.config=e,i(this,Ai,n,"f")}toJSON(){return{config:this.config,metaData:t(this,Ai,"f")}}static fromJSON(e){return new Mi(e.config,e.metaData)}}Ai=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Pi||(Pi={}));const wi="Skyflow";class Ui{constructor(e){var n,o;Oi.set(this,void 0),yi.set(this,Lt()),Ri.set(this,{uuid:t(this,yi,"f"),clientDomain:window.location.origin}),Li.set(this,""),gi.set(this,void 0),Si.set(this,void 0),Ci.set(this,void 0),Di.set(this,void 0),this.bus=Y.getEventBus();const s=localStorage.getItem("sdk_version")||"";t(this,Ri,"f").sdkVersion=s,i(this,Oi,new Mi(Object.assign({},e),t(this,Ri,"f")),"f"),i(this,Si,(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.logLevel)||De.ERROR,"f"),i(this,Ci,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||Pe.PROD,"f"),i(this,Di,{},"f");this.bus.target({origin:me.IFRAME_SECURE_ORGIN}).on(q+t(this,yi,"f"),((e,n)=>{xe(Ye(F.CAPTURED_BEARER_TOKEN_EVENT,wi),be.LOG,t(this,Si,"f")),!t(this,Oi,"f").config.getBearerToken||t(this,Li,"f")&&Ti(t(this,Li,"f"))?(xe(Ye(F.REUSE_BEARER_TOKEN,wi),be.LOG,t(this,Si,"f")),n({authToken:t(this,Li,"f")})):t(this,Oi,"f").config.getBearerToken().then((e=>{Ti(e)?(xe(Ye(F.BEARER_TOKEN_RESOLVED,wi),be.LOG,t(this,Si,"f")),i(this,Li,e,"f"),n({authToken:t(this,Li,"f")})):(xe(V.INVALID_BEARER_TOKEN,be.ERROR,t(this,Si,"f")),n({error:V.INVALID_BEARER_TOKEN}))})).catch((e=>{xe(V.BEARER_TOKEN_REJECTED,be.ERROR,t(this,Si,"f")),n({error:e})}))})),xe(Ye(F.BEARER_TOKEN_LISTENER,wi),be.LOG,t(this,Si,"f")),xe(Ye(F.CURRENT_ENV,wi,t(this,Ci,"f")),be.LOG,t(this,Si,"f")),xe(Ye(F.CURRENT_LOG_LEVEL,wi,t(this,Si,"f")),be.LOG,t(this,Si,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||De.ERROR;qe(e),xe(Ye(F.INITIALIZE_CLIENT,wi),be.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 Ui(n);return xe(Ye(F.CLIENT_INITIALIZED,wi),be.LOG,i),s}container(e,i){switch(e){case Pi.COLLECT:{const n=new Bt(i,Object.assign(Object.assign({},t(this,Ri,"f")),{clientJSON:t(this,Oi,"f").toJSON(),containerType:e}),t(this,Di,"f"),{logLevel:t(this,Si,"f"),env:t(this,Ci,"f")});return xe(Ye(F.COLLECT_CONTAINER_CREATED,wi),be.LOG,t(this,Si,"f")),n}case Pi.COMPOSABLE:{(e=>{if(!e)throw new Ve(Be.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Ve(Be.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Ve(Be.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Ve(Be.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Ve(Be.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Ve(Be.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Ve(Be.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Ve(Be.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(i);const n=new pi(i,Object.assign(Object.assign({},t(this,Ri,"f")),{clientJSON:t(this,Oi,"f").toJSON(),containerType:e}),t(this,Di,"f"),{logLevel:t(this,Si,"f"),env:t(this,Ci,"f")});return xe(Ye(F.COLLECT_CONTAINER_CREATED,wi),be.LOG,t(this,Si,"f")),n}default:if(!e)throw new Ve(Be.EMPTY_CONTAINER_TYPE,[],!0);throw new Ve(Be.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return Pi}static get ElementType(){return te}static get RedactionType(){return ge}static get RequestMethod(){return Se}static get LogLevel(){return De}static get EventName(){return Ce}static get Env(){return Pe}static get ValidationRuleType(){return Me}}function ki(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(xi(n)),dataAttributes:o}}function xi(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function Yi(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=ki(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=Fi());Bi(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=Vi(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Fi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Vi(e){return window[e]}function Bi(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,Oi=new WeakMap,Ai=new WeakMap,Li=new WeakMap,Ri=new WeakMap,gi=new WeakMap,Si=new WeakMap,Ci=new WeakMap;class Gi{static load(e,t){if(e===ji.PayPal){if(!t)throw new Error("PayPal config is required");return Gi.loadPayPalScript(t)}return Gi.loadScript(e)}static reset(){Gi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/fad57d9/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(Gi.scriptMap.has(t))return Gi.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(Gi.logLoadError(e,new Error(t.toString())))}}));return Gi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:t,currency:i,vault:n,intent:o}){return e(this,void 0,void 0,(function*(){try{const e=yield Yi({"client-id":t,components:"buttons,funding-eligibility",intent:o,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(e)return e}catch(e){throw Gi.logLoadError(ji.PayPal,e)}throw Gi.logLoadError(ji.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[ji.ApplePay,s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[ji.GooglePay,s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[ji.PayPal,s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new s.PayrailsError(i.get(e)||s.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return r.PayrailsLogger.error(n.message,{error:n}),n}}var ji;Gi.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"}(ji||(ji={}));class Xi extends U{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 Hi extends U{constructor(t,i){var n,o;super(t,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Xi(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,n;null===(n=null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(e,t)}))}})),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 Wi extends Hi{static isApplePayAvailable(){return e(this,void 0,void 0,(function*(){try{return yield Gi.load(ji.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 L(e,t),Wi.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(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){try{(yield Wi.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 t,i,n;return e(this,void 0,void 0,(function*(){try{const o=(null===(t=this.options.styles)||void 0===t?void 0:t.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",(()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){const t=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=t,{amount:s}=this.sdkConfig;try{const t={countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}},r=new ApplePaySession(3,t);return r.onvalidatemerchant=t=>e(this,void 0,void 0,(function*(){const{res:e}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:t.validationURL,clientDomain:this.options.clientDomain}),i=e.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=t=>e(this,void 0,void 0,(function*(){var e,i,n,o,s,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==u?void 0:u.finalState)||void 0===e?void 0:e.code))(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)&&(null===(s=this.options)||void 0===s||s.events.onAuthorizeFailed());r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(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(t){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t),{paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName}),i=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:zi,CVV:Ki,CARDHOLDER_NAME:$i,EXPIRATION_MONTH:qi,EXPIRATION_YEAR:Ji}=exports.ElementType,Zi={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},Qi=[{type:$i,placeholder:"Card holder",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:zi,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.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:qi,placeholder:"MM",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:Ji,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Ki,placeholder:"CVC",styles:Object.assign(Object.assign({},Zi),{base:Object.assign(Object.assign({},Zi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class en extends Hi{get bin(){return this.collectContainer.bin}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),Qi.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,u;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const E=new tn(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(u=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===u?void 0:u.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(E)})),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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},Zi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){return e(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 tn{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 nn extends U{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 on;!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"}(on||(on={}));const sn="https://assets.payrails.io/img/";class rn extends nn{constructor(e,t,i,n){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,rn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(e){var t;if(e.paymentMethod!==exports.PAYMENT_METHOD_CODES.CARD)return"";switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case on.AMEX:return sn+"amex.svg";case on.DINERS:return sn+"diners-club.svg";case on.DISCOVER:return sn+"discover.svg";case on.HIPERCARD:return sn+"hipercard.svg";case on.JCB:return sn+"jcb.svg";case on.MAESTRO:return sn+"maestro.svg";case on.MASTERCARD:return sn+"mastercard.svg";case on.UNIONPAY:return sn+"unionpay.svg";case on.VISA:return sn+"visa.svg"}return sn+"default.svg"}}class an extends U{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new ln((()=>{(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 ln extends U{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=rn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class dn extends U{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 cn extends U{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 un extends nn{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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw r.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 En extends un{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 Wi(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class _n extends nn{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 hn(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 hn extends U{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class In extends U{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 t,i;return e(this,void 0,void 0,(function*(){if((null===(i=null===(t=this.options)||void 0===t?void 0:t.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 pn={label:"Generic redirect"};class fn extends U{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 L(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new In({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:pn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var t,i,n,o;return e(this,void 0,void 0,(function*(){if(yield O(null!==(t=this.options.events)&&void 0!==t?t:{}))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 s.PayrailsError(s.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 s.PayrailsError(s.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 s.PayrailsError&&r.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=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};class mn extends nn{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 Nn={apiVersion:2,apiVersionMinor:0};class Tn extends Hi{static getSDKClient(t=exports.PayrailsEnvironment.TEST,i){return e(this,void 0,void 0,(function*(){return yield Gi.load(ji.GooglePay),Tn.googleSDKClient||(Tn.googleSDKClient=new google.payments.api.PaymentsClient({environment:t,merchantInfo:i})),Tn.googleSDKClient}))}static isGooglePayAvailable(t,i=exports.PayrailsEnvironment.TEST,n){return e(this,void 0,void 0,(function*(){try{const e=yield Tn.getSDKClient(i,n),o=Object.assign(Object.assign({},Nn),{allowedPaymentMethods:t}),{result:s}=yield e.isReadyToPay(o);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 L(e,t),Tn.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(t){var i,n,o,s,r,a,l,d;return e(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=t.createButton({buttonColor:c,buttonType:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&(yield this.authorize(t))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(e);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){new M(this.options,this.execution,this.paymentExecutor).handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===r||r.call(s):null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===d||d.call(l,c)}))}authorize(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},Nn),{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)||""}});t.loadPaymentData(e).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(t){super.mount(t),(()=>{e(this,void 0,void 0,(function*(){var e;try{if(yield Tn.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield Tn.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()}}Tn.googleSDKClient=null;class yn extends un{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 Tn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class On extends Hi{constructor(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,i,n,o;null===(n=null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,t),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=t,this.execution=i,this.options=n,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>e(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new An("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new L(t,i),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(this,void 0,void 0,(function*(){const e=yield Gi.load(ji.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(t){var i,n,o;return e(this,void 0,void 0,(function*(){if(!t.Buttons)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const e=t.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),e}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>e(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,i,n,o,s,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(t=this.options)||void 0===t?void 0:t.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:(t,i)=>e(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(t){var i,n,o,s,r,a,l,d,c,u;return e(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 An("No confirm link");const e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,e);"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(t){super.mount(t),(()=>{e(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 r.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class An extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Ln extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Rn extends un{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 gn extends U{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=o,this.applyStyles();void 0!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);a.set(t.identifier,t)}}));const l={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};this.execution.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&l[t]){l[t];const e=l[t]();a.set(e.identifier,e)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);a.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)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(a.values()))}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===D.REDIRECT}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new rn(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,a,l;const d=e.paymentMethodCode;if(!d){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw r.PayrailsLogger.error(t.message,{error:t}),t}return new mn(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===(a=null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o[d])||void 0===a?void 0:a.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 _n(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var e,t,i;return this.googlePay=new yn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:this.getElementEvents(),styles:Object.assign(Object.assign({},null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.googlePayButton),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new Rn(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 en(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 En(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()}})},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 k(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,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 cn({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 dn({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(e){var t,i,n,o,s,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}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 Sn={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 Cn{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 Cn(e,t,i),this.instance}createCollectElement(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw r.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 e(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return e(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 e(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(t){return e(this,void 0,void 0,(function*(){const e=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const o=yield(({url:e,token:t,body:i})=>I({url:e,token:t,method:h.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(e,t)});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(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(Sn))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"").slice(0,6)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Dn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=_().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=_(),this.scriptId=_()}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 Pn=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/fad57d9/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=Yi(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=Yi(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,yi=new WeakMap,Ri=new WeakMap,Li=new WeakMap,gi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,Di=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:t,currency:i,vault:n,intent:o}){return e(this,void 0,void 0,(function*(){try{const e=yield Fi({"client-id":t,components:"buttons,funding-eligibility",intent:o,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(e)return e}catch(e){throw ji.logLoadError(Xi.PayPal,e)}throw ji.logLoadError(Xi.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[Xi.ApplePay,s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[Xi.GooglePay,s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[Xi.PayPal,s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new s.PayrailsError(i.get(e)||s.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return r.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 k{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 k{constructor(t,i){var n,o;super(t,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:t=>e(this,void 0,void 0,(function*(){var e,n;null===(n=null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(e,t)}))}})),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 e(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 L(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(t){super.mount(t),(()=>{e(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 t,i,n;return e(this,void 0,void 0,(function*(){try{const o=(null===(t=this.options.styles)||void 0===t?void 0:t.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",(()=>e(this,void 0,void 0,(function*(){yield this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){return e(this,void 0,void 0,(function*(){const t=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=t,{amount:s}=this.sdkConfig;try{const t=new ApplePaySession(3,{countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}});t.onvalidatemerchant=i=>e(this,void 0,void 0,(function*(){const{res:e}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:i.validationURL,clientDomain:this.options.clientDomain}),n=e.data.data;t.completeMerchantValidation(n)})),t.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())},t.onpaymentauthorized=i=>e(this,void 0,void 0,(function*(){var e,n,o,s,r,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(i.payment.token);if("authorizeSuccessful"===(null===(e=null==u?void 0:u.finalState)||void 0===e?void 0:e.code))(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else t.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());t.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){t.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))}}));return(yield O(this.options.events))&&t.begin(),t}catch(e){return null}}))}onApplePayAuthorized(t){return e(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},t),{paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName}),i=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:Ki,CVV:$i,CARDHOLDER_NAME:qi,EXPIRATION_MONTH:Ji,EXPIRATION_YEAR:Zi}=exports.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(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),en.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,u;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const E=new nn(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(u=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===u?void 0:u.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(E)})),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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},Qi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){return e(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 k{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(e){var t;if(e.paymentMethod!==exports.PAYMENT_METHOD_CODES.CARD)return"";switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.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 k{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 k{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 k{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 k{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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw r.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 k{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class pn extends k{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 t,i;return e(this,void 0,void 0,(function*(){if((null===(i=null===(t=this.options)||void 0===t?void 0:t.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 fn={label:"Generic redirect"};class mn extends k{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 L(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:fn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var t,i,n,o;return e(this,void 0,void 0,(function*(){if(yield O(null!==(t=this.options.events)&&void 0!==t?t:{}))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 s.PayrailsError(s.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 s.PayrailsError(s.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 s.PayrailsError&&r.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=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};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 mn(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(t=exports.PayrailsEnvironment.TEST,i){return e(this,void 0,void 0,(function*(){return yield ji.load(Xi.GooglePay),An.googleSDKClient||(An.googleSDKClient=new google.payments.api.PaymentsClient({environment:t,merchantInfo:i})),An.googleSDKClient}))}static isGooglePayAvailable(t,i=exports.PayrailsEnvironment.TEST,n){return e(this,void 0,void 0,(function*(){try{const e=yield An.getSDKClient(i,n),o=Object.assign(Object.assign({},Tn),{allowedPaymentMethods:t}),{result:s}=yield e.isReadyToPay(o);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 L(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(t){var i,n,o,s,r,a,l,d;return e(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=t.createButton({buttonColor:c,buttonType:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>e(this,void 0,void 0,(function*(){(yield O(this.options.events))&&(yield this.authorize(t))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(e);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){new w(this.options,this.execution,this.paymentExecutor).handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===r||r.call(s):null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===d||d.call(l,c)}))}authorize(t){var i,n,o,s,r,a,l,d;return e(this,void 0,void 0,(function*(){const e=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)||""}});t.loadPaymentData(e).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(t){super.mount(t),(()=>{e(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(t,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:t=>e(this,void 0,void 0,(function*(){var e,i,n,o;null===(n=null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,t),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=t,this.execution=i,this.options=n,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>e(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new Rn("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new L(t,i),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return e(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(t){var i,n,o;return e(this,void 0,void 0,(function*(){if(!t.Buttons)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const e=t.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),e}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>e(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,i,n,o,s,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(t=this.options)||void 0===t?void 0:t.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:(t,i)=>e(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(t){var i,n,o,s,r,a,l,d,c,u;return e(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 e={};this.shouldStoreInstrument&&t.billingToken&&(e.tokenId=t.billingToken),this.fraudNetGuid&&(e.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,e);"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(t){super.mount(t),(()=>{e(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 r.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class Rn extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Ln extends s.PayrailsError{constructor(e,t){super(s.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 k{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.execution=n,this.sdkConfig=o,this.applyStyles();void 0!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);a.set(t.identifier,t)}}));const l={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};this.execution.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&l[t]){l[t];const e=l[t]();a.set(e.identifier,e)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);a.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)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(a.values()))}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===P.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,a,l;const d=e.paymentMethodCode;if(!d){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw r.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===(a=null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o[d])||void 0===a?void 0:a.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 e,t,i;return this.googlePay=new On(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:this.getElementEvents(),redirectFor3DS:this.clientConfig.redirectFor3DS,styles:Object.assign(Object.assign({},null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.googlePayButton),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.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;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else 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(e){var t,i,n,o,s,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}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(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw r.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 e(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return e(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 e(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(t){return e(this,void 0,void 0,(function*(){const e=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const o=yield(({url:e,token:t,body:i})=>I({url:e,token:t,method:h.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(e,t)});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(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(Cn))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"").slice(0,6)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Pn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=_().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=_(),this.scriptId=_()}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
|
|
25
|
+
class Mn{static init(e,t){var i,n,o,a,l,d,c,u,E,_;try{bn(),r.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:"web-sdk",version:"5.10.0"}});const s=JSON.parse(atob(e.data)),h=Boolean(s.vaultConfiguration.encryptionPublicKey);r.PayrailsLogger.setState({payrails:{execution_id:null===(o=s.execution)||void 0===o?void 0:o.id,holder_reference:s.holderReference,vault_provider:s.vaultConfiguration.vaultType,merchant_reference:null===(a=s.execution)||void 0===a?void 0:a.merchantReference,frames_type:h?"payrails":"skyflow",workflow:{code:(null===(d=null===(l=s.execution)||void 0===l?void 0:l.workflow)||void 0===d?void 0:d.code)||"",version:(null===(u=null===(c=s.execution)||void 0===c?void 0:c.workflow)||void 0===u?void 0:u.version)||0}}});const{vaultConfiguration:{vaultId:I,vaultUrl:p,token:f},execution:m}=s,v=Ui.init({vaultID:I,vaultURL:p,getBearerToken:()=>Promise.resolve(f),options:{initResponse:e,deserializedData:Object.assign(Object.assign({},s),{usePayrailsFrames:h}),logLevel:(null===(_=null===(E=null==t?void 0:t.telemetry)||void 0===E?void 0:E.logLevel)||void 0===_?void 0:_.toUpperCase())||"ERROR"}});let N;return m&&(N=new U(m),N.isPaymentMethodAvailable(exports.PAYMENT_METHOD_CODES.CARD)&&ji.preloadCardForm()),new Mn(Object.assign(Object.assign({},s),{usePayrailsFrames:h}),v,N,t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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 s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.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 yn(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 mn(this.sdkConfiguration,this.safeExecution,e),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new Pn(e,this.safeExecution,(null===(t=this.options)||void 0===t?void 0:t.environment)||exports.PayrailsEnvironment.TEST)),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}get safeExecution(){if(!this.execution){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.execution}logIntegrationMode(e){r.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,exports.PayrailsEnvironment=void 0,(wn=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",wn.PRODUCTION="PRODUCTION",exports.Payrails=Mn}();
|