PageSourceSearch

https://dinnerly.com/funnel/_next/static/chunks/cf3ac016-f68273fa4e4de068.js

js dinnerly.com collected 2026-10-01 14:01:39 UTC 290,489 bytes, 15 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[300],{5779:(e,t,i)=>{function n(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)0>t.indexOf(n[s])&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}function s(e,t,i,n){return new(i||(i=Promise))(function(s,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})}function o(e,t,i,n){if("a"===i&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw 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 r(e,t,i,n,s){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!s)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,i):s?s.value=i:t.set(e,i),i}i.d(t,{ab:()=>sl,jo:()=>e7}),"function"==typeof SuppressedError&&SuppressedError;var a,l,c,d,u,h,p,_,m,E,y,v,I,f,g,A,L,O,C,R,T,S,P,b,N,w,D,M,k,Y,U,x,j,F,B,V,X,z,G,H,W,$,q,K,Z,J,Q,ee,et,ei,en,es,eo,er,ea,el,ec,ed,eu,eh,ep,e_,em,eE,ey,ev,eI,ef,eg,eA,eL,eO,eC,eR,eT,eS,eP,eb,eN,ew,eD,eM,ek,eY,eU,ex,ej,eF,eB,eV,eX,ez,eG,eH,eW,e$,eq,eK,eZ,eJ,eQ,e0,e1,e2,e3,e4,e6,e5,e9,e8,e7,te,tt={};!function(e){let t,i;Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n=((t=n||{}).PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",t.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",t.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",t.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",t.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",t.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",t.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",t.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",t.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",t.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",t.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR="payrails:client:init.applepay_start_payment_session_error",t.PAYRAILS_CLIENT_APPLEPAY_MERCHANT_VALIDATION_FAILED="payrails:client:init.applepay_merchant_validation_failed",t.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",t.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",t.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",t.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR="payrails:client:payment_executor.payout_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",t.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",t.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",t.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",t.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",t.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",t.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",t.PAYRAILS_API_PAYOUT_ERROR="payrails:api:request_payout_error",t.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",t.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",t.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",t.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",t.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",t.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",t.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_failed",t.PAYRAILS_CLIENT_CALLBACK_FAILED="payrails:client:callback_failed",t.PAYRAILS_API_BIN_LOOKUP_FAILED="payrails:api:bin_lookup_failed",t.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",t.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",t.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",t.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",t.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",t.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",t.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_input
1s",t.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",t.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",t.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED="payrails:client:collect_container.creation.failed",t.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE="payrails:client:collect_container.empty_container_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE="payrails:client:collect_container.invalid_container_type",t.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED="payrails:client:collect_container.collect_operation_failed",t.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR="payrails:client:vault.connection_error",t.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR="payrails:client:vault.network.error",t.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME="payrails:client:collect_container.unique_element_name",t.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS="payrails:client:collect_container.invalid_tokens",t.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT="payrails:client:collect_container.empty_element",t.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER="payrails:client:collect_container.invalid_event_listener",t.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.missing_event_handler",t.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.invalid_event_handler",t.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE="payrails:client:collect_container.invalid_event_type",t.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING="payrails:client:collect_container.table_name_missing",t.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE="payrails:client:collect_container.empty_table",t.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME="payrails:client:collect_container.invalid_table_name",t.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN="payrails:client:collect_container.missing_column",t.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN="payrails:client:collect_container.empty_column",t.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN="payrails:client:collect_container.invalid_column",t.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID="payrails:client:collect_container.empty_skyflow_id",t.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID="payrails:client:collect_container.invalid_skyflow_id",t.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM="payrails:client:collect_container.mismatch_element_count_layout_sum",t.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR="payrails:client:collect_container.invalid_element_selector",t.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT="payrails:client:collect_container.duplicate_element",t.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE="payrails:client:collect_container.invalid_element_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE="payrails:client:collect_container.invalid_validations_type",t.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE="payrails:client:collect_container.missing_validation_rule_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE="payrails:client:collect_container.invalid_validation_rule_type",t.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS="payrails:client:collect_container.missing_validation_rule_params",t.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS="payrails:client:collect_container.invalid_validation_rule_params",t.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.missing_regex_in_regex_match_rule",t.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE="payrails:client:collect_container.missing_min_and_max_in_length_match_rule",t.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.missing_element_in_element_match_rule",t.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.invalid_element_in_element_match_rule",t.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.invalid_regex_in_regex_match_rule",t.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS="payrails:client:collect_container.invalid_boolean_options",t.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE="payrails:client:collect_container.missing_element_type",t.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE="payrails:client:collect_container.empty_element_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE="payrails:client:collect_container.invalid_upsert_option_type",t.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY="payrails:client:collect_container.empty_upsert_options_array",t.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE="payrails:client:collect_container.invalid_upsert_option_object_type",t.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.missing_table_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_table_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.missing_column_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_column_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.missing_composable_container_options",t.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.invalid_composable_container_options",t.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY="payrails:client:collect_container.missing_composable_layout_key",t.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE="payrails:client:collect_container.invalid_composable_layout_type",t.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY="payrails:client:collect_container.empty_composable_layout_array",t.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT="payrails:client:collect_container.negative_values_composable_layout",t.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT="payrails:client:collect_container.invalid_input_options_format",t.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION="payrails:client:collect_container.invalid_input_options_translation",t.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.records_key_missing_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_records_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_records_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_table_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_table_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_table_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_fields_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_f
1ields_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_fields_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING="payrails:client:collect_container.get_bearer_token_missing",t.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_MISSING="payrails:client:composable_container_options_missing",t.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID="payrails:client:composable_container_options_invalid",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_UNSUPPORTED_COMPONENT_TYPE="payrails:client:dynamic_element_form.unsupported_component_type",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG="payrails:client:dynamic_element_form.missing_config",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED="payrails:client:dynamic_element_form.not_mounted",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID="payrails:client:dynamic_element_form.form_invalid",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_PAYMENT_BUTTON_MISSING_WORKFLOW_CODE="payrails:client:payment_button.no_instrument_selected",t.PAYRAILS_CLIENT_CREATE_STORED_INSTRUMENT_INVALID_ELEMENT_TYPE="payrails:client:create_stored_instrument.invalid_element_type",t.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED="payrails:client:api:payout_no_instrument_selected",t);let s={"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:"Collect 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"}
1,"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:client:init.applepay_start_payment_session_error":{description:"Apple pay start payment session call failed",docUrl:"https://docs.payrails.com/"},"payrails:client:init.applepay_merchant_validation_failed":{description:"Apple pay merchant validation failed",docUrl:"https://docs.payrails.com/docs/apple-pay#pre-requisites"},"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:callback_failed":{description:"Callback passed threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:session_refresh_failed":{description:"Error occured while refreshing the session",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:bin_lookup_failed":{description:"Error occured while looking up the BIN",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.payout_error":{description:"Error occured while executing a payout",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:api:request_payout_error":{description:"Payout 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"},"payrails:client:collect_container.creation.failed":{description:"Collect container failed to initialize",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_container_type":{description:"client container - Invalid container type. Container object cannot be empty.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_container_type":{description:"client container - Invalid container type. Invalid container object",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:vault.connection_error":{description:"Vault connection error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:vault.network.error":{description:"Vault network error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.unique_element_name":{description:"client container - Element name must be unique",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_tokens":{description:"client container - Invalid tokens",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_element":{description:"client container - Element cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_listener":{description:"client container - Invalid event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_event_handler":{description:"client container - Missing handler in event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_handler":{description:"client container - Invalid handler in event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_type":{description:"client container - Invalid event type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"}
1,"payrails:client:collect_container.table_name_missing":{description:"client container - Table name missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_table":{description:"client container - Table cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_name":{description:"client container - Invalid table name",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_column":{description:"client container - Column missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_column":{description:"client container - Column cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_column":{description:"client container - Invalid column",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_skyflow_id":{description:"client container - Skyflow ID cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_skyflow_id":{description:"client container - Invalid Skyflow ID",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.mismatch_element_count_layout_sum":{description:"client container - Element count does not match layout sum",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_selector":{description:"client container - Invalid element selector",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.duplicate_element":{description:"client container - Duplicate element",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_type":{description:"client container - Invalid element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validations_type":{description:"client container - Invalid validations type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_validation_rule_type":{description:"client container - Missing validation rule type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validation_rule_type":{description:"client container - Invalid validation rule type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_validation_rule_params":{description:"client container - Missing validation rule params",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validation_rule_params":{description:"client container - Invalid validation rule params",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_regex_in_regex_match_rule":{description:"client container - Missing regex in regex match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_min_and_max_in_length_match_rule":{description:"client container - Missing min and max in length match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_element_in_element_match_rule":{description:"client container - Missing element in element match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_in_element_match_rule":{description:"client container - Invalid element in element match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_regex_in_regex_match_rule":{description:"client container - Invalid regex in regex match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_boolean_options":{description:"client container - Invalid boolean options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_element_type":{description:"client container - Missing element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_element_type":{description:"client container - EMPTY element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_upsert_option_type":{description:"client container - Invalid upsert option type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_upsert_options_array":{description:"client container - Empty upsert options array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_upsert_option_object_type":{description:"client container - Invalid upsert option object type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_table_in_upsert_option":{description:"client container - Missing table in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_in_upsert_option":{description:"client container - Invalid table in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_column_in_upsert_option":{description:"client container - Missing column in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_column_in_upsert_option":{description:"client container - Invalid column in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_composable_container_options":{description:"client container - Missing composable container options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_composable_container_options":{description:"client container - Invalid composable container options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_composable_layout_key":{description:"client container - Missing composable layout key",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_composable_layout_type":{description:"client container - Invalid composable layout type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_composable_layout_array":{description:"client container - Empty composable layout array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.negative_values_composable_layout":{description:"client container - Negative values in composable layout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_input_options_format":{de
1scription:"client container - Invalid input options format",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_input_options_translation":{description:"client container - Invalid input options translation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.records_key_missing_in_additional_fields":{description:"client container - Records key missing in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_records_in_additional_fields":{description:"client container - Invalid records in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_records_in_additional_fields":{description:"client container - Missing records in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_table_in_additional_fields":{description:"client container - Missing table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_table_in_additional_fields":{description:"client container - Empty table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_in_additional_fields":{description:"client container - Invalid table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_fields_in_additional_fields":{description:"client container - Missing fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_fields_in_additional_fields":{description:"client container - Empty fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_fields_in_additional_fields":{description:"client container - Invalid fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.get_bearer_token_missing":{description:"client container - Get bearer token missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:composable_container_options_missing":{description:"client container - Composable container options missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:composable_container_options_invalid":{description:"client container - Composable container options invalid",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.collect_operation_failed":{description:"client container - Collect operation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.unsupported_component_type":{description:"client container - Unsupported component type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.missing_config":{description:"client container - Dynamic element form missing config",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.not_mounted":{description:"client container - Dynamic element form not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.form_invalid":{description:"client container - Dynamic element form is invalid",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_button.no_instrument_selected":{description:"client container - Dynamic element payment button can only support payout workflows",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:create_stored_instrument.invalid_element_type":{description:"client container - Invalid element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api:payout_no_instrument_selected":{description:"client container - No instrument selected for payout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"}};var o=((i=o||{}).ERROR="payrails:error",i.INFO="payrails:info",i.DEBUG="payrails:debug",i.WARN="payrails:warn",i);
1class r extends Error{constructor(e,t){var i;const{description:n,docUrl:o,cause:a}=null!=t?t:{},{description:l,docUrl:c}=s[e]||{},d=null!=(i=null!=n?n:l)?i:"An unknown error occurred";super(d),this.name=e,this.docUrl=null!=o?o:c,this.cause=a,this.message=d,Error.captureStackTrace&&Error.captureStackTrace(this,r)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=n,e.PAYRAILS_OBSERVABILITY_EVENTS=o,e.PayrailsError=r}(tt);var ti={};!function(e){let t,i;var n,s,o=Object.defineProperty,r=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,d=(e,t)=>{for(var i in t||(t={}))a.call(t,i)&&c(e,i,t[i]);if(r)for(var i of r(t))l.call(t,i)&&c(e,i,t[i]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var u=((t=u||{}).PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",t.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",t.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",t.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",t.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",t.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",t.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",t.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",t.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",t.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",t.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR="payrails:client:init.applepay_start_payment_session_error",t.PAYRAILS_CLIENT_APPLEPAY_MERCHANT_VALIDATION_FAILED="payrails:client:init.applepay_merchant_validation_failed",t.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",t.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",t.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",t.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR="payrails:client:payment_executor.payout_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",t.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",t.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",t.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",t.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",t.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",t.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",t.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",t.PAYRAILS_API_PAYOUT_ERROR="payrails:api:request_payout_error",t.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",t.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",t.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",t.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",t.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",t.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",t.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_failed",t.PAYRAILS_CLIENT_CALLBACK_FAILED="payrails:client:callback_failed",t.PAYRAILS_API_BIN_LOOKUP_FAILED="payrails:api:bin_lookup_failed",t.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",t.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",t.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",t.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",t.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",t.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",t.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_input
1s",t.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",t.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",t.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED="payrails:client:collect_container.creation.failed",t.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE="payrails:client:collect_container.empty_container_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE="payrails:client:collect_container.invalid_container_type",t.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED="payrails:client:collect_container.collect_operation_failed",t.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR="payrails:client:vault.connection_error",t.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR="payrails:client:vault.network.error",t.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME="payrails:client:collect_container.unique_element_name",t.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS="payrails:client:collect_container.invalid_tokens",t.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT="payrails:client:collect_container.empty_element",t.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER="payrails:client:collect_container.invalid_event_listener",t.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.missing_event_handler",t.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.invalid_event_handler",t.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE="payrails:client:collect_container.invalid_event_type",t.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING="payrails:client:collect_container.table_name_missing",t.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE="payrails:client:collect_container.empty_table",t.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME="payrails:client:collect_container.invalid_table_name",t.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN="payrails:client:collect_container.missing_column",t.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN="payrails:client:collect_container.empty_column",t.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN="payrails:client:collect_container.invalid_column",t.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID="payrails:client:collect_container.empty_skyflow_id",t.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID="payrails:client:collect_container.invalid_skyflow_id",t.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM="payrails:client:collect_container.mismatch_element_count_layout_sum",t.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR="payrails:client:collect_container.invalid_element_selector",t.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT="payrails:client:collect_container.duplicate_element",t.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE="payrails:client:collect_container.invalid_element_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE="payrails:client:collect_container.invalid_validations_type",t.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE="payrails:client:collect_container.missing_validation_rule_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE="payrails:client:collect_container.invalid_validation_rule_type",t.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS="payrails:client:collect_container.missing_validation_rule_params",t.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS="payrails:client:collect_container.invalid_validation_rule_params",t.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.missing_regex_in_regex_match_rule",t.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE="payrails:client:collect_container.missing_min_and_max_in_length_match_rule",t.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.missing_element_in_element_match_rule",t.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.invalid_element_in_element_match_rule",t.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.invalid_regex_in_regex_match_rule",t.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS="payrails:client:collect_container.invalid_boolean_options",t.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE="payrails:client:collect_container.missing_element_type",t.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE="payrails:client:collect_container.empty_element_type",t.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE="payrails:client:collect_container.invalid_upsert_option_type",t.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY="payrails:client:collect_container.empty_upsert_options_array",t.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE="payrails:client:collect_container.invalid_upsert_option_object_type",t.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.missing_table_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_table_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.missing_column_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_column_in_upsert_option",t.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.missing_composable_container_options",t.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.invalid_composable_container_options",t.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY="payrails:client:collect_container.missing_composable_layout_key",t.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE="payrails:client:collect_container.invalid_composable_layout_type",t.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY="payrails:client:collect_container.empty_composable_layout_array",t.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT="payrails:client:collect_container.negative_values_composable_layout",t.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT="payrails:client:collect_container.invalid_input_options_format",t.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION="payrails:client:collect_container.invalid_input_options_translation",t.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.records_key_missing_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_records_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_records_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_table_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_table_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_table_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_fields_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_f
1ields_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_fields_in_additional_fields",t.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING="payrails:client:collect_container.get_bearer_token_missing",t.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_MISSING="payrails:client:composable_container_options_missing",t.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID="payrails:client:composable_container_options_invalid",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_UNSUPPORTED_COMPONENT_TYPE="payrails:client:dynamic_element_form.unsupported_component_type",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG="payrails:client:dynamic_element_form.missing_config",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED="payrails:client:dynamic_element_form.not_mounted",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID="payrails:client:dynamic_element_form.form_invalid",t.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_PAYMENT_BUTTON_MISSING_WORKFLOW_CODE="payrails:client:payment_button.no_instrument_selected",t.PAYRAILS_CLIENT_CREATE_STORED_INSTRUMENT_INVALID_ELEMENT_TYPE="payrails:client:create_stored_instrument.invalid_element_type",t.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED="payrails:client:api:payout_no_instrument_selected",t),h=((i=h||{}).ERROR="payrails:error",i.INFO="payrails:info",i.DEBUG="payrails:debug",i.WARN="payrails:warn",i);class p{log(e,t){console.group(`%c[${e}] : ${t.mssg}`,function(e){switch(e){case"error":return"color:red";case"info":return"color:blue";case"warn":return"color:orange";default:return"color:black"}}(e)),console.log(t.error),console.log("metadata",t.withMetada),console.log("extra",t.extra),console.groupEnd()}}function _(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var m,E,y,v,I,f,g,A,L,O,C,R,T,S,P={},b={},N={},w={},D={},M={},k={},Y={},U={},x={},j={},F={},B={};function V(){if(C)return B;C=1,Object.defineProperty(B,"__esModule",{value:!0}),B.Framebus=void 0;var e=J(),t="u">typeof window&&window.Promise;return B.Framebus=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=!!e.targetFrames,this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=!!(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 s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t)||(0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(t){(0,e.sendMessage)(t,o,s)}):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise(function(i,s){n.emit(e,t,function(e){i(e)})||s(Error('Listener not added for "'.concat(e,'"')))})},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=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:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.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(s=0;s<a.length;
1s++)if(a[s]===n)return a.splice(s,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){return!this.limitBroadcastToFramesArray||!!this.targetFramesAsWindows().find(function(t){return t===e})},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}(),B}var X,z,G,H,W,$,q={},K={},Z={};function J(){var e,t;return H||(H=1,e=P&&P.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),t=P&&P.__exportStar||function(t,i){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||e(i,t,n)},Object.defineProperty(P,"__esModule",{value:!0}),t(function(){if(m)return b;m=1,Object.defineProperty(b,"__esModule",{value:!0}),b.detach=b.attach=void 0;var e=J(),t=!1;return b.attach=function(){t||"u"<typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},b.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},b}(),P),t(function(){if(E)return N;E=1,Object.defineProperty(N,"__esModule",{value:!0}),N.broadcastToChildWindows=void 0;var e=J();return N.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},N}(),P),t(function(){if(y)return w;y=1,Object.defineProperty(w,"__esModule",{value:!0}),w.broadcast=void 0;var e=J();return w.broadcast=function t(i,n){var s,o=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});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},w}(),P),t((v||(v=1,Object.defineProperty(D,"__esModule",{value:!0}),D.subscribers=D.childWindows=D.prefix=void 0,D.prefix="/*framebus*/",D.childWindows=[],D.subscribers={}),D),P),t(function(){if(I)return M;I=1,Object.defineProperty(M,"__esModule",{value:!0}),M.dispatch=void 0;var e=J();return M.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},M}(),P),t((f||(f=1,Object.defineProperty(k,"__esModule",{value:!0}),k.hasOpener=void 0,k.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),k),P),t((g||(g=1,Object.defineProperty(Y,"__esModule",{value:!0}),Y.isntString=void 0,Y.isntString=function(e){return"string"!=typeof e}),Y),P),t(function(){if(A)return U;A=1,Object.defineProperty(U,"__esModule",{value:!0}),U.onMessage=void 0;var e=J();return U.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},U}(),P),t(function(){if(L)return x;L=1,Object.defineProperty(x,"__esModule",{value:!0}),x.packagePayload=void 0;var e=J();return x.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw Error("Could not stringify event: ".concat(e.message))}return o},x}(),P),t((O||(O=1,Object.defineProperty(j,"__esModule",{value:!0}),j.sendMessage=void 0,j.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),j),P),t(function(){if(S)return F;S=1;
1var e=F&&F.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(F,"__esModule",{value:!0}),F.subscribeReplier=void 0;var t=V(),i=e((T||(T=1,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)})}),R));return F.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)}),s},F}(),P),t(function(){if(X)return q;X=1,Object.defineProperty(q,"__esModule",{value:!0}),q.subscriptionArgsInvalid=void 0;var e=J();return q.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},q}(),P),t((z||(z=1,Object.defineProperty(K,"__esModule",{value:!0})),K),P),t(function(){if(G)return Z;G=1,Object.defineProperty(Z,"__esModule",{value:!0}),Z.unpackPayload=void 0;var e=J();return Z.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,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},Z}(),P)),P}let Q=_(function(){if($)return W;$=1;var e=J(),t=V();return(0,e.attach)(),W=t.Framebus}());class ee{constructor(e){this.origin=null,this.onAndEmit=(e,t,i="*")=>{this.bus.on(`${e}-REQ`,n=>{var s,o;return s=this,o=function*(){let s=yield t(n);this.bus.target({origin:i}).emit(`${e}-RES`,s)},new Promise((e,t)=>{var i=e=>{try{r(o.next(e))}catch(e){t(e)}},n=e=>{try{r(o.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);r((o=o.apply(s,null)).next())})})},this.emitAndResolve=(e,t,i="*")=>new Promise((n,s)=>{this.bus.on(`${e}-RES`,e=>{n(e)}),this.bus.target({origin:i}).emit(`${e}-REQ`,d({},t))}),this.listeners=[],this.bus=new Q(e)}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class et{constructor(){this.bus=ee.getInstance()}log(e,t){this.bus.emit(h.ERROR,{level:e,event:t})}}let ei=_(function(){if(s)return n;s=1;var e=function(e){var i;return!!e&&"object"==typeof e&&"[object RegExp]"!==(i=Object.prototype.toString.call(e))&&"[object Date]"!==i&&e.$$typeof!==t},t="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?l(Array.isArray(e)?[]:{},e,t):e}function o(e,t,n){return e.concat(t).map(function(e){return i(e,n)})}function r(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function a(e,t){try{return t in e}catch(e){return!1}}function l(t,n,s){(s=s||{}).arrayMerge=s.arrayMerge||o,s.isMergeableObject=s.isMergeableObject||e,s.cloneUnlessOtherwiseSpecified=i;var c,d,u=Array.isArray(n);return u===Array.isArray(t)?u?s.arrayMerge(t,n,s):(d={},(c=s).isMergeableObject(t)&&r(t).forEach(function(e){d[e]=i(t[e],c)}),r(n).forEach(function(e){a(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))||(a(t,e)&&c.isMergeableObject(n[e])?d[e]=(function(e,t){if(!t.customMerge)return l;var i=t.customMerge(e);return"function"==typeof i?i:l})(e,c)(t[e],n[e],c):d[e]=i(n[e],c))}),d):i(n,s)}return l.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,i){return l(e,i,t)},{})},n=l}());class en{constructor(){this.state={}}static getInstance(){return en.instance||(en.instance=new en),en.instance}getState(e){return this.state[e]}setState(e){this.state=ei(this.state,e)}}let es=en.getInstance(),eo=()=>({resolution:`${(window&&window.screen).width}x${(window&&window.screen).height}`,user_agent:(window&&window.navigator).userAgent,language:(window&&window.navigator).language}),er=[u.PAYRAILS_API_AUTHORIZATION_ERROR,u.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR,u.PAYRAILS_API_UNSUCCESSFUL];class ea{constructor(e){this.adapter=[new et],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new p)}static init(e){ea.instance=new ea(e)}static getLogger(){return ea.instance}initGlobalState(e){es.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){es.setState(e)}log(e,t,i){var n;this.enabled&&-1===er.indexOf(null==(n=null==i?void 0:i.error)?void 0:n.name)&&this.adapter.forEach(n=>
1{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:d(d({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})})}constructMetadata(){return{device:eo(),payrails:es.getState("payrails"),sdk:es.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=ea,e.getDeviceInfo=eo}(ti);let tn="%s1 - Creating Collect container.",ts="%s1 - Created Collect container successfully.",to="%s1 - Data has been collected successfully.",tr="%s1 - %s2 event emitted",ta="Interface: init - Invalid token is generated from getBearerToken callback",tl="collect_controller",tc="element",td={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},tu="FRAME_READY",th="TOKENIZATION_REQUEST",tp="RESET",t_="INPUT_EVENT",tm="SET_VALUE",tE="SET_ATTRIBUTE",ty="COLLECT_ELEMENT_SET_ERROR",tv="COMPOSABLE_UPDATE_OPTIONS",tI="VALIDATE_ELEMENT",tf="COMPOSABLE_CONTAINER_MOUNTED",tg="COLLECT_CONTAINER_MOUNTED";(tk=tx||(tx={})).CVV="CVV",tk.EXPIRATION_DATE="EXPIRATION_DATE",tk.CARD_NUMBER="CARD_NUMBER",tk.CARDHOLDER_NAME="CARDHOLDER_NAME",tk.INPUT_FIELD="INPUT_FIELD",tk.PIN="PIN",tk.EXPIRATION_MONTH="EXPIRATION_MONTH",tk.EXPIRATION_YEAR="EXPIRATION_YEAR",(tY=tj||(tj={})).VISA="VISA",tY.MASTERCARD="MASTERCARD",tY.AMEX="AMEX",tY.DINERS_CLUB="DINERS_CLUB",tY.DISCOVER="DISCOVER",tY.JCB="JCB",tY.MAESTRO="MAESTRO",tY.UNIONPAY="UNIONPAY",tY.HIPERCARD="HIPERCARD",tY.DEFAULT="DEFAULT",tY.CVV="CVV",tY.EXPIRY="EXPIRY",tY.ERROR="ERROR",tY.UNKNOWN="UNKNOWN",tY.ELO="ELO";let tA={[tj.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[tj.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[tj.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[tj.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[tj.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[tj.ELO]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}]},tL={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},[tx.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[tx.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:tA[tj.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[tx.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[tx.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[tx.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[tx.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[tx.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[tx.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},tO={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},tC={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},tR={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},tT={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},tS={[tj.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[tj.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[tj.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[tj.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[tj.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[tj.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[tj.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[tj.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[tj.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]},[tj.ELO]:{regex:/^(?:40117[89]|431274|438935|451416|457393|45763[12]|504175|506(699|7[0-6]\d|77[0-8])|509\d{3}|627780|636(297|368)|650(0(3[1-3]|3[5-9]|4\d|5[01])|4(0[5-9]|[12]\d|3\d)|(4(8[5-9]|9\d)|5([0-2]\d|3[0-8]))|5(4[1-9]|[5-8]\d|9[0-8])|7(0\d|1[0-8]|2[0-7])|9(0[1-9]|[1-6]\d|7[0-8]))|6516(5[2-9]|[67]\d)|6550([01]\d|2[1-9]|[34]\d|5[0-8]))\d*/,maxCardLength:16,cardLengthRange:[16]}};tj.DEFAULT,tj.CVV,tj.EXPIRY,tj.ERROR,tj.AMEX,tj.DINERS_CLUB,tj.DISCOVER,tj.HIPERCARD,tj.JCB,tj.MAESTRO,tj.MASTERCARD,tj.UNIONPAY,tj.VISA,tj.ELO;let tP="MM/YY",tb=[tP,"YYYY/MM","YY/MM","MM/YYYY"],tN=["YY","YYYY"];(tU=tF||(tF={})).APPLICATIONORJSON="application/json",tU.TEXTORPLAIN="text/plain",tU.TEXTORXML="text/xml",tU.FORMURLENCODED="application/x-www-form-urlencoded",tU.FORMDATA="multipart/form-data",tx.CARD_NUMBER,tx.EXPIRATION_DATE,tx.EXPIRATION_MONTH,tx.EXPIRATION_YEAR,tx.CVV,tx.EXPIRATION_DATE,tx.CARD_NUMBER,tx.CARDHOLDER_NAME,tx.INPUT_FIELD,tx.PIN,tx.EXPIRATION_MONTH,tx.EXPIRATION_YEAR,tx.CVV,tx.EXPIRATION_DATE,tx.CARD_NUMBER,tx.CARDHOLDER_NAME,tx.INPUT_FIELD,tx.PIN,tx.EXPIRATION_MONTH,tx.EXPIRATION_YEAR;let tw=[tx.CARDHOLDER_NAME,tx.EXPIRATION_MONTH,tx.PIN,tx.CVV],tD={X:"[0-9]"},tM={visa:tS.VISA.regex,mastercard:tS.MASTERCARD.regex,amex:tS.AMEX.regex,diners_club:tS.DINERS_CLUB.regex,discover:tS.DISCOVER.regex,jcb:tS.JCB.regex,hipercard:tS.HIPERCARD.regex,unionpay:tS.UNIONPAY.regex,maestro:tS.MAESTRO.regex,elo:tS.ELO.regex};for(var tk,tY,tU,tx,tj,tF,tB,tV=[],tX=0;tX<256;++tX)tV.push((tX+256).toString(16).slice(1));var tz=new Uint8Array(16),tG={randomUUID:"u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function tH(e,t,i){if(tG.randomUUID&&!e)return tG.randomUUID();var n=(e=e||{}).random||(e.rng||function(){if(!tB&&!(tB="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return tB(tz)})();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return(tV[e[t+0]]+tV[e[t+1]]+tV[e[t+2]]+tV[e[t+3]]+"-"+tV[e[t+4]]+tV[e[t+5]]+"-"+tV[e[t+6]]+tV[e[t+7]]+"-"+tV[e[t+8]]+tV[e[t+9]]+"-"+tV[e[t+10]]+tV[e[t+11]]+tV[e[t+12]]+tV[e[t+13]]+tV[e[t+14]]+tV[e[t+15]]).toLowerCase()}(n)}(a=P||(P={})).GET="GET",a.POST="POST",a.DELETE="DELETE",a.PATCH="PATCH";let tW=e=>s(void 0,[e],void 0,function*({url:e,method:t=P.GET,token:i="",body:n}){let s={method:t,headers:Object.assign(Object.assign(Object.assign({},tQ()),tJ(i)),t0())};t!==P.POST&&t!==P.PATCH||(s.body=JSON.stringify(n||{}));let o=yield fetch(e,s);if([401,403].includes(o.status))throw new t$(e,t);if(429===o.status)throw new tK(e,t);if(!o.ok)throw new tq(e,t);let r=yield o.json();return{ok:o.ok,req:Object.assign({url:e},s),res:r}});class t$ extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let tq=class extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},tK=class extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class tZ extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}let tJ=e=>({authorization:`Bearer ${e}`}),tQ=()=>({"x-idempotency-key":tH()}),t0=()=>({"x-client-version":"5.44.1","x-client-type":"web-sdk"}),t1=({url:e,token:t,body:i})=>tW({url:e,token:t,method:P.POST,body:i});function t2(...e){return e.reduce((e,t)=>
1(function e(t,i){if(void 0===i)return t;if("object"!=typeof t||null===t||"object"!=typeof i||null===i||Array.isArray(i)||Array.isArray(t))return i;let n=Object.assign({},t);for(let s of Object.keys(i))void 0!==i[s]&&(i[s]&&"object"==typeof i[s]&&!Array.isArray(i[s])&&t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])?n[s]=e(t[s],i[s]):n[s]=i[s]);return n})(e,t),{})}(l=b||(b={})).CARD="card",l.GOOGLE_PAY="googlePay",l.PAYPAL="payPal",l.APPLE_PAY="applePay",l.GENERIC_REDIRECT="genericRedirect",l.LEAN="lean",l.MERCADO_PAGO="mercadoPago",l.PIX="pix",l.BANK_ACCOUNT="bankAccount",l.IDEAL="iDeal",l.YAPE="yape",l.UPI="upi",l.KLARNA="klarna",l.ONE_VOUCHER="1voucher",l.ALFA="alfa",l.APLAZO="aplazo",l.BANK_TRANSFER="bankTransfer",l.CAPITEC_PAY="capitecPay",l.EASYPAISA="easypaisa",l.EFT_PRO="eftPro",l.FAWRY_PAY="fawryPay",l.JAZZ_CASH="jazzCash",l.KONNECT="konnect",l.KUESKI="kueski",l.MONO_DIRECT_DEBIT="monoDirectDebit",l.O_PAY_WALLET="oPayWallet",l.PAGA_WALLET="pagaWallet",l.PAYFLEX="payflex",l.PAY_JUST_NOW="payjustnow",l.WAFA_CASH_WALLET="wafaCashWallet",l.MERCADO_PAGO_WALLET="mercadoPagoWallet",l.MERCADO_PAGO_CONSUMER_CREDIT="mercadoPagoConsumerCredit",l.NET_BANKING="netBanking",l.CASH_FREE_WALLET="cashFreeWallet",l.PAYTM_WALLET="paytmWallet",l.NIBSS_PAY="nibssPay",l.NIBSS_INSTANT_PAY="nibssInstantPay",l.MEEZA_WALLET="meezaWallet",l.VODAFONE_CASH="vodafoneCash",l.SEPA_DIRECT_DEBIT="sepaDirectDebit",l.MODO="modo",l.PAYZONE_CASH="payzoneCash",l.REVOLUT_PAY="revolutPay",Object.fromEntries(Object.entries(b).map(([e,t])=>[e,t])),(c=N||(N={})).ENABLED="enabled",c.CREATED="created",c.DELETED="deleted",c.DISABLED="disabled",c.INVALID="invalid",c.TRANSIENT="transient";let t3=["customer"];class t4{static get response(){if(!t4._response){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw ti.PayrailsLogger.error(e.message,{error:e}),e}return t4._response}static setResponse(e){return t4._response=e,t4._updatedMetaKeys=new Set,t4}static get workflowCode(){return t4.response.workflow.code}static get lookup(){return t4.response.initialResults.find(({body:{name:e}})=>"lookup"===e)}static get holderReference(){return t4.response.holderReference}static get savedCreditCards(){return t4.getStoredInstrumentForPaymentMethod(b.CARD)}static get savedPaypalAccounts(){return t4.getStoredInstrumentForPaymentMethod(b.PAYPAL).filter(({status:e})=>e===N.ENABLED)}static get savedGooglePayAccounts(){return t4.getStoredInstrumentForPaymentMethod(b.GOOGLE_PAY).filter(({status:e})=>e===N.ENABLED)}static get savedApplePayAccounts(){return t4.getStoredInstrumentForPaymentMethod(b.APPLE_PAY)}static get paypalConfig(){let e=t4.availablePaymentMethods.find(({paymentMethodCode:e})=>e===b.PAYPAL);if(!e){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw ti.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:t4.availablePaymentMethods}}),e}return e.config||{}}static get googlePayConfig(){var e;let t=t4.availablePaymentMethods.find(({paymentMethodCode:e})=>e===b.GOOGLE_PAY);if(!t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw ti.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:t4.availablePaymentMethods}}),e}return(null==(e=t.clientConfig)?void 0:e.additionalConfig)&&void 0!==t.clientConfig.additionalConfig.apiVersion?t.clientConfig.additionalConfig:[t.config]}static isPaymentMethodAvailable(e){return t4.availablePaymentMethods.some(({paymentMethodCode:t})=>t===e)}static get applePayConfig(){let e=t4.availablePaymentMethods.find(({paymentMethodCode:e})=>e===b.APPLE_PAY);if(!e){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw ti.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:t4.availablePaymentMethods}}),e}return e.config.parameters}static get url(){return t4.response.links.self}static get meta(){return t4.response.meta}static get availablePaymentMethods(){var e;return(null==(e=t4.lookup)?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e,t;return null==(t=null==(e=t4.lookup)?void 0:e.body.links.authorize)?void 0:t.href}static get payoutLink(){var e,t;return null==(t=null==(e=t4.lookup)?void 0:e.body.links.payout)?void 0:t.href}static get createSessionLink(){var e;return null==(e=t4.response.links.startPaymentSession)?void 0:e.href}static get createInstrumentLink(){var e;return null==(e=t4.response.links.createInstrument)?void 0:e.href}static get storedPaymentInstruments(){return t4.availablePaymentMethods.flatMap(e=>e.paymentInstruments||[]).filter(({paymentMethod:e,status:t})=>{let i=[b.GOOGLE_PAY,b.PAYPAL];return t===N.ENABLED||!i.includes(e)})}static get storedDropinInstruments(){return t4.storedPaymentInstruments.filter(({paymentMethod:e})=>![b.GOOGLE_PAY,b.APPLE_PAY].includes(e))}static getFullPaymentMethodConfig(e){return t4.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)}static isAddressSelectorEnabled(e){var t,i;return!!t4._response&&(null==(i=null==(t=t4.getFullPaymentMethodConfig(e))?void 0:t.clientConfig)?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(t4._response){let i=this.getFullPaymentMethodConfig(e);return i&&(null==(t=this.getPaymentMethodConfig(i).clientConfig)?void 0:t.supportsInstallments)}return!1}static getPaymentInstallmentOptions(e){var t;let i=this.getFullPaymentMethodConfig(e);return i&&(null==(t=this.getPaymentMethodConfig(i).clientConfig)?void 0:t.installments)||{}}static getStoredInstrumentForPaymentMethod(e){var t;return(null==(t=this.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e))?void 0:t.paymentInstruments)||[]}static getPaymentMethodForStoredInstrument(e){let t=this.availablePaymentMethods.find(({paymentInstruments:t})=>null==t?void 0:t.some(({id:t})=>t===e.id));return t&&this.getPaymentMethodConfig(t)}static getPaymentMethodConfig(e){let{paymentInstruments:t}=e;return n(e,["paymentInstruments"])}static updateInstallmentOptions(e){let t=t4.getFullPaymentMethodConfig(b.CARD);(null==t?void 0:t.clientConfig)&&(t.clientConfig.installments=e)}static updateMeta(e,t){if(!t3.includes(e))return;let i=t4.response.meta||{},n=t2(i[e]||{},t);t4._response=Object.assign(Object.assign({},t4.response),{meta:Object.assign(Object.assign({},i),{[e]:n})}),t4._updatedMetaKeys.add(e)}static getAllowedMeta(){let e=t4.response.meta||{};return t4.pickMetaByKeys(e,t3)}static getUpdatedMeta(){let e=t4.response.meta||{};return t4.pickMetaByKeys(e,t4._updatedMetaKeys)}static pickMetaByKeys(e,t){let i={};for(let n of t){let t=e[n];void 0!==t&&(i[n]=t)}return i}}t4._updatedMetaKeys=new Set,(d=w||(w={})).REDIRECT="redirect",d.DIRECT="direct",d.EMBEDDED="embedded",(u=D||(D={})).API="api",u.HPP="hpp";class t6{constructor(){this._config=void 0}static getInstance(){return t6._instance||(t6._instance=new t6),t6._instance}set config(e){try{t6.getInstance()._config=e}catch(e){ti.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return t6.getInstance()._config||ti.PayrailsLogger.error("SDK Configuration not set"),t6.getInstance()._config||{}}}let t5=e=>{try{var t;let i,n=JSON.parse((t=e.data,i=window.atob(t),decodeURIComponent(Array.prototype.map.call(i,e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))));t6.getInstance().config=n,n.execution&&t4.setResponse(n.execution)}catch(e){ti.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}};(h=M||(M={})).CARD_NUMBER="CARD_NUMBER",h.CARDHOLDER_NAME="CARDHOLDER_NAME",h.CVV="CVV",h.EXPIRATION_MONTH="EXPIRATION_MONTH",h.EXPIRATION_YEAR="EXPIRATION_YEAR",h.EXPIRATION_DATE="EXPIRATION_DATE";class t9{constructor(e,t){var i;this.bin="",this.isBinLookupEnabled=!1,this.id="payrails-container-wrapper",this.dataTestId="payrails-container-wrapper",this.className="payrails-container-wrapper",this.containerType="COMPOSABLE",this.manualErrorElements=new Set,this.fetchBinLookup=e=>s(this,void 0,void 0,function*(){var t,i;if(!e)return{bin:""};if(e.length<6)return{bin:e};let n=`${null==(i=null==(t=t6.getInstance().config.links)?void 0:t.binLookup)?void 0:i.href}`;if(!n)return{bin:e};let s=t6.getInstance().config.token;try{return(yield(({url:e,token:t,body:i})=>tW({url:e,method:P.POST,token:t,body:i}))({url:n,token:s,body:{bin:e}})).res}
1catch(i){let t=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_BIN_LOOKUP_FAILED,{description:"Error fetching BIN lookup data!",cause:i});return ti.PayrailsLogger.error(t.message,{error:t}),{bin:e}}}),this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null==(i=t6.getInstance().config.links)?void 0:i.binLookup);try{this.__container=e.container(this.containerType,t)}catch(t){const e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:t});ti.PayrailsLogger.error(e.message,{error:e})}}static init(e,t){var i;return this.instance&&(null==(i=this.instance.__container)||i.unmount()),this.instance=new t9(e,t),this.instance}createCollectElement(e){var t;let i={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},n=null==(t=this.__container)?void 0:t.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===M.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},i),{format:e.format}):i);if(!n){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw ti.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw ti.PayrailsLogger.error(e.message,{error:e}),e}this.element=document.createElement("span"),this.element.setAttribute("id",`${this.id}`),this.element.setAttribute("data-testid",this.dataTestId),this.element.setAttribute("class",this.className);let t=document.querySelector(e);if(!t){let t=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw ti.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element);try{window.setTimeout(()=>{this.__container.mount(`#${this.id}`)},50)}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);ti.PayrailsLogger.error(e.message,{error:e})}}unmount(){this.element&&this.element.remove()}validate(){return s(this,void 0,void 0,function*(){var e;return yield null==(e=this.__container)?void 0:e.validate()})}collect(){return s(this,void 0,void 0,function*(){try{return yield this.collectPayrailsData()}catch(i){let e=Error(i.message);e.stack=i.stack,e.name=i.name,e.message=i.message;let t=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:e});throw e.name!==tt.ERROR_CODES.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS&&ti.PayrailsLogger.error(t.message,{error:t}),t}})}reset(){var e;null==(e=this.__container)||e.reset()}collectPayrailsData(){return s(this,void 0,void 0,function*(){var e;return Object.assign(Object.assign({},(yield null==(e=this.__container)?void 0:e.collect())),{vaultProviderConfigId:t6.getInstance().config.vaultConfiguration.providerConfigId})})}tokenize(e){return s(this,void 0,void 0,function*(){let t=yield this.collect(),i=t6.getInstance().config.vaultConfiguration.links.saveInstrument.href,n=t6.getInstance().config.token;if(!i){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw ti.PayrailsLogger.error(e.message,{error:e}),e}return(yield t1({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)})).res})}constructSaveInstrumentBody(e,t){var i,n;let s={holderReference:t6.getInstance().config.holderReference,paymentMethod:"card",storeInstrument:null!=(i=null==t?void 0:t.storeInstrument)&&i,futureUsage:null!=(n=null==t?void 0:t.futureUsage)?n:"CardOnFile"};return s.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId},s}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{let i=e[t];return"on"===t?((i,n)=>{e[t].call(e,i,t=>{"CHANGE"===i&&(this.manualErrorElements.has(e)&&!t.isEmpty&&("resetError"in e&&"function"==typeof e.resetError&&e.resetError(),this.manualErrorElements.delete(e)),t.elementType===M.CARD_NUMBER&&(t.network=function(e){for(let[t,i]of Object.entries(tM))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value))),n(t)})}).bind(e):"setError"===t?(...t)=>(this.manualErrorElements.add(e),i.apply(e,t)):"function"==typeof i?i.bind(e):i}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[M.CARD_NUMBER,"card_number"],[M.CARDHOLDER_NAME,"cardholder_name"],[M.CVV,"security_code"],[M.EXPIRATION_MONTH,"expiry_month"],[M.EXPIRATION_YEAR,"expiry_year"],[M.EXPIRATION_DATE,"expiry_date"]]
1)}}var t8={};!function(e){let t,i;var n,s=Object.defineProperty,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,l=(e,t,i)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var c,d,u,h,p,_,m,E,y,v,I,f,g,A,L=((t=L||{}).COLLECT="COLLECT",t.TOKENIZE="TOKENIZE",t.READY="READY",t.SHOW="SHOW",t.CHANGE="CHANGE",t.FOCUS="FOCUS",t.BLUR="BLUR",t.ERROR="ERROR",t.FOCUS_ELEMENT="FOCUS_ELEMENT",t.SET_ERROR="SET_ERROR",t.UPDATE="UPDATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.VALIDATE="VALIDATE",t.RESET="RESET",t.SUBMIT="SUBMIT",t),O=((i=O||{}).CardNumber="CARD_NUMBER",i.ExpiryYear="EXPIRATION_YEAR",i.ExpiryMonth="EXPIRATION_MONTH",i.ExpiryDate="EXPIRATION_DATE",i.SecurityCode="CVV",i.CardHolderName="CARDHOLDER_NAME",i),C={},R={},T={},S={},P={},b={},N={},w={},D={},M={},k={},Y={},U={};function x(){if(I)return U;I=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Framebus=void 0;var e=$(),t="u">typeof window&&window.Promise;return U.Framebus=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=!!e.targetFrames,this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=!!(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 s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t)||(0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(t){(0,e.sendMessage)(t,o,s)}):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise(function(i,s){n.emit(e,t,function(e){i(e)})||s(Error('Listener not added for "'.concat(e,'"')))})},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=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:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.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(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,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){return!this.limitBroadcastToFramesArray||!!this.targetFramesAsWindows().find(function(t){return t===e})},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}(),U}var j,F,B,V,X,z,G={},H={},W={};function $(){var e,t;return V||(V=1,e=C&&C.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);
1s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),t=C&&C.__exportStar||function(t,i){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||e(i,t,n)},Object.defineProperty(C,"__esModule",{value:!0}),t(function(){if(c)return R;c=1,Object.defineProperty(R,"__esModule",{value:!0}),R.detach=R.attach=void 0;var e=$(),t=!1;return R.attach=function(){t||"u"<typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},R.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},R}(),C),t(function(){if(d)return T;d=1,Object.defineProperty(T,"__esModule",{value:!0}),T.broadcastToChildWindows=void 0;var e=$();return T.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},T}(),C),t(function(){if(u)return S;u=1,Object.defineProperty(S,"__esModule",{value:!0}),S.broadcast=void 0;var e=$();return S.broadcast=function t(i,n){var s,o=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});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},S}(),C),t((h||(h=1,Object.defineProperty(P,"__esModule",{value:!0}),P.subscribers=P.childWindows=P.prefix=void 0,P.prefix="/*framebus*/",P.childWindows=[],P.subscribers={}),P),C),t(function(){if(p)return b;p=1,Object.defineProperty(b,"__esModule",{value:!0}),b.dispatch=void 0;var e=$();return b.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},b}(),C),t((_||(_=1,Object.defineProperty(N,"__esModule",{value:!0}),N.hasOpener=void 0,N.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),N),C),t((m||(m=1,Object.defineProperty(w,"__esModule",{value:!0}),w.isntString=void 0,w.isntString=function(e){return"string"!=typeof e}),w),C),t(function(){if(E)return D;E=1,Object.defineProperty(D,"__esModule",{value:!0}),D.onMessage=void 0;var e=$();return D.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},D}(),C),t(function(){if(y)return M;y=1,Object.defineProperty(M,"__esModule",{value:!0}),M.packagePayload=void 0;var e=$();return M.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw Error("Could not stringify event: ".concat(e.message))}return o},M}(),C),t((v||(v=1,Object.defineProperty(k,"__esModule",{value:!0}),k.sendMessage=void 0,k.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),k),C),t(function(){if(A)return Y;A=1;var e=Y&&Y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribeReplier=void 0;var t=x(),i=e((g||(g=1,f=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)})}),f));return Y.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)}),s},Y}(),C),t(function(){if(j)return G;j=1,Object.defineProperty(G,"__esModule",{value:!0}),G.subscriptionArgsInvalid=void 0;var e=$();return G.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},G}(),C),t((F||(F=1,Object.defineProperty(H,"__esModule",{value:!0})),H),C),t(function(){if(B)return W;B=1,Object.defineProperty(W,"__esModule",{value:!0}),W.unpackPayload=void 0;var e=$();return W.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,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},W}(),C)),C}let q=(n=function(){if(z)return X;z=1;
1var e=$(),t=x();return(0,e.attach)(),X=t.Framebus}())&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;class K{constructor(e){this.origin=null,this.onAndEmit=(e,t,i="*")=>{this.bus.on(`${e}-REQ`,n=>{var s,o;return s=this,o=function*(){let s=yield t(n);this.bus.target({origin:i}).emit(`${e}-RES`,s)},new Promise((e,t)=>{var i=e=>{try{r(o.next(e))}catch(e){t(e)}},n=e=>{try{r(o.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);r((o=o.apply(s,null)).next())})})},this.emitAndResolve=(e,t,i="*")=>new Promise((n,s)=>{this.bus.on(`${e}-RES`,e=>{n(e)}),this.bus.target({origin:i}).emit(`${e}-REQ`,((e,t)=>{for(var i in t||(t={}))r.call(t,i)&&l(e,i,t[i]);if(o)for(var i of o(t))a.call(t,i)&&l(e,i,t[i]);return e})({},t))}),this.listeners=[],this.bus=new q(e)}static getInstance(){return K.instance||(K.instance=new K),K.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.COLLECT_FRAME_EVENT_NAMES=L,e.CollectElementType=O,e.IframeEventBus=K,e.getEventBus=()=>K.getInstance()}(t8);class t7{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){let i=this.events[e];if(!i)return;let n=i.findIndex(e=>e.callback===t);i.splice(n,1)}_emit(e,...t){let i=this.events[e];i&&i.forEach(e=>{e.callback(...t)})}hasListener(e){let t=this.events[e];return!!t&&t.length>0}resetEvents(){let e={};Object.keys(this.events).forEach(t=>{let i=this.events[t];if(i&&i.length>0){let n=[];i.forEach(e=>{e.priority&&n.push(e)}),e[t]=n}}),this.events=e}static createChild(e){e.prototype=Object.create(t7.prototype,{constructor:e})}}let ie={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},it={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},ii=(e,t)=>{Object.keys(t).forEach(i=>{if(Object.prototype.hasOwnProperty.call(t,i)){let n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}})};var is=(e={})=>{let t=document.createElement("iframe"),i=Object.assign(Object.assign({},it),e);return Object.assign(t.style,tO),ii(t,i),t.getAttribute("id")||(t.id=t.name),t};let io=(e,t)=>{Object.keys(t).forEach(i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])})};function ir(e){return JSON.parse(JSON.stringify(e))}(p=k||(k={})).DEFAULT="DEFAULT",p.PLAIN_TEXT="PLAIN_TEXT",p.MASKED="MASKED",p.REDACTED="REDACTED",(_=Y||(Y={})).GET="GET",_.POST="POST",_.PUT="PUT",_.PATCH="PATCH",_.DELETE="DELETE",(m=U||(U={})).CHANGE="CHANGE",m.READY="READY",m.FOCUS="FOCUS",m.BLUR="BLUR",m.SUBMIT="SUBMIT",(E=x||(x={})).WARN="WARN",E.INFO="INFO",E.DEBUG="DEBUG",E.ERROR="ERROR",(y=j||(j={})).DEV="DEV",y.PROD="PROD",(v=F||(F={})).LOG="LOG",v.WARN="WARN",v.ERROR="ERROR",(I=B||(B={})).REGEX_MATCH_RULE="REGEX_MATCH_RULE",I.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",I.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE";let ia={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}},il={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},ic="[Skyflow]",id=(e,t,i)=>{if(i&&ia[i]){let{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=ia[i];t===F.LOG&&n?console.log(`${x.DEBUG}: ${ic} ${e}`):t===F.LOG&&s?console.log(`${x.INFO}: ${ic} ${e}`):t===F.WARN&&o?console.warn(`${x.WARN}: ${ic} ${e}`):t===F.ERROR&&r&&console.error(`${x.ERROR}: ${ic} ${e}`)}},iu=(...e)=>{let t=e[0],i=e.filter((e,t)=>0!==t);return t?t.replace(/%s[0-9]+/g,e=>i[e.replace("%s","")-1]):""},ih=(e="")=>{let 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},ip=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new tt.PayrailsError(tt.ER
1ROR_CODES.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS);let{records:t}=e;if(!t||!Array.isArray(t))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS);if(0===t.length)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS);t.forEach((e,t)=>{var i,n,s,o;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS);if(!e.table)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS);if(void 0!==(null==(i=e.fields)?void 0:i.skyflowID)){if(!(null==(n=e.fields)?void 0:n.skyflowID))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID);if(!("string"==typeof(null==(s=e.fields)?void 0:s.skyflowID)||(null==(o=e.fields)?void 0:o.skyflowID)instanceof String))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)}if(!("string"==typeof e.table||e.table instanceof String))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS);if(!e.fields)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS)})},i_=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},im=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},iE=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE);if(!e.type)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(e,"altText")&&id("altText is DEPERECATED, passing altText will not have any effect",F.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)},iy=e=>{if(!e||!Array.isArray(e))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE);if(!e.length)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY);e.forEach((e,t)=>{if(!e||"object"!=typeof e)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION)})};function iv(e){let t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}class iI{constructor(e,t,i,n){this.setAttributess=e=>{ii(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 tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR)}else{if(!(e instanceof HTMLElement))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR);this.container=e}}catch(e){console.error(e)}ii(this.iframe,{src:ie.IFRAME_SECURE_SITE,title:"Secure Credit Card Form","aria-label":"Secure payment form",role:"application",tabindex:"0"}),null==(t=this.container)||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=is({name:this.name})}}class ig{}let iA="Element";class iL extends ig{constructor(e,t,i,s,a=!1,l,c,d,u){var h;super(),this.type=e1.COLLECT,V.set(this,void 0),X.set(this,!1),z.set(this,void 0),G.set(this,void 0),H.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),W.set(this,void 0),$.set(this,new t7),q.set(this,void 0),K.set(this,t8.getEventBus()),Z.set(this,void 0),J.set(this,[]),Q.set(this,!1),ee.set(this,void 0),et.set(this,void 0),ei.set(this,!1),this.getID=()=>o(this,V,"f"),this.mount=e=>{var t;
1if(!e)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);let i=(e,t)=>{if(e.name===o(this,Z,"f").name){t(o(this,W,"f")),o(this,el,"f").call(this);let e=o(this,z,"f")[0],{name:s}=e,a=n(e,["name"]);o(this,G,"f").length>1?o(this,G,"f").forEach((e,t)=>{o(this,q,"f")&&o(this,q,"f")._emit(`${td.READY}:${e.elementName}`,Object.assign(Object.assign({},o(this,z,"f")[t]),{elementType:e.elementType}))}):o(this,$,"f")._emit(td.READY,Object.assign({},a)),o(this,K,"f").off(tu+this.containerId,i),id(`${iu("%s1 - %s2 Element mounted.",iA,ih(o(this,Z,"f").name))} `,F.LOG,o(this,ee,"f").logLevel),o(this,J,"f").forEach(e=>e()),r(this,J,[],"f")}};if(o(this,G,"f").length>1)o(this,Z,"f").mount(e),o(this,K,"f").on(tu+this.containerId,i);else{if(o(this,ei,"f"))return o(this,Z,"f").mount(e),void o(this,K,"f").on(tu+this.containerId,i);null==(t=o(this,q,"f"))||t.on(tg,t=>{(null==t?void 0:t.containerId)===this.containerId&&(o(this,Z,"f").mount(e),o(this,K,"f").on(tu+this.containerId,i))})}},this.unmount=()=>{o(this,K,"f").off(t_,o(this,er,"f")),o(this,Z,"f").unmount()},this.update=e=>{let t=ir(e),i=()=>{o(this,X,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),r(this,W,iC(o(this,W,"f"),t),"f"),r(this,G,iR(o(this,W,"f")),"f"),o(this,X,"f")?o(this,K,"f").emit(tm,{name:o(this,Z,"f").name,options:o(this,G,"f")[0],isSingleElementAPI:!0}):(o(this,G,"f").forEach(e=>{o(this,K,"f").emit(tm,{name:e.elementName,options:e,isSingleElementAPI:!0})}),o(this,K,"f").emit(tm,{name:o(this,Z,"f").name,options:o(this,W,"f"),isSingleElementAPI:!1})),o(this,el,"f").call(this)};o(this,Q,"f")?i():o(this,J,"f").push(i)},en.set(this,e=>{o(this,X,"f")||o(this,$,"f").on(tm,()=>{e(o(this,G,"f"))},!0)}),this.updateElement=e=>{o(this,K,"f").emit(tm,{name:e.elementName,options:e,isSingleElementAPI:!0})},es.set(this,()=>{o(this,z,"f").forEach((e,t)=>{var i;if(0===t){o(this,H,"f").isEmpty=e.isEmpty,o(this,H,"f").isComplete=e.isComplete,o(this,H,"f").isValid=e.isValid,o(this,H,"f").isFocused=e.isFocused,o(this,H,"f").isRequired=e.isRequired,o(this,H,"f").value={};let i=o(this,G,"f")[t].elementName,n=e.value&&((e,t,i)=>{if("string"!=typeof e)return e;if(t===tx.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{let t=e.replace(/[\s-]/g,"");tj.DEFAULT,Object.entries(tS).forEach(([e,i])=>{i.regex.test(t)})})(e);let t=e.length<=15?6:8;return e.length>t?e.replace(RegExp(`.(?=.{0,${(null==e?void 0:e.length)-t-1}}$)`,"g"),"X"):e}return e}return i?e:void 0})(e.value,e.elementType,o(this,et,"f"));o(this,X,"f")?o(this,H,"f").value=n:o(this,H,"f").value[i]=n}else o(this,H,"f").isEmpty=o(this,H,"f").isEmpty||e.isEmpty,o(this,H,"f").isComplete=o(this,H,"f").isComplete&&e.isComplete,o(this,H,"f").isValid=o(this,H,"f").isValid&&e.isValid,o(this,H,"f").isFocused=o(this,H,"f").isFocused||e.isFocused,o(this,H,"f").isRequired=o(this,H,"f").isRequired||e.isRequired,o(this,H,"f").value||(o(this,H,"f").value={}),!o(this,G,"f")[t]&&(null==(i=o(this,G,"f")[t])?void 0:i.sensitive)&&(o(this,H,"f").value[o(this,G,"f")[t].elementName]=e.value||"")})}),this.getState=()=>({isEmpty:o(this,H,"f").isEmpty,isComplete:o(this,H,"f").isComplete,isValid:o(this,H,"f").isValid,isFocused:o(this,H,"f").isFocused,value:o(this,H,"f").value,required:o(this,H,"f").isRequired}),this.getOptions=()=>{let e=ir(o(this,W,"f"));return o(this,X,"f")?e=e.rows[0].elements[0]:e.rows.forEach(e=>{e.elements.forEach(e=>{delete e.elementName})}),delete e.elementName,e},eo.set(this,e=>{o(this,$,"f").on("DESTROY_FRAME",()=>{let t=o(this,G,"f").map(e=>e.elementName);o(this,X,"f")||t.push(o(this,Z,"f").name),e(t)},!0)}),er.set(this,e=>{if(o(this,X,"f")&&e.event===td.READY&&e.name===o(this,Z,"f").name)o(this,$,"f")._emit(td.READY);else{let t=o(this,G,"f").length>1;o(this,G,"f").forEach((i,n)=>{var s;if(e.name===i.elementName){let r="";switch(e.event){case td.FOCUS:r=td.FOCUS;break;case td.BLUR:r=td.BLUR;break;case td.CHANGE:r=td.CHANGE;break;case td.READY:r=td.READY;break;case td.SUBMIT:return void(null==(s=o(this,q,"f"))||s._emit(td.SUBMIT));default:throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}o(this,z,"f")[n].isEmpty=e.value.isEmpty,o(this,z,"f")[n].isValid=e.value.isValid,o(this,z,"f")[n].isComplete=e.value.isComplete,o(this,z,"f")[n].isFocused=e.value.isFocused,o(this,z,"f")[n].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?o(this,z,"f")[n].value=e.value.value:o(this,z,"f")[n].value=void 0,r=t?`${r}:${e.name}
1`:r,o(this,K,"f").emit(td.HEIGHT+o(this,Z,"f").name,{},e=>{(null==e?void 0:e.height)>0&&o(this,Z,"f").setIframeHeight(e.height)}),o(this,es,"f").call(this);let a=Object.assign(Object.assign({},o(this,z,"f")[n]),{elementType:i.elementType});t&&o(this,q,"f")?o(this,q,"f")._emit(r,a):o(this,$,"f")._emit(r,a)}})}}),ea.set(this,()=>{o(this,K,"f").on(t_,o(this,er,"f"))}),el.set(this,()=>{let{rows:e}=o(this,W,"f");e.forEach(e=>{e.elements.forEach(e=>{e.elementType!==tL.radio.name&&e.elementType!==tL.checkbox.name&&(e.value=void 0)})}),r(this,G,iR(o(this,W,"f")),"f")}),this.containerId=s.containerId,r(this,V,e,"f"),r(this,ee,d,"f"),r(this,W,iC(t),"f"),r(this,G,iR(t),"f"),r(this,X,a,"f"),u&&r(this,q,u,"f"),r(this,et,il[o(this,ee,"f").env].doesReturnValue,"f"),this.elementType=o(this,X,"f")?o(this,G,"f")[0].elementType:"group",r(this,z,[],"f"),o(this,G,"f").forEach(e=>{o(this,z,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:o(this,et,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})}),r(this,Z,new iI(o(this,W,"f").elementName,i,this.containerId,o(this,ee,"f").logLevel),"f"),o(this,ea,"f").call(this),o(this,eo,"f").call(this,l),o(this,en,"f").call(this,c),id(iu("%s1 - Created %s2 element.",iA,ih(o(this,Z,"f").name)),F.LOG,o(this,ee,"f").logLevel),r(this,ei,s.isMounted,"f"),null==(h=o(this,q,"f"))||h.on(tg,e=>{(null==e?void 0:e.containerId)===this.containerId&&r(this,ei,!0,"f")});const p=e=>{e.height&&e.height>0&&o(this,Z,"f").setIframeHeight(e.height)};o(this,K,"f").on(td.MOUNTED,e=>{s.type===e1.COMPOSABLE?o(this,G,"f").forEach(t=>{e.name===t.elementName&&(t.isMounted=!0,r(this,Q,!0,"f"))}):e.name===o(this,G,"f")[0].elementName&&(o(this,G,"f")[0].isMounted=!0,r(this,Q,!0,"f")),o(this,K,"f").emit(td.HEIGHT+o(this,Z,"f").name,{},p)})}on(e,t){if(!Object.values(td).includes(e))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);o(this,$,"f").on(e,e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)})}iframeName(){return o(this,Z,"f").name}isMounted(){return o(this,Q,"f")}isValidElement(){for(let e=0;e<o(this,G,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(o(this,G,"f")[e],"table"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!o(this,G,"f")[e].table)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof o(this,G,"f")[e].table||o(this,G,"f")[e].table instanceof String))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(o(this,G,"f")[e],"column"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!o(this,G,"f")[e].column)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof o(this,G,"f")[e].column||o(this,G,"f")[e].column instanceof String))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==o(this,G,"f")[e].skyflowID&&!o(this,G,"f")[e].skyflowID)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){o(this,K,"f").emit(ty,{name:iv(o(this,Z,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){o(this,K,"f").emit(ty,{name:iv(o(this,Z,"f").name),isTriggerError:!1})}setValue(e){o(this,ee,"f").env!==j.PROD?o(this,X,"f")&&o(this,K,"f").emit(tm,{name:o(this,Z,"f").name,options:Object.assign(Object.assign({},o(this,G,"f")[0]),{value:e}),isSingleElementAPI:!0}):id(iu("%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",o(this,G,"f")[0].elementType),F.WARN,o(this,ee,"f").logLevel)}clearValue(){o(this,ee,"f").env!==j.PROD?o(this,X,"f")&&o(this,K,"f").emit(tm,{name:o(this,Z,"f").name,options:Object.assign(Object.assign({},o(this,G,"f")[0]),{value:""}),isSingleElementAPI:!0}):id(iu("%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",o(this,G,"f")[0].elementType),F.WARN,o(this,ee,"f").logLevel)}
1setAttribute(e,t){o(this,K,"f").emit(tE,{name:o(this,Z,"f").name,attribute:e,value:t})}focus(){var e;if(!(null==(e=o(this,G,"f"))?void 0:e.length))return;let t=this.getState();o(this,K,"f").emit(t_,{name:o(this,G,"f")[0].elementName,event:td.FOCUS,value:{isEmpty:t.isEmpty,isValid:t.isValid,isComplete:t.isComplete,isFocused:!0,isRequired:t.required,value:t.value}})}}function iO(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(tL,e))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE);t.validations.forEach((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE);if(!Object.values(B).includes(e.type))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS);if(e.type===B.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE)}else if(e.type===B.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE)})}if(Object.prototype.hasOwnProperty.call(i,"name")&&i.name!==t.name)throw Error("Name attribute can't be updated");if((i=Object.assign(Object.assign({},t),i)).mask||i.replacePattern){let{type:t}=tL[e].attributes;"text"===t&&"textarea"===t&&"email"===t||(delete i.mask,delete i.replacePattern)}if(i.mask,Array.isArray(i.mask)){let e=i.mask;if("string"!=typeof e[0]||e[1]&&"object"!=typeof e[1])throw Error("mask array values has to be string")}if(Array.isArray(i.replacePattern)){let e=i.replacePattern;if("string"!=typeof e[0]||e[1]&&"string"!=typeof e[1])throw Error("replacePatterns array values has to be string")}if((e===tL.radio.name||e===tL.checkbox.name)&&!i.value)throw Error("Elements radio and checkbox requires value attribute");if(!(e!==tL.dropdown.name||i.options&&Array.isArray(i.options)&&0!==i.options.length))throw Error("Element dropdown requires options attribute with an array of objects containing value and text attributes")}function iC(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach((n,s)=>{let o=e.rows[s];t.rows[s]=Object.assign(Object.assign({},o),n),n.elements.forEach((e,t)=>{var s,r;let a=o.elements[t];if(e.elementType&&a.elementType!==e.elementType&&a.elementName&&a.elementName!==e.elementName)throw Error("Element can't be changed.");iO(a.elementType,a,e),n.elements[t]=Object.assign(Object.assign(Object.assign({},a),e),{elementName:a.elementName});let l=e.classes||{},c=e.styles||{};c.base=Object.assign(Object.assign({},tR),c.base),e.classes=l,e.styles=c;let d=(null==(s=null==e?void 0:e.labelStyles)?void 0:s.classes)||{},u=(null==(r=null==e?void 0:e.labelStyles)?void 0:r.styles)||{};i&&(Object.values(tT).forEach(e=>{if(d[e]||u[e])switch(e){case tT.BASE:u[e]=Object.assign({},u[e]);break;case tT.FOCUS:u[tT.BASE]=Object.assign(Object.assign({},u[tT.BASE]),{":focus":Object.assign({},u[tT.BASE]&&u[tT.BASE][":focus"])});break;case tT.WEBPACKAUTOFILL:u[tT.BASE]=Object.assign(Object.assign({},u[tT.BASE]),{":-webkit-autofill":Object.assign({},u[tT.BASE]&&u[tT.BASE][":-webkit-autofill"])});break;default:u[e]=Object.assign(Object.assign({},u[tT.BASE]),u[e])}}),Object.keys(u).forEach(e=>{let t=u[e][":-webkit-autofill"];"object"==typeof t&&Object.keys(t).forEach(e=>{t[e]&&!t[e].includes("!important")&&(t[e]=`${t[e]} !important`)})})),e.labelStyles={labelClasses:d},e.labelStyles.styles=u})}),t}V=new WeakMap,X=new WeakMap,z=new WeakMap,G=new WeakMap,H=new WeakMap,W=new WeakMap,$=new WeakMap,q=new WeakMap,K=new WeakMap,Z=new WeakMap,J=new WeakMap,Q=new WeakMap,ee=new WeakMap,et=new WeakMap,ei=new WeakMap,en=new WeakMap,es=new WeakMap,eo=new WeakMap,er=new WeakMap,ea=new WeakMap,el=new WeakMap;let iR=e=>{let{rows:t}=e,i=[];
1return t.forEach(e=>{e.elements.forEach(e=>{i.push(e)})}),i},iT=e=>{let t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach((e,t)=>{if(e&&e.type===B.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE);if(e.params&&(null==e.params.element||!(e.params.element instanceof iL)))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE);e.params&&e.params.element&&e.params.element instanceof iL&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===B.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!i_(e.params.regex))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&i_(e.params.regex)&&(e.params.regex=e.params.regex.toString())}}),t},iS=(e,t,i)=>{var n;let s=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(s,"format")||Object.prototype.hasOwnProperty.call(s,"translation"))&&(tw.includes(e)?(id(iu("format or translation are not supported on %s1 element type.",e),F.WARN,i),null==s||delete s.format,null==s||delete s.translation):e===tL.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION)}})(t),null==(s=Object.assign(Object.assign({},s),{mask:[s.format,s.translation?s.translation:tD]}))||delete s.format,null==s||delete s.translation)),e===tL.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(s,"enableCardIcon")||(s=Object.assign(Object.assign({},s),{enableCardIcon:!0}));let e=" ";(null==s?void 0:s.format)==="XXXX-XXXX-XXXX-XXXX"&&(e="-"),null==(s=Object.assign(Object.assign({},s),{cardSeperator:e}))||delete s.format,null==s||delete s.translation}else if(e===tL.EXPIRATION_DATE.name){let e=!1;s.format&&((e=!!(n=s.format.toUpperCase())&&tb.includes(n))||id(iu("EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",tb.toString()),F.WARN,i)),null==(s=Object.assign(Object.assign({},s),{format:e?s.format.toUpperCase():tP}))||delete s.translation}else if(e===tL.EXPIRATION_YEAR.name){let e,t=!1;s.format&&((t=!!(e=s.format.toUpperCase())&&tN.includes(e))||id(iu("EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",tN.toString()),F.WARN,i)),null==(s=Object.assign(Object.assign({},s),{format:t?s.format.toUpperCase():"YY"}))||delete s.translation}if(Object.prototype.hasOwnProperty.call(s,"enableCardIcon")&&"boolean"!=typeof s.enableCardIcon)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS,{description:"Interface: container create - Invaild enableCardIcon in options, enableCardIcon of type boolean is required."});if(Object.prototype.hasOwnProperty.call(s,"required")&&"boolean"!=typeof s.required)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS,{description:"Interface: container create - Invaild required in options, required of type boolean is required."});return s};function iP(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=crypto.getRandomValues(new Uint32Array(1))[0]/0x100000000*16|0;return("x"===e?t:3&t|8).toString(16)})}class ib{}let iN="CollectContainer";class iw extends ib{constructor(e,t,i,n){super(),ec.set(this,void 0),ed.set(this,{}),eu.set(this,void 0),eh.set(this,void 0),ep.set(this,void 0),this.type=e1.COLLECT,e_.set(this,void 0),em.set(this,!1),this.create=(e,t={required:!1})=>{iE(e,o(this,eh,"f").logLevel);let i=iT(e),n=iS(e.type,t,o(this,eh,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),n),{validations:i})]}]};return o(this,eE,"f").call(this,s,!0)},eE.set(this,(e,t=!1)=>{let i=[],n=ir(e);
1if(n.rows.forEach(e=>{e.elements.forEach(e=>{let{elementType:t}=e;iO(t,e),e.sensitive=e.sensitive||tL[t].sensitive,e.replacePattern=e.replacePattern||tL[t].replacePattern,e.mask=e.mask||tL[t].mask,e.isMounted=!1,e.elementType!==tL.radio.name&&e.elementType!==tL.checkbox.name||(e.elementName=`${e.elementName}:${btoa(e.value)}`),e.elementName=`${tc}:${e.elementType}:${btoa(iP())}`,e.label=e.label,e.skyflowID=e.skyflowID,i.push(e)})}),n.elementName=t?i[0].elementName:`${tc}:group:${btoa(n.name)}`,t&&!o(this,ed,"f")[i[0].elementName]&&o(this,ef,"f").call(this,i[0].name))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let s=o(this,ed,"f")[n.elementName];if(s)t?s.update(i[0]):s.update(n);else{let e=iP();s=new iL(e,n,o(this,eu,"f"),{containerId:o(this,ec,"f"),isMounted:o(this,em,"f"),type:this.type},t,o(this,ev,"f"),o(this,eI,"f"),o(this,eh,"f"),o(this,e_,"f")),o(this,ed,"f")[n.elementName]=s,o(this,ep,"f")[e]=s}return t||i.forEach(e=>{let t=e.elementName;o(this,ed,"f")[t]?o(this,ed,"f")[t].update(e):o(this,ed,"f")[t]=this.create(e.elementType,s)}),s}),ey.set(this,e=>{Object.keys(o(this,ed,"f")).forEach(t=>{t===e&&delete o(this,ed,"f")[t]})}),ev.set(this,e=>{e.forEach(e=>{o(this,ey,"f").call(this,e)})}),eI.set(this,e=>{e.forEach(e=>{o(this,ed,"f")[e.elementName]&&o(this,ed,"f")[e.elementName].update(e)})}),ef.set(this,e=>{let t=Object.keys(o(this,ed,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1}),this.validate=()=>new Promise((e,t)=>{Object.values(o(this,ed,"f")).forEach(e=>{if(!e.isMounted())throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(tI+o(this,ec,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,i)=>{try{let n;im(o(this,eu,"f").clientJSON.config);let s=Object.values(o(this,ed,"f")),r=tP;if(s.forEach(e=>{if(!e.isMounted())throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement();let t=e.getOptions();t.elementType===tx.EXPIRATION_DATE&&(r=t.format||"MM/YY")}),Object.prototype.hasOwnProperty.call(e,"tokens")&&(n=e.tokens,"boolean"!=typeof n))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&ip(e.additionalFields),(null==e?void 0:e.upsert)&&iy(null==e?void 0:e.upsert),this.bus.target(ie.IFRAME_SECURE_ORGIN).emit(th+o(this,ec,"f"),Object.assign(Object.assign({},Object.assign(Object.assign({},e),{expiryDateFormat:r})),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),e=>{!e||(null==e?void 0:e.error)?(id(`${JSON.stringify(null==e?void 0:e.error)}`,F.ERROR,o(this,eh,"f").logLevel),i(null==e?void 0:e.error)):(id(iu(to,iN),F.LOG,o(this,eh,"f").logLevel),t(e))}),id(iu(tr,iN,th),F.LOG,o(this,eh,"f").logLevel)}catch(e){id(`${e.message}`,F.ERROR,o(this,eh,"f").logLevel),i(e)}}),this.unmount=()=>{this.iframe.remove()},this.bus=t8.getEventBus(),r(this,ec,iP(),"f"),r(this,eu,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),r(this,ep,i,"f"),r(this,eh,n,"f"),r(this,e_,new t7,"f"),this.iframe=is({name:`${tl}:${o(this,ec,"f")}:${o(this,eh,"f").logLevel}`}),ii(this.iframe,{src:ie.IFRAME_SECURE_SITE}),io(this.iframe,Object.assign({},tC)),id(iu(tn,iN),F.LOG,o(this,eh,"f").logLevel);const s=(e,t)=>{e.name===tl+o(this,ec,"f")&&(t(Object.assign(Object.assign({},o(this,eu,"f")),{clientJSON:Object.assign(Object.assign({},o(this,eu,"f").clientJSON),{config:Object.assign({},o(this,eu,"f").clientJSON.config)}),context:o(this,eh,"f")})),r(this,em,!0,"f"),o(this,e_,"f")._emit(tg,{containerId:o(this,ec,"f")}),this.bus.target({origin:ie.IFRAME_SECURE_ORGIN}).off(tu+o(this,ec,"f"),s))};this.bus.target({origin:ie.IFRAME_SECURE_ORGIN}).on(tu+o(this,ec,"f"),s),document.body.append(this.iframe)}reset(){this.bus.emit(tp+o(this,ec,"f"))}}ec=new WeakMap,ed=new WeakMap,eu=new WeakMap,eh=new WeakMap,ep=new WeakMap,e_=new WeakMap,em=new WeakMap,eE=new WeakMap,ey=new WeakMap,ev=new WeakMap,eI=new WeakMap,ef=new WeakMap;let iD=(e,t,i)=>{let n=t.split(/[\.\[\]]/g),s=e;for(let e of n){if(null==s)return i;let t=e.replace(/['"]/g,"");""!==t.trim()&&(s=s[t])}return void 0===s?i:s},iM=(e,t,i)=>{if(!e)return{};if(!t||void 0===i)return e;let n=t.split(/[\.\[\]]/g).filter(e=>!!e.trim()),s=e=>{if(n.length>1){let t=n.shift(),i=null!==((e,t)=>{if(null==e)return t;let i=parseInt(e);return isNaN(i)?t:i})(n[0],null);e[t]=void 0===e[t]?i?[]:{}:e[t],s(e[t])}else e[n[0]]=i},o=(e=>{if(null==e||"object"!=typeof e&&"function"!=typeof e)return e;if("function"==typeof e)return e.bind({});let t=new e.constructor;return Object.getOwnPropertyNames(e).forEach(i=>
1{t[i]=e[i]}),t})(e);return s(o),o};class ik{constructor(e,t){eg.set(this,void 0),eA.set(this,void 0),eL.set(this,t8.getEventBus()),eO.set(this,null),this.type=e1.COMPOSABLE,eC.set(this,!1),eR.set(this,!1),this.update=e=>{r(this,eR,!0,"f"),o(this,eC,"f")?(o(this,eA,"f")._emit(tv,{elementName:o(this,eg,"f"),elementOptions:e}),r(this,eR,!1,"f")):o(this,eR,"f")&&o(this,eA,"f").on(`${U.READY}:${o(this,eg,"f")}`,()=>{o(this,eA,"f")._emit(tv,{elementName:o(this,eg,"f"),elementOptions:e}),r(this,eC,!0,"f"),r(this,eR,!1,"f")})},r(this,eg,e,"f"),r(this,eA,t,"f"),o(this,eA,"f").on(`${U.READY}:${o(this,eg,"f")}`,()=>{r(this,eC,!0,"f")})}on(e,t){if(!Object.values(td).includes(e))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);o(this,eA,"f").on(`${e}:${o(this,eg,"f")}`,e=>{if(void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value){let{value:t}=e;e.value=t.slice(0,8)}r(this,eO,{isEmpty:e.isEmpty,isValid:e.isValid,isComplete:e.isComplete,isFocused:e.isFocused,isRequired:e.isRequired,value:e.value},"f"),delete e.isComplete,delete e.name,t(e)})}focus(){let e=o(this,eO,"f")||{isEmpty:!0,isValid:!1,isComplete:!1,isFocused:!0,isRequired:!1};o(this,eL,"f").emit(t_,{name:o(this,eg,"f"),event:td.FOCUS,value:Object.assign(Object.assign({},e),{isFocused:!0})})}setAttribute(e,t){o(this,eA,"f")._emit(tE,{elementName:o(this,eg,"f"),attribute:e,value:t})}}eg=new WeakMap,eA=new WeakMap,eL=new WeakMap,eO=new WeakMap,eC=new WeakMap,eR=new WeakMap;let iY="CollectContainer";class iU extends ib{constructor(e,t,i,n){super(),eT.set(this,void 0),eS.set(this,{}),eP.set(this,void 0),eb.set(this,{rows:[]}),eN.set(this,[]),ew.set(this,void 0),eD.set(this,void 0),eM.set(this,void 0),ek.set(this,!1),eY.set(this,void 0),eU.set(this,void 0),this.type=e1.COMPOSABLE,ex.set(this,!1),ej.set(this,{}),this.create=(e,t={required:!1})=>{iE(e,o(this,ew,"f").logLevel);let i=iT(e),n=iS(e.type,t,o(this,ew,"f").logLevel),s=`${tc}:${e.type}:${btoa(iP())}`;return o(this,eN,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),n),{validations:i,elementName:s})),new ik(s,o(this,eM,"f"))},eF.set(this,(e,t=!1)=>{let i=[];if(r(this,eS,{},"f"),r(this,ej,ir(e),"f"),o(this,ej,"f").rows.forEach(e=>{e.elements.forEach(e=>{let{elementType:t}=e;iO(t,e),e.sensitive=e.sensitive||tL[t].sensitive,e.replacePattern=e.replacePattern||tL[t].replacePattern,e.mask=e.mask||tL[t].mask,e.isMounted=!1,e.label=e.label,e.skyflowID=e.skyflowID,i.push(e)})}),o(this,ej,"f").elementName=t?i[0].elementName:`${tc}:group:${btoa(o(this,ej,"f").name)}`,t&&!o(this,eS,"f")[i[0].elementName]&&o(this,ez,"f").call(this,i[0].name))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let n=o(this,eS,"f")[o(this,ej,"f").elementName];if(n)t?n.update(i[0]):n.update(o(this,ej,"f"));else{let e=iP();n=new iL(e,o(this,ej,"f"),o(this,eP,"f"),{containerId:o(this,eT,"f"),isMounted:o(this,ex,"f"),type:this.t
1ype},!0,o(this,eV,"f"),o(this,eX,"f"),o(this,ew,"f"),o(this,eM,"f")),o(this,eS,"f")[o(this,ej,"f").elementName]=n,o(this,eD,"f")[e]=n}return n}),eB.set(this,e=>{Object.keys(o(this,eS,"f")).forEach(t=>{t===e&&delete o(this,eS,"f")[t]})}),eV.set(this,e=>{e.forEach(e=>{o(this,eB,"f").call(this,e)})}),eX.set(this,e=>{e.forEach(e=>{o(this,eS,"f")[e.elementName]&&o(this,eS,"f")[e.elementName].update(e)})}),ez.set(this,e=>{let t=Object.keys(o(this,eS,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1}),this.on=(e,t)=>{if(!Object.values(td).includes(e))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);o(this,eM,"f").on(td.SUBMIT,()=>{t()})},this.mount=e=>{if(!e)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);r(this,eb,{rows:[]},"f");let{layout:t}=o(this,eY,"f");if((t||[]).reduce((e,t)=>e+t,0)!==o(this,eN,"f").length)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);let i=0;(t.forEach((e,t)=>{o(this,eb,"f").rows=[...o(this,eb,"f").rows,{elements:[]}];for(let n=0;n<e;n++)o(this,eb,"f").rows[t].elements.push(o(this,eN,"f")[i]),i++}),o(this,eY,"f").styles&&(o(this,eb,"f").styles=Object.assign({},o(this,eY,"f").styles)),o(this,eY,"f").errorTextStyles&&(o(this,eb,"f").errorTextStyles=Object.assign({},o(this,eY,"f").errorTextStyles)),o(this,ex,"f"))?(o(this,eU,"f")&&(o(this,eU,"f").unmount(),r(this,eU,null,"f")),r(this,eS,{},"f"),r(this,eU,o(this,eF,"f").call(this,o(this,eb,"f"),!1),"f"),this.mountContainerElement(e),r(this,ek,!0,"f")):o(this,eM,"f").on(tf+o(this,eT,"f"),()=>{r(this,eS,{},"f"),r(this,eU,o(this,eF,"f").call(this,o(this,eb,"f"),!1),"f"),this.mountContainerElement(e),r(this,ek,!0,"f")})},this.mountContainerElement=e=>{o(this,eU,"f").mount(e)},this.unmount=()=>{var e;[...o(this,eN,"f").map(e=>e.elementName)].forEach(e=>{o(this,eB,"f").call(this,e)}),r(this,eN,[],"f"),r(this,eb,{rows:[]},"f"),r(this,eS,{},"f"),null==(e=o(this,eU,"f"))||e.unmount(),this.iframe.remove(),r(this,ek,!1,"f"),r(this,ex,!1,"f")},this.validate=()=>new Promise((e,t)=>{Object.values(o(this,eS,"f")).forEach(e=>{if(!e.isMounted())throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(tI+o(this,eT,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,i)=>{try{if(im(o(this,eP,"f").clientJSON.config),!o(this,ek,"f")){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw ti.PayrailsLogger.error(e.message,{error:e}),e}if(iR(o(this,ej,"f")).forEach(e=>{if(!(null==e?void 0:e.isMounted))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)}),Object.values(o(this,eS,"f")).forEach(e=>{e.isValidElement()}),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&ip(e.additionalFields),(null==e?void 0:e.upsert)&&iy(null==e?void 0:e.upsert),this.bus.emit(th+o(this,eT,"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)?(id(`${JSON.stringify(null==e?void 0:e.error)}`,F.ERROR,o(this,ew,"f").logLevel),i(null==e?void 0:e.error)):(id(iu(to,iY),F.LOG,o(this,ew,"f").logLevel),t(e))}),id(iu(tr,iY,th),F.LOG,o(this,ew,"f").logLevel)}catch(e){id(`${e.message}`,F.ERROR,o(this,ew,"f").logLevel),i(e)}}),eG.set(this,()=>{o(this,eM,"f").on(tv,e=>{let t,i=o(this,eN,"f").map((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i);o(this,eU,"f")&&o(this,eU,"f").updateElement(Object.assign({},i[t]))})}),this.bus=t8.getEventBus(),r(this,eT,iP(),"f"),r(this,eP,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),r(this,eD,i,"f"),r(this,ew,n,"f"),r(this,eY,e,"f"),r(this,eM,new t7,"f"),this.iframe=is({name:`${tl}:${o(this,eT,"f")}:${o(this,ew,"f").logLevel}`}),ii(this.iframe,{src:ie.IFRAME_SECURE_SITE}),io(this.iframe,Object.assign({},tC)),id(iu(tn,iY),F.LOG,o(this,ew,"f").logLevel);const s=(e,t)=>{e.name===tl+o(this,eT,"f")&&(t(Object.assign(Object.assign({},o(this,eP,"f")),{clientJSON:Object.assign(Object.assign({}
1,o(this,eP,"f").clientJSON),{config:Object.assign({},o(this,eP,"f").clientJSON.config)}),context:o(this,ew,"f")})),r(this,ex,!0,"f"),o(this,eM,"f")._emit(tf+o(this,eT,"f"),{containerId:o(this,eT,"f")}),this.bus.target({origin:ie.IFRAME_SECURE_ORGIN}).off(tu+o(this,eT,"f"),s))};this.bus.target({origin:ie.IFRAME_SECURE_ORGIN}).on(tu+o(this,eT,"f"),s),document.body.append(this.iframe),o(this,eG,"f").call(this)}reset(){this.bus.emit(tp+o(this,eT,"f"),{})}}function ix(e){this.message=e}eT=new WeakMap,eS=new WeakMap,eP=new WeakMap,eb=new WeakMap,eN=new WeakMap,ew=new WeakMap,eD=new WeakMap,eM=new WeakMap,ek=new WeakMap,eY=new WeakMap,eU=new WeakMap,ex=new WeakMap,ej=new WeakMap,eF=new WeakMap,eB=new WeakMap,eV=new WeakMap,eX=new WeakMap,ez=new WeakMap,eG=new WeakMap,ix.prototype=Error(),ix.prototype.name="InvalidCharacterError";var ij="u">typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ix("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,s=0,o=0,r="";n=t.charAt(o++);~n&&(i=s%4?64*i+n:n,s++%4)&&(r+=String.fromCharCode(255&i>>(-2*s&6))))n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function iF(e){this.message=e}iF.prototype=Error(),iF.prototype.name="InvalidTokenError";let iB=e=>{try{if(!e||"[object String]"!==Object.prototype.toString.call(e))return!1;let t=!1,i=function(e,t){if("string"!=typeof e)throw new iF("Invalid token specified");var i=+(!0!==(t=t||{}).header);try{return JSON.parse(function(e){var t,i=e.replace(/-/g,"+").replace(/_/g,"/");switch(i.length%4){case 0:break;case 2:i+="==";break;case 3:i+="=";break;default:throw"Illegal base64url string!"}try{return t=i,decodeURIComponent(ij(t).replace(/(.)/g,function(e,t){var i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}catch(e){return ij(i)}}(e.split(".")[i]))}catch(e){throw new iF("Invalid token specified: "+e.message)}}(e),n=(new Date).getTime()/1e3,s=i.exp;return s&&n>s&&(t=!0),!t}catch(e){return!1}};class iV{constructor(e,t){eH.set(this,void 0),this.config=e,r(this,eH,t,"f")}toJSON(){return{config:this.config,metaData:o(this,eH,"f")}}static fromJSON(e){return new iV(e.config,e.metaData)}}eH=new WeakMap,(f=e1||(e1={})).COLLECT="COLLECT",f.COMPOSABLE="COMPOSABLE";let iX="Skyflow";class iz{constructor(e){var t,i;eW.set(this,void 0),e$.set(this,iP()),eq.set(this,{uuid:o(this,e$,"f"),clientDomain:window.location.origin}),eK.set(this,""),eZ.set(this,void 0),eJ.set(this,void 0),eQ.set(this,void 0),e0.set(this,void 0),this.bus=t8.getEventBus();const n=localStorage.getItem("sdk_version")||"";o(this,eq,"f").sdkVersion=n,r(this,eW,new iV(Object.assign({},e),o(this,eq,"f")),"f"),r(this,eJ,(null==(t=null==e?void 0:e.options)?void 0:t.logLevel)||x.ERROR,"f"),r(this,eQ,(null==(i=null==e?void 0:e.options)?void 0:i.env)||j.PROD,"f"),r(this,e0,{},"f"),this.bus.on("ERROR",e=>{if(e&&e.errorCode){let t=new tt.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});ti.PayrailsLogger.error(t.message,{error:t})}}),this.bus.target({origin:ie.IFRAME_SECURE_ORGIN}).on("GET_BEARER_TOKEN"+o(this,e$,"f"),(e,t)=>{id(iu("%s1 - Captured bearer token event.",iX),F.LOG,o(this,eJ,"f")),!o(this,eW,"f").config.getBearerToken||o(this,eK,"f")&&iB(o(this,eK,"f"))?(id(iu("%s1 - Reusing the bearer token.",iX),F.LOG,o(this,eJ,"f")),t({authToken:o(this,eK,"f")})):o(this,eW,"f").config.getBearerToken().then(e=>{iB(e)?(id(iu("%s1 - GetBearerToken promise resolved successfully.",iX),F.LOG,o(this,eJ,"f")),r(this,eK,e,"f"),t({authToken:o(this,eK,"f")})):(id(ta,F.ERROR,o(this,eJ,"f")),t({error:ta}))}).catch(e=>{id("Interface: init - GetBearerToken promise got rejected.",F.ERROR,o(this,eJ,"f")),t({error:e})})}),id(iu("%s1 - Get bearer token listener added.",iX),F.LOG,o(this,eJ,"f")),id(iu("%s1 - Client Env is %s2",iX,o(this,eQ,"f")),F.LOG,o(this,eJ,"f")),id(iu("%s1 - Client LogLevel is %s2",iX,o(this,eJ,"f")),F.LOG,o(this,eJ,"f"))}static init(e){var t,i;let n=(null==(t=null==e?void 0:e.options)?void 0:t.logLevel)||x.ERROR;(function(e){var t,i,n,s;if((null==(t=null==e?void 0:e.options)?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{return new URL(e),!0}catch(e){return!1}})(null==(i=null==e?void 0:e.options)?void 0:i.customElementsURL)){let t=new URL(null==(n=null==e?void 0:e.options)?void 0:n.customElementsURL),i=t.protocol,o=t.hostname;ie.IFRAME_SECURE_ORGIN=`${i}//${o}`,ie.IFRAME_SECURE_SITE=null==(s=null==e?void 0:e.options)?void 0:s.customElementsURL}ie.IFRAME_SECURE_ORGIN="https://assets.payrails.io",ie.IFRAME_SECURE_SITE="https://assets.payrails.io/2089b54/card/index.html"})(e),id(iu("%s1 - Initializing skyflow client.",iX),F.LOG,n),e.vaultURL="string"!=typeof(i=e.vaultURL)?i:"/"===(null==i?void 0:i.trim().slice(-1))?i.slice(0,-1):i.trim();let s=new iz(e);return id(iu("%s1 - Initialized skyflow client successfully.",iX),F.LOG,n),s}container(e,t){switch(e){case e1.COLLECT:{let i=new iw(t,Object.assign(Object.assign({},o(this,eq,"f")),{clientJSON:o(this,eW,"f").toJSON(),containerType:e}),o(this,e0,"f"),{logLevel:o(this,eJ,"f"),env:o(this,eQ,"f")});return id(iu(ts,iX),F.LOG,o(this,eJ,"f")),i}
1case e1.COMPOSABLE:{if(!t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS);if("object"!=typeof t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID);if(!Object.prototype.hasOwnProperty.call(t,"layout"))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY);if(!t.layout||!Array.isArray(t.layout))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(0===t.layout.length)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY);t.layout.forEach(e=>{if("number"!=typeof e)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(e<0)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT)});let i=new iU(t,Object.assign(Object.assign({},o(this,eq,"f")),{clientJSON:o(this,eW,"f").toJSON(),containerType:e}),o(this,e0,"f"),{logLevel:o(this,eJ,"f"),env:o(this,eQ,"f")});return id(iu(ts,iX),F.LOG,o(this,eJ,"f")),i}default:if(!e)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE);throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE)}}static get ContainerType(){return e1}static get ElementType(){return tx}static get RedactionType(){return k}static get RequestMethod(){return Y}static get LogLevel(){return x}static get EventName(){return U}static get Env(){return j}static get ValidationRuleType(){return B}}eW=new WeakMap,e$=new WeakMap,eq=new WeakMap,eK=new WeakMap,eZ=new WeakMap,eJ=new WeakMap,eQ=new WeakMap,e0=new WeakMap;let iG=(e,t)=>s(void 0,void 0,void 0,function*(){try{let i=yield su(e,t);if(!i){let n=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart resolved to false"});return sd(e,t,{code:te.VALIDATION_FAILED,message:n.message}),i}}catch(n){let i=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart threw an error",cause:n});return ti.PayrailsLogger.error(i.message,{error:i}),sd(e,t,{code:te.VALIDATION_FAILED,message:i.message}),!1}return!0}),iH={},iW={success:"https://assets.payrails.io/html/payrails-success.html",error:"https://assets.payrails.io/html/payrails-error.html",cancel:"https://assets.payrails.io/html/payrails-cancel.html",pending:"https://assets.payrails.io/html/payrails-pending.html"};class i${static getInstance(){return this.instance||(this.instance=new i$),this.instance}constructor(e=""){this.lastActionUpdateTime=e,i$.instance=this}}class iq{constructor(e=iW,t=680,i=60,n=2e3,s=5,o=i$.getInstance()){this.returnLinks=e,this.POLL_INTERVAL=t,this.MAX_POLL_ATTEMPTS=i,this.POLL_INITIAL_DELAY=n,this.POLL_ERROR_COUNT_MULTIPLIER=s,this.paymentStatus=o}pay(e){return s(this,void 0,void 0,function*(){try{let t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:t});throw ti.PayrailsLogger.error(e.message,{error:e}),t}})}payout(e){return s(this,void 0,void 0,function*(){try{let t=(yield this.executePayout(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR,{cause:t});throw ti.PayrailsLogger.error(e.message,{error:e}),t}})}confirm(e){return s(this,arguments,void 0,function*(e,t={}){try{let i=yield tW({url:e,method:P.POST,token:t6.getInstance().config.token,body:{data:t}}),n=yield this.pollForAuthorizationResult(i.res.links.execution);if(n.finalState)return n;let s=n.response.status.slice().sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0].time,{res:o}=yield this.getExecution(i.res.links.execution,s);return{finalState:o.status.find(({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(s)),response:o}}
1catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:t});throw ti.PayrailsLogger.error(e.message,{error:e}),t}})}getExecution(e,t){return s(this,arguments,void 0,function*(e,t,i=0,n){if(i>this.MAX_POLL_ATTEMPTS)throw new tZ(e,P.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY,n):yield this.wait(this.POLL_INTERVAL,n);try{let s=yield tW({url:e,token:t6.getInstance().config.token});if(t&&!s.res.status.find(({time:e})=>new Date(e)>new Date(t)))return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+1,n);return s}catch(s){if(s instanceof tq)return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER,n);if(s instanceof tK)return yield this.wait(this.POLL_INTERVAL*i,n),this.getExecution(e,t,i+1,n);throw s}})}createApplePaySession(e){return s(this,void 0,void 0,function*(){return tW({url:e.requestUrl,method:P.POST,token:t6.getInstance().config.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:t6.getInstance().config.amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})})}authorize(e){return s(this,void 0,void 0,function*(){if(!t4.authorizeLink||!t6.getInstance().config.amount){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw ti.PayrailsLogger.error(e.message,{error:e}),e}let{success:t=iW.success,error:i=iW.error,cancel:n=iW.cancel,pending:s=iW.pending}=this.returnLinks,o=this.attachMetaToPaymentComposition({amount:t6.getInstance().config.amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:s}});return tW({url:t4.authorizeLink,method:P.POST,token:t6.getInstance().config.token,body:o})})}executePayout(e){return s(this,void 0,void 0,function*(){if(!t4.payoutLink||!t6.getInstance().config.amount){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw ti.PayrailsLogger.error(e.message,{error:e}),e}let t={amount:t6.getInstance().config.amount,payoutComposition:e};return tW({url:t4.payoutLink,method:P.POST,token:t6.getInstance().config.token,body:t})})}getFirstNonFraudNetId(e){let t=Object.keys(e||{}).find(e=>"fraudNet"!==e);return t?e[t]:null}attachMetaToPaymentComposition(e){var t,i,n,s,o,r,a;let l;l=e.paymentComposition[0].paymentMethodCode===b.PAYPAL&&(null==(i=null==(t=window.PayrailsData)?void 0:t.riskIds)?void 0:i.fraudNet)?null==(s=null==(n=window.PayrailsData)?void 0:n.riskIds)?void 0:s.fraudNet:this.getFirstNonFraudNetId(null==(o=window.PayrailsData)?void 0:o.riskIds)||"";let c=Object.assign(Object.assign({},e),{meta:Object.assign(Object.assign({},t4.getUpdatedMeta()),e.meta)});return!1!==(null==(r=iH.telemetry)?void 0:r.collectMetadata)&&(c.meta=Object.assign(Object.assign({},c.meta),{clientContext:Object.assign(Object.assign({},(null==(a=c.meta)?void 0:a.clientContext)||{}),((e=window,t=navigator)=>{let i,n={userAgent:t.userAgent,language:t.language,screenHeight:e.screen.height,screenWidth:e.screen.width,colorDepth:e.screen.colorDepth,timeZoneOffset:(new Date).getTimezoneOffset(),acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",javaEnabled:!1,javaScriptEnabled:!0},s=(i=t.userAgent,/android/i.test(i)?"android":/iphone|ipad|ipod/i.test(i)?"ios":/windows|linux|mac/i.test(i)?"web":void 0);return s&&(n.osType=s),n})())})),l&&(c.meta.risk={sessionId:l}),c}wait(e,t){return s(this,void 0,void 0,function*(){var i;if(null==t?void 0:t.aborted)throw null!=(i=t.reason)?i:new DOMException("Aborted","AbortError");return new Promise((i,n)=>{let s=setTimeout(()=>{null==t||t.removeEventListener("abort",o),i()},e),o=()=>{var e;clearTimeout(s),null==t||t.removeEventListener("abort",o),n(null!=(e=null==t?void 0:t.reason)?e:new DOMException("Aborted","AbortError"))};null==t||t.addEventListener("abort",o,{once:!0})})})}pollForAuthorizationResult(e){return s(this,arguments,void 0,function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed","payoutPending","payoutSuccessful","payoutFailed"],n){var s;let o=null==n?void 0:n.signal;if(null==o?void 0:o.aborted)throw null!=(s=o.reason)?s:new DOMException("Aborted","AbortError");let r=(yield this.getExecution(e,this.paymentStatus.lastActionUpdateTime,t,o)).res,a=r.status,l=a.find(({code:e})=>"authorizeRequested"===e||"payoutRequested"===e);if(!l&&t<10)return yield this.wait(this.POLL_INTERVAL,o),this.pollForAuthorizationResult(e,t+1,i,{signal:o});
1if(!l){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw ti.PayrailsLogger.error(e.message,{error:e}),e}let c=a.find(({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(l.time)),d=c?c.time:l.time,u=a.filter(({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(d)).sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0];return u?(this.paymentStatus.lastActionUpdateTime=u.time,{finalState:u,response:r}):this.pollForAuthorizationResult(e,t+1,i,{signal:o})})}}function iK(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 iZ(){if("u"<typeof Promise)throw Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function iJ(e,t){if("object"!=typeof e||null===e)throw Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw Error("Expected PromisePonyfill to be a function.")}(g=e2||(e2={})).ApplePay="https://applepay.cdn-apple.com/jsapi/v1.3.2/apple-pay-sdk.js",g.GooglePay="https://pay.google.com/gp/p/js/pay.js",g.PayPal="paypal-sdk",g.Lean="https://cdn.leantech.me/link/loader/prod/ae/latest/lean-link-loader.min.js";class iQ{static load(e,t){let i=e.toString(),n=iQ.scriptMap.get(i);if(n)return n;let o=s(this,void 0,void 0,function*(){try{if(e===e2.PayPal){if(!t)throw Error("PayPal config is required");return yield iQ.loadPayPalScript(t)}return yield iQ.loadScript(e)}finally{iQ.scriptMap.delete(i)}});return iQ.scriptMap.set(i,o),o}static reset(){iQ.scriptMap.clear()}static invalidate(e){var t;iQ.scriptMap.delete(e.toString());let i=iQ.getScriptKey(e);iQ.scriptMap.delete(i),null==(t=document.getElementById(i))||t.remove()}static preloadCardForm(){let e="https://assets.payrails.io/2089b54/card";[[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach(([e,t])=>{if(!document.getElementById(t)){let i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}})}static loadScript(e){let t=iQ.getScriptKey(e);if(iQ.scriptMap.has(t))return iQ.scriptMap.get(t);let i=document.createElement("script");i.src=e,i.id=t;let n=iQ.sdkScriptAttributes[e];n&&Object.entries(n).forEach(([e,t])=>{i.setAttribute(e,t)});let s=new Promise((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(iQ.logLoadError(e,Error(t.toString())))}).catch(e=>{throw iQ.scriptMap.delete(t),i.remove(),e});return iQ.scriptMap.set(t,s),document.body.appendChild(i),s}static getScriptKey(e){return`payrails-script-${JSON.stringify(e)}`}static loadPayPalScript(e){return s(this,arguments,void 0,function*({clientId:e,currency:t,vault:i,intent:n,locale:s}){let o;for(let r=0;r<=iQ.PAYPAL_MAX_RETRIES;r++){r>0&&(iQ.removePayPalScriptElements(),yield iQ.delay(iQ.PAYPAL_BASE_DELAY_MS*Math.pow(2,r-1)));try{let r=yield function(e,t){if(void 0===t&&(t=iZ()),iJ(e,t),"u"<typeof window)return t.resolve(null);var i,n,s,o,r,a,l,c,d,u=(n="https://www.paypal.com/sdk/js",e.sdkBaseURL&&(n=e.sdkBaseURL,delete e.sdkBaseURL),s=e["merchant-id"],o=e["data-merchant-id"],r="",a="",Array.isArray(s)?s.length>1?(r="*",a=s.toString()):r=s.toString():"string"==typeof s&&s.length>0?r=s:"string"==typeof o&&o.length>0&&(r="*",a=o),e["merchant-id"]=r,e["data-merchant-id"]=a,c=(l=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:{}})).queryParams,d=l.dataAttributes,{url:"".concat(n,"?").concat(function(e){var t="";return Object.keys(e).forEach(function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]}),t}(c)),dataAttributes:d}),h=u.url,p=u.dataAttributes,_=p["data-namespace"]||"paypal",m=(i=_,window[i]);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=iK(e,t),s=i.cloneNode();if(delete s.dataset.uidAuto,Object.keys(s.dataset).length!==Object.keys(n.dataset).length)return null;var o=!0;return Object.keys(s.dataset).forEach(function(e){s.dataset[e]!==n.dataset[e]&&(o=!1)}),o?i:null}(h,p)&&m?t.resolve(m):(function(e,t){void 0===t&&(t=iZ()),iJ(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw Error("Expected attributes to be an object.");return new t(function(e,t){var s,o,r,a,l,c;if("u"<typeof window)return e();o=(s={url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=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;t(Error((i=e.split("/* Original Error:")[1])?i.replace(/\n/g,"").replace("*/","").trim():e))}).catch(function(e){t(e)}):t(e)}}).url,r=s.attributes,a=s.onSuccess,l=s.onError,(c=iK(o,r)).onerror=l,c.onload=a,document.head.insertBefore(c,document.head.firstElementChild)})})({url:h,attributes:p},t).then(function(){var e,t=(e=_,window[e]);if(t)return t;throw Error("The window.".concat(_," global variable is not available."))})}(Object.assign({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"},s&&{locale:s}));if(r)return r;o=Error("The window.payrailsPaypal global variable is not available.")}catch(e){o=e}
1let a=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR,{cause:o});ti.PayrailsLogger.error(`PayPal SDK load attempt ${r+1}/${iQ.PAYPAL_MAX_RETRIES+1} failed`,{error:a})}throw iQ.logLoadError(e2.PayPal,o)})}static removePayPalScriptElements(){document.querySelectorAll('script[src*="paypal.com/sdk/js"]').forEach(e=>e.remove())}static delay(e){return new Promise(t=>setTimeout(t,e))}static logLoadError(e,t){let i=new Map([[e2.ApplePay,tt.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[e2.GooglePay,tt.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[e2.PayPal,tt.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new tt.PayrailsError(i.get(e)||tt.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return ti.PayrailsLogger.error(n.message,{error:n}),n}}iQ.scriptMap=new Map,iQ.sdkScriptAttributes={[e2.ApplePay]:{crossorigin:"anonymous",integrity:"sha384-DZRWMZLyVXr+7shJfal8pIG2v4KisLoSWFjZQMUv0+GWaCwoa82qeHsWrbBIUDPU"}},iQ.PAYPAL_MAX_RETRIES=2,iQ.PAYPAL_BASE_DELAY_MS=1e3;let i0=/^[a-zA-Z]+([_-][a-zA-Z0-9]+)*$/,i1=e=>{if(e&&i0.test(e))return e},i2=e=>{var t,i;return(i1(e)||i1(null==(i=null==(t=t4.meta)?void 0:t.customer)?void 0:i.language)||"en-GB").replace("_","-")};class i3{constructor(e,{id:t="",className:i="",dataTestId:n=""}={}){this.subElements=[],this.eventBus=t8.getEventBus();const s=document.createElement(e);t&&(this.id=t,s.setAttribute("id",t)),n&&(this.dataTestId=n,s.setAttribute("data-testid",n)),i&&(Array.isArray(i)?s.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):s.setAttribute("class",i)),this.element=s}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){let t=document.querySelector(e);if(!t)throw new tt.PayrailsError(tt.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 tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)})}clean(){var e;null==(e=document.getElementById(this.element.id))||e.remove()}unmount(){var e;this.subElements.forEach(e=>e.unmount()),null==(e=this.parentElement)||e.removeChild(this.element)}}class i4 extends i3{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument",dataTestId:e.dataTestId}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null==(e=this.element.querySelector("input"))?void 0:e.checked)}createHTML(){var e,t,i,n,s,o,r,a,l,c;let d=(null==(i=null==(t=null==(e=this.options)?void 0:e.translations)?void 0:t.labels)?void 0:i.saveInstrument)||(null==(o=null==(s=null==(n=this.options)?void 0:n.translations)?void 0:s.labels)?void 0:o.storeInstrument)||"Save instrument for future payments",u=`${this.id}-checkbox`,h=`${this.dataTestId}-checkbox`;(null==(l=null==(a=null==(r=this.options)?void 0:r.translations)?void 0:a.labels)?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead");let p="checked"==(null==(c=this.options)?void 0:c.defaultStoreInstrumentState);this.element.innerHTML=`<label for="${u}"><input type="checkbox" id="${u}" name="${u}" data-testid="${h}" class="payrails-store-instrument-checkbox">${d}</label>`,p&&(this.element.querySelector("input").checked=!0)}applyStyles(){var e,t;Object.keys((null==(t=null==(e=this.options)?void 0:e.styles)?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.styles)?void 0:i.storeInstrumentCheckbox)?void 0:n[e]})}addListeners(){this.element.addEventListener("change",e=>{var t,i,n,s;(null==(i=null==(t=this.options)?void 0:t.events)?void 0:i.onSaveInstrumentCheckboxChanged)&&(null==(s=null==(n=this.options)?void 0:n.events)||s.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()}),this.element.addEventListener("click",e=>{e.stopPropagation(),e.stopImmediatePropagation()})}}class i6 extends i3{constructor(e,t){var i,n,o,r,a;super(e,t),this.options=t,this.storeInstrumentCheckbox=null,(null==(i=this.options)?void 0:i.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new i4(Object.assign(Object.assign({},t),{id:`${null==(n=this.options)?void 0:n.id}-store-instrument-checkbox`,dataTestId:(null==(o=this.options)?void 0:o.dataTestId)?`${null==(r=this.options)?void 0:r.dataTestId}-store-instrument-checkbox`:`${null==(a=this.options)?void 0:a.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>s(this,void 0,void 0,function*(){var i,n;null==(n=null==(i=null==t?void 0:t.events)?void 0:i.onSaveInstrumentCheckboxChanged)||n.call(i,e)})}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null==(e=this.storeInstrumentCheckbox)?void 0:e.isChecked)||(null==(t=this.options)?void 0:t.alwaysStoreInstrument)||!1}}class i5 extends i6{static isApplePayAvailable(){return s(this,void 0,void 0,function*(){try{return yield iQ.load(e2.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}})}constructor(e){super("div",Object.assign(Object.assign({},e),{id:`payrails-apple-pay-button-${tH()}`,dataTestId:"payrails-apple-pay-button"})),this.options=e,this.appleButton=null,this.isProcessing=!1,this.completedSessions=new WeakSet,this.abortedSessionReasons=new WeakMap,this.paymentExecutor=new iq,i5.isApplePayAvailable().then(e=>{var t,i,n;e&&(null==(n=null==(i=null==(t=this.options)?void 0:t.events)?void 0:i.onApplePayAvailable)||n.call(i))}),this.action="tokenization"===t6.getInstance().config.type?e8.TOKENIZE:e8.AUTHORIZE}mount(e){this.unmount(),super.mount(e),s(this,void 0,void 0,function*(){try{(yield i5.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}})}unmount(){var e,t;null==(t=null==(e=this.appleButton)?void 0:e.parentElement)||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){return s(this,void 0,void 0,function*(){var e,t,i,n;try{let o=(null==(e=this.options.styles)?void 0:e.type)||"buy",r=(null==(t=this.options.styles)?void 0:t.style)||"black",a=i2(null==(i=this.options.styles)?void 0:i.locale);this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${o}" locale="${a}"></apple-pay-button>
1`,null==(n=this.storeInstrumentCheckbox)||n.mount(this.selector);let l=this.element.querySelector("apple-pay-button");null==l||l.setAttribute("style","width: 100%;"),null==l||l.addEventListener("click",()=>s(this,void 0,void 0,function*(){this.isProcessing||(this.isProcessing=!0,yield this.createApplePaySession())}))}catch(e){}})}onAuthorizeFailedHandler(e,t){this.isProcessing=!1,this.options.abortAfterAuthorizeFailed?(this.abortedSessionReasons.set(e,t),this.completeApplePaySession(e,"abort")):(this.completeApplePaySession(e,"failure"),sd(e8.AUTHORIZE,this.options.events,t instanceof tt.PayrailsError?t:void 0))}completeApplePaySession(e,t){if(!this.completedSessions.has(e)){this.completedSessions.add(e);try{if("abort"===t)return void e.abort();e.completePayment("success"===t?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE)}catch(e){ti.PayrailsLogger.warn(`ApplePaySession completion failed (${t})`,{error:e instanceof tt.PayrailsError?e:void 0})}}}createApplePaySession(){return s(this,void 0,void 0,function*(){var e,t;let{countryCode:i,supportedNetworks:n,merchantCapabilities:o,requiredBillingContactFields:r=[],requiredShippingContactFields:a=[]}=t4.applePayConfig,{amount:l}=t6.getInstance().config;try{let c=new ApplePaySession(3,{countryCode:i,currencyCode:l.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:(null==(t=null==(e=this.options.translations)?void 0:e.labels)?void 0:t.paymentScreenLabel)||"",type:"final",amount:l.value},requiredBillingContactFields:r,requiredShippingContactFields:a});return c.onvalidatemerchant=e=>s(this,void 0,void 0,function*(){let t;try{let{res:i}=yield this.paymentExecutor.createApplePaySession({requestUrl:t4.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain});t=i}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR);return ti.PayrailsLogger.error(e.message,{error:e,extra:{catchError:t}}),this.abortedSessionReasons.set(c,e),void c.abort()}try{let e=t.data.data;c.completeMerchantValidation(e)}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_MERCHANT_VALIDATION_FAILED);ti.PayrailsLogger.error(e.message,{error:e,extra:{catchError:t}}),this.abortedSessionReasons.set(c,e),c.abort()}}),c.oncancel=e=>{this.isProcessing=!1;let t=this.abortedSessionReasons.get(c);t instanceof tt.PayrailsError?(this.abortedSessionReasons.delete(c),sd(this.action,this.options.events,t)):sd(this.action,this.options.events,{code:te.USER_CANCELLED})},c.onpaymentauthorized=e=>s(this,void 0,void 0,function*(){yield this.onApplePayAuthorized(e.payment,c)}),(yield sp(this.action,this.options.events))?c.begin():this.isProcessing=!1,c}catch(e){return this.isProcessing=!1,null}})}onApplePayAuthorized(e,t){return s(this,void 0,void 0,function*(){return(yield iG(this.action,this.options.events))?this.action===e8.TOKENIZE?yield this.doTokenize(e,t):yield this.doAuthorizedPayment(e,t):(this.action===e8.AUTHORIZE?this.onAuthorizeFailedHandler(t,{code:te.VALIDATION_FAILED,message:"Authorization request start validation failed"}):(this.isProcessing=!1,this.completeApplePaySession(t,"failure"),sd(this.action,this.options.events,{code:te.VALIDATION_FAILED,message:"Request start validation failed"})),null)})}doAuthorizedPayment(e,t){return s(this,void 0,void 0,function*(){var i,n,s,o,r;let a=[{paymentMethodCode:b.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:t6.getInstance().config.amount,storeInstrument:this.shouldStoreInstrument}];try{let e=yield this.paymentExecutor.pay(a);return"authorizeSuccessful"===(null==(i=e.finalState)?void 0:i.code)?(this.completeApplePaySession(t,"success"),this.isProcessing=!1,sc(e8.AUTHORIZE,this.options.events,e)):this.onAuthorizeFailedHandler(t,{code:te.AUTHORIZATION_ERROR,message:(null==(r=null==(o=null==(s=null==(n=e.finalState)?void 0:n.errors)?void 0:s[0])?void 0:o.reason)?void 0:r.result)||"Authorization Failed"}),e}catch(e){this.onAuthorizeFailedHandler(t,e)}})}doTokenize(e,t){return s(this,void 0,void 0,function*(){let i,n=t6.getInstance().config,s=t4.createInstrumentLink,o=n.token;if(!s)return this.completeApplePaySession(t,"failure"),this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events);try{i=JSON.stringify(e)}catch(e){return this.completeApplePaySession(t,"failure"),this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events,e)}let r={holderReference:n.holderReference,paymentMethod:b.APPLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:i}};try{let e=yield t1({url:s,token:o,body:r});return e.ok?(this.completeApplePaySession(t,"success"),this.isProcessing=!1,sc(e8.TOKENIZE,this.options.events,e.res),e.res):(this.completeApplePaySession(t,"failure"),this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events))}catch(e){return this.completeApplePaySession(t,"failure"),this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events,e)}})}}let i9={wrapper:{display:"flex",flexDirection:"column"}};(e3||(e3={})).GET="GET";let i8=e=>s(void 0,[e],void 0,function*({url:e}){let t={method:e3.GET},i=yield fetch(e,t),n=yield i.json();if(429===i.status)throw new ne(e,e3.GET);if(!i.ok)throw new i7(e,e3.GET);return{ok:i.ok,req:Object.assign({url:e},t),res:n}});class i7 extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class ne extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class nt extends i3{constructor(e,t){super(e,{id:t.id,className:t.className}),this.applyStyles(t.styles)}applyStyles(e){Object.keys(e||{}
1).forEach(t=>{this.element.style[t]=null==e?void 0:e[t]})}}let ni="__payrails-selectedCountry";class nn extends nt{constructor(e){var t,i;super("span",Object.assign(Object.assign({},e),{id:"payrails-country-select",className:"payrails-country-selector-wrapper",styles:null==(t=e.styles)?void 0:t.wrapper})),this.options=e,this._countriesList=null==(i=e.config)?void 0:i.data,this.createHTML(),this.attachEvents()}set countriesList(e){this._countriesList=e,this.populateCountrySelect(),this.setDefaultCountry()}get countriesList(){return this._countriesList}populateCountrySelect(){return s(this,void 0,void 0,function*(){var e,t;let i=document.createElement("option");i.value="",i.textContent=(null==(e=this.options.translations)?void 0:e.placeholder)||"Select Country",null==(t=this.selectElement)||t.appendChild(i),this._countriesList.forEach(e=>{var t;let i=document.createElement("option");i.value=e.code,i.textContent=e.name,null==(t=this.selectElement)||t.appendChild(i)})})}setDefaultCountry(){let e=JSON.parse(sessionStorage.getItem(ni)||"{}");if(null==e?void 0:e.code)return void(this.value=e.code);let t=Intl.DateTimeFormat().resolvedOptions().timeZone;t&&this.countriesList.forEach(e=>{var i;if(null==(i=e.timezones)?void 0:i.includes(t))return this.value=e.code,void sessionStorage.setItem(ni,JSON.stringify(this.value))})}createHTML(){this.createLabel(),this.createSelectBox()}createSelectBox(){var e;this.selectElement=document.createElement("select"),this.selectElement.id=this.options.id,this.selectElement.className="payrails-country-select-element",this._countriesList&&this.populateCountrySelect(),this.applyStylesToSubElements(null==(e=this.options.styles)?void 0:e.element,this.selectElement),this.element.appendChild(this.selectElement)}createLabel(){var e,t,i;this.label=document.createElement("label"),this.label.textContent=(null==(e=this.options.translations)?void 0:e.label)||"Country",this.applyStylesToSubElements(null==(t=this.options.styles)?void 0:t.label,this.label),(null==(i=this.options.translations)?void 0:i.label)&&this.element.appendChild(this.label)}applyStylesToSubElements(e,t){Object.keys(e||{}).forEach(i=>{t.style[i]=null==e?void 0:e[i]})}attachEvents(){var e;null==(e=this.selectElement)||e.addEventListener("change",e=>{var t,i;null==(i=null==(t=this.options.events)?void 0:t.onChange)||i.call(t,{country:this.value}),sessionStorage.setItem(ni,JSON.stringify(this.value)),e.stopPropagation(),e.stopImmediatePropagation()})}get isValid(){var e;return""!==(null==(e=this.selectElement)?void 0:e.value)}get value(){var e,t,i,n,s,o;return{code:null==(e=this.selectElement)?void 0:e.value,fullName:(null==(i=null==(t=this.selectElement)?void 0:t.options[this.selectElement.selectedIndex])?void 0:i.textContent)||"",iso3:(null==(o=null==(n=this._countriesList)?void 0:n.get(null==(s=this.selectElement)?void 0:s.value))?void 0:o.iso3)||""}}set value(e){this.selectElement&&(this.selectElement.value=e)}}class ns extends nt{set selectedCountry(e){this._selectedCountry=e}get selectedCountry(){return this._selectedCountry}constructor(e){var t;super("span",Object.assign(Object.assign({},e),{id:"payrails-postal-code-wrapper",className:"payrails-postal-code-wrapper",styles:null==(t=e.styles)?void 0:t.wrapper})),this.options=e,this._selectedCountry="",this._countriesList=void 0,this._countriesList=e.config.data,this.createHTML(),this.attachEvents()}createHTML(){this.createLabel(),this.createInput()}createInput(){var e,t;this.inputElement=document.createElement("input"),this.inputElement.type="text",this.inputElement.placeholder=(null==(e=this.options.translations)?void 0:e.placeholder)||"Postal Code",this.inputElement.id=this.options.id,this.inputElement.className="payrails-postal-code-input",this.applyStylesToSubElements(null==(t=this.options.styles)?void 0:t.element,this.inputElement),this.element.appendChild(this.inputElement)}createLabel(){var e,t,i;this.label=document.createElement("label"),this.label.textContent=(null==(e=this.options.translations)?void 0:e.label)||"Postal Code",this.applyStylesToSubElements(null==(t=this.options.styles)?void 0:t.label,this.label),(null==(i=this.options.translations)?void 0:i.label)&&this.element.appendChild(this.label)}applyStylesToSubElements(e,t){Object.keys(e||{}
1).forEach(i=>{t.style[i]=null==e?void 0:e[i]})}attachEvents(){var e,t,i;null==(e=this.inputElement)||e.addEventListener("change",e=>{e.stopPropagation(),e.stopImmediatePropagation()}),null==(t=this.inputElement)||t.addEventListener("input",e=>{var t,i,n;null==(i=null==(t=this.options.events)?void 0:t.onChange)||i.call(t,{postalCode:this.value}),null==(n=this.inputElement)||n.classList.remove("error"),e.stopPropagation(),e.stopImmediatePropagation()}),null==(i=this.inputElement)||i.addEventListener("focusout",e=>{var t;this.isValid||null==(t=this.inputElement)||t.classList.add("error"),e.stopPropagation(),e.stopImmediatePropagation()})}set countriesList(e){this._countriesList=e}get value(){var e;return(null==(e=this.inputElement)?void 0:e.value)||""}set value(e){this.inputElement&&(this.inputElement.value=e)}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}get isValid(){var e,t,i;let n=null==(e=this.inputElement)?void 0:e.value,s=this.selectedCountry,o=(null==(i=null==(t=this._countriesList)?void 0:t.get(s))?void 0:i.postalCodeRegex)||"";if(n)return o?new RegExp(o).test(n):n.length>0}setValidation(e){this.inputElement&&(this.inputElement.pattern=e,this.inputElement.classList.remove("error"))}}class no extends i3{get fullAddress(){var e,t,i,n;let s={},o=null==(e=this.countrySelector)?void 0:e.value;return o&&(s.country=o,o.code&&(null==(i=null==(t=this.countriesMap)?void 0:t.get(o.code))?void 0:i.showPostalCode)&&(s.postalCode=null==(n=this.postalCodeInput)?void 0:n.value)),Object.assign({},s)}constructor(e){var t;super("div",{id:e.id,className:"payrails-address-selector-wrapper",styles:(null==(t=e.styles)?void 0:t.wrapper)||(null==i9?void 0:i9.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),s(void 0,void 0,void 0,function*(){return new Map(Object.entries((yield(({url:e})=>i8({url:e}))({url:"https://assets.payrails.io/json/countries.json"})).res))}).then(e=>{this.countriesMap=e,this.countrySelector&&(this.countrySelector.countriesList=e),this.postalCodeInput&&(this.postalCodeInput.countriesList=e)})}applyStyles(){var e,t;Object.keys((null==(t=null==(e=this.options)?void 0:e.styles)?void 0:t.wrapper)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null==(n=null==(i=null==(t=this.options)?void 0:t.styles)?void 0:i.wrapper)?void 0:n[e]})}createAddressComponents(e){var t,i,n,s,o,r,a,l,c,d;let u={id:"country-selector",styles:(null==(t=this.options.styles)?void 0:t.countrySelector)||(null==i9?void 0:i9.countrySelector),events:{onChange:e=>{var t,i;let{country:n}=e;this.onCountryChange(n),null==(i=null==(t=this.options.events)?void 0:t.onBillingAddressChanged)||i.call(t,{isValid:this.isValid,billingAddress:this.fullAddress})}},translations:{label:null==(n=null==(i=this.options.translations)?void 0:i.labels)?void 0:n.countrySelector,placeholder:null==(o=null==(s=this.options.translations)?void 0:s.placeholders)?void 0:o.countrySelector}},h={id:"postal-code-input",translations:{label:null==(a=null==(r=this.options.translations)?void 0:r.labels)?void 0:a.postalCodeInput,placeholder:null==(c=null==(l=this.options.translations)?void 0:l.placeholders)?void 0:c.postalCodeInput},styles:(null==(d=this.options.styles)?void 0:d.postalCodeInput)||(null==i9?void 0:i9.postalCodeInput),events:{onChange:()=>{var e,t;null==(t=null==(e=this.options.events)?void 0:e.onBillingAddressChanged)||t.call(e,{isValid:this.isValid,billingAddress:this.fullAddress})}},config:{data:e}};this.countrySelector=new nn(u),this.postalCodeInput=new ns(h)}init(){var e,t;this.countrySelector&&this.subElements.push(this.countrySelector),this.postalCodeInput&&this.subElements.push(this.postalCodeInput),null==(e=this.postalCodeInput)||e.hide(),(null==(t=this.options.styles)?void 0:t.wrapper)&&Object.assign(this.element.style,this.options.styles.wrapper)}get isValid(){var e,t,i,n;let s=this.countrySelector&&this.countrySelector.isValid,o=null==(t=null==(e=this.countrySelector)?void 0:e.value)?void 0:t.code;return o&&(null==(n=null==(i=this.countriesMap)?void 0:i.get(o))?void 0:n.showPostalCode)&&(s=s&&this.postalCodeInput&&this.postalCodeInput.isValid),!!s}onCountryChange(e){var t;let i=null==e?void 0:e.code;if(!i)return;let n=null==(t=this.countriesMap)?void 0:t.get(i);if(this.postalCodeInput)if(n&&(null==n?void 0:n.showPostalCode)){let e=new RegExp(n.postalCodeRegex||"[0-9]*");this.postalCodeInput.setValidation(e.source),this.postalCodeInput.selectedCountry=i,this.postalCodeInput.show()}else this.postalCodeInput.hide(),this.postalCodeInput.setValidation(""),this.postalCodeInput.value=""}get selectedCountry(){var e;return null==(e=this.countrySelector)?void 0:e.value}get postalCode(){var e;return null==(e=this.postalCodeInput)?void 0:e.value}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}}class nr extends i3{constructor(e){var t;super("div",{id:e.id,className:e.className}),this.options=e,this.INSTALLMENT_STORAGE_KEY="__payrails-selectedInstallmentCount",this.installmentOptions=[],this.installmentOptions=(null==(t=e.installmentConfig)?void 0:t.installmentOptions)||[],this.createHTML(),this.applyStyles(),this.addListeners()}getDefaultInstallment(){var e,t;return parseInt(null!=(e=sessionStorage.getItem(this.INSTALLMENT_STORAGE_KEY))?e:"",10)||(null==(t=this.options.installmentConfig)?void 0:t.defaultInstallment)}generateOptionsHTML(e){var t,i,n;let s=(null==(n=null==(i=null==(t=this.options)?void 0:t.translations)?void 0:i.labels)?void 0:n.paymentInstallments)||"Split payment into monthly installments",o=this.getDefaultInstallment();return[`<option value="">${s}</option>`,...(null==e?void 0:e.map(e=>{let t=e.count===o?" selected":"";return`<option value="${e.count}" ${t}>${e.count} x ${e.amount}</option>`}))||[]].join("")}renderOptions(e){let t=this.element.querySelector("select");if(t){t.innerHTML=this.generateOptionsHTML(e);let i=this.getDefaultInstallment();i&&(t.value=String(i)),e.length>0?this.setDisabled(!1):this.setDisabled(!0)}}updateOptions(e){this.updateConfig(Object.assign(Object.assign({},this.options.installmentConfig),{installmentOptions:e}))}updateConfig(e){var t,i,n,s,o,r,a;
1if(!this.options)return;let l=null!=(t=this.options.installmentConfig)?t:{},c=null!=e?e:{};this.options.installmentConfig={installmentCurrency:null!=(i=c.installmentCurrency)?i:l.installmentCurrency,installmentOptions:null!=(s=null!=(n=c.installmentOptions)?n:l.installmentOptions)?s:[],defaultInstallment:null!=(o=c.defaultInstallment)?o:l.defaultInstallment},this.installmentOptions=null!=(r=this.options.installmentConfig.installmentOptions)?r:[],null==(a=this.renderOptions)||a.call(this,this.installmentOptions)}createHTML(){let e=`${this.id}-dropdown`;this.element.innerHTML=`<select name="${this.options.className}" id="${e}"></select>`,this.renderOptions(this.installmentOptions||[])}applyStyles(){var e,t;Object.keys((null==(t=null==(e=this.options)?void 0:e.styles)?void 0:t.paymentInstallmentsDropdown)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null==(n=null==(i=null==(t=this.options)?void 0:t.styles)?void 0:i.paymentInstallmentsDropdown)?void 0:n[e]})}addListeners(){this.element.addEventListener("change",e=>{var t;e.stopPropagation(),e.stopImmediatePropagation();let i=null==(t=this.element.querySelector("select"))?void 0:t.value;i?sessionStorage.setItem(this.INSTALLMENT_STORAGE_KEY,i):sessionStorage.removeItem(this.INSTALLMENT_STORAGE_KEY)}),this.element.addEventListener("click",e=>{e.stopPropagation(),e.stopImmediatePropagation()})}get selectedInstallmentValue(){var e;return null==(e=this.element.querySelector("select"))?void 0:e.value}setDisabled(e){let t=this.element.querySelector("select");t&&0!==this.installmentOptions.length?t&&(t.disabled=e,this.setVisible(!e)):this.setVisible(!1)}setVisible(e){let t=this.element.querySelector("select");t&&t.parentElement&&(t.parentElement.style.display=e?"block":"none")}}class na extends i3{constructor(e,t){var i,n;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new nr(Object.assign(Object.assign({},t),{id:`${null==(i=this.options)?void 0:i.id}-dropdown`,className:"payrails-payment-installments-dropdown",installmentConfig:null==(n=this.options)?void 0:n.installmentConfig})),this.subElements.push(this.paymentInstallmentsDropdown)}get selectedInstallmentValue(){var e;return parseInt((null==(e=this.paymentInstallmentsDropdown)?void 0:e.selectedInstallmentValue)||"0")}updateInstallmentOptions(e){var t;this.options&&(null==(t=this.paymentInstallmentsDropdown)||t.updateOptions(e))}updateInstallmentConfig(e){var t;this.options&&(this.options.installmentConfig=Object.assign(Object.assign({},this.options.installmentConfig),e),null==(t=this.paymentInstallmentsDropdown)||t.updateConfig(this.options.installmentConfig))}setDisabled(e){var t;null==(t=this.paymentInstallmentsDropdown)||t.setDisabled(e)}}let{CARD_NUMBER:nl,CVV:nc,CARDHOLDER_NAME:nd,EXPIRATION_DATE:nu,EXPIRATION_MONTH:nh,EXPIRATION_YEAR:np}=M,n_={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},nm=[{type:nd,placeholder:"Card holder",styles:Object.assign(Object.assign({},n_),{base:Object.assign(Object.assign({},n_.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:nl,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},n_),{base:Object.assign(Object.assign({},n_.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:nh,placeholder:"MM",styles:Object.assign(Object.assign({},n_),{base:Object.assign(Object.assign({},n_.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:np,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},n_),{base:Object.assign(Object.assign({},n_.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:nu,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},n_),{base:Object.assign(Object.assign({},n_.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:nc,placeholder:"CVC",styles:Object.assign(Object.assign({},n_),{base:Object.assign(Object.assign({},n_.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];
1class nE extends i6{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(e,t){var i,n,s,o,r,a,l,c,d;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.labels),{saveInstrument:null==(s=null==(n=null==t?void 0:t.translations)?void 0:n.labels)?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null==(o=null==t?void 0:t.styles)?void 0:o.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.defaultStyles={},this.defaultTranslations={},this.defaultStyles=(null==(r=this.options)?void 0:r.styles)||{},this.defaultTranslations=(null==(a=this.options)?void 0:a.translations)||{},this.eventsRef=null==(l=this.options)?void 0:l.events,this.throttledFetchBinLookup=function(e){let t,i;return function(...n){return new Promise((s,o)=>{i?(clearTimeout(t),t=setTimeout(()=>{Date.now()-i>=500&&(e(...n).then(s).catch(o),i=Date.now())},500-(Date.now()-i))):(e(...n).then(s).catch(o),i=Date.now())})}}(this.fetchBinLookup.bind(this)),(null==(c=null==t?void 0:t.styles)?void 0:c.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),t4.isPaymentInstallmentsEnabled(b.CARD)&&(this.paymentInstallmentsDropdown=new na("span",Object.assign(Object.assign({},t),{installmentConfig:{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),defaultInstallment:null==(d=null==t?void 0:t.installmentConfig)?void 0:d.defaultInstallment},id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),t4.isAddressSelectorEnabled(b.CARD)&&(this.addressComponent=this.createAddressSelector(),this.subElements.push(this.addressComponent)),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}initializeFormFields(){var e;(null==(e=this.options)?void 0:e.layout)&&this.options.layout.length>0?this.initializeCustomLayout():this.initializeDefaultLayout()}getErrorTextStyles(e){return(null==e?void 0:e.base)?e:{base:{}}}updateStyles(e){return this.formFields.forEach(t=>{var i,n,s,o;let r=t2((null==(i=null==e?void 0:e.inputFields)?void 0:i.all)||{},(null==(n=null==e?void 0:e.inputFields)?void 0:n[t.type])||{}),a=this.prepareInputStyles(r,t.type),l=t2((null==(s=null==e?void 0:e.labels)?void 0:s.all)||{},(null==(o=null==e?void 0:e.labels)?void 0:o[t.type])||{}),c=this.prepareLabelStyles(t.type,l),d=this.prepareErrorStyles(null==e?void 0:e.errorTextStyles);t.update({styles:{inputStyles:a,labelStyles:c,errorTextStyles:d}})}),t2(this.defaultStyles,e||{})}updateTranslations(e){let t=t2(this.defaultTranslations||{},e||{});return this.formFields.forEach(e=>{var i,n,s,o;let r=null==(i=t.labels)?void 0:i[e.type],a=null==(n=t.placeholders)?void 0:n[e.type],l=null==(o=null==(s=t.error)?void 0:s.default)?void 0:o[e.type];e.update({translations:Object.assign(Object.assign(Object.assign({},void 0!==r&&{label:r}),void 0!==a&&{placeholder:a}),void 0!==l&&{translations:{error:{default:l}}})})}),t}updateEvents(e){this.eventsRef=Object.assign(Object.assign({},this.eventsRef),e),this.formFields.forEach(e=>{e.update({events:{onFocus:()=>{var e,t;return null==(t=null==(e=this.eventsRef)?void 0:e.onFocus)?void 0:t.call(e)},onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})})}update(e){(null==e?void 0:e.styles)&&(this.defaultStyles=this.updateStyles(e.styles)),(null==e?void 0:e.translations)&&(this.defaultTranslations=this.updateTranslations(e.translations)),(null==e?void 0:e.events)&&this.updateEvents(e.events)}updateInstallmentConfig(e){var t,i,n,s,o;if(!this.paymentInstallmentsDropdown)return;let r=t4.getPaymentInstallmentOptions(b.CARD),a={installmentCurrency:(null==(t=t6.getInstance().config.amount)?void 0:t.currency)||""};this.options&&e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(this.options.installmentConfig={defaultInstallment:null!=(i=e.defaultInstallment)?i:null},a.defaultInstallment=null!=(n=e.defaultInstallment)?n:null);let l=null==(o=null==(s=this.lastBinLookup)?void 0:s.issuerCountry)?void 0:o.code;a.installmentOptions=(l&&r?r[l]:void 0)||[],this.paymentInstallmentsDropdown.updateInstallmentConfig(a)}createFormField(e,t,i,n,s,o=!1){var r,a,l,c,d,u,h;let p=this.prepareErrorStyles(i);return new ny(this.collectContainer,{type:e,required:o,label:null==(a=null==(r=this.defaultTranslations)?void 0:r.labels)?void 0:a[e],errorTextStyles:p,placeholder:(null==(c=null==(l=this.defaultTranslations)?void 0:l.placeholders)?void 0:c[e])||s,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(t,e),translations:{error:{default:(null==(h=null==(u=null==(d=this.defaultTranslations)?void 0:d.error)?void 0:u.default)?void 0:h[e])||""}},format:n,events:{onFocus:()=>{var e,t;return null==(t=null==(e=this.eventsRef)?void 0:e.onFocus)?void 0:t.call(e)},onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})}isFieldRequired(){var e,t;return!!(null==(t=null==(e=this.defaultStyles)?void 0:e.errorTextStyles)?void 0:t.base)}initializeCustomLayout(){var e;if(!(null==(e=this.options)?void 0:e.layout))return;let t=e=>
1{e.forEach(e=>{var t;let i=nm.find(t=>t.type===e);if(!i)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(i.type))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);let{type:n,styles:s,format:o,placeholder:r}=i,a=this.isFieldRequired();this.formFields.push(this.createFormField(n,s,null==(t=this.defaultStyles)?void 0:t.errorTextStyles,o,r,a))})};this.options.layout.forEach(e=>t(e))}hasFieldBeenUsed(e){return this.formFields.some(t=>t.type===e)}initializeDefaultLayout(){let e=e=>{var t,i,n;return!(null==(t=this.options)?void 0:t.showCardHolderName)&&e===M.CARDHOLDER_NAME||!(null==(i=this.options)?void 0:i.showSingleExpiryDateField)&&e===M.EXPIRATION_DATE||!(!(null==(n=this.options)?void 0:n.showSingleExpiryDateField)||e!==M.EXPIRATION_MONTH&&e!==M.EXPIRATION_YEAR)};nm.filter(({type:t})=>!e(t)).forEach(({type:e,styles:t,format:i,placeholder:n})=>{var s;let o=this.isFieldRequired();this.formFields.push(this.createFormField(e,t,null==(s=this.defaultStyles)?void 0:s.errorTextStyles,i,n,o))})}throttledFetchBinLookupIfChanged(){return s(this,void 0,void 0,function*(){return this.bin!==this.lastBin&&(this.lastBin=this.bin,this.lastBinLookup=yield this.throttledFetchBinLookup()),this.lastBinLookup})}tokenize(e){return this.collectContainer.tokenize(e)}createAddressSelector(){var e,t;return new no({id:"payrails-address-selector",events:Object.assign(Object.assign({},this.eventsRef),{onBillingAddressChanged:e=>{var t,i;this.onChange(),null==(i=null==(t=this.eventsRef)?void 0:t.onBillingAddressChanged)||i.call(t,e)}}),styles:null==(e=this.defaultStyles)?void 0:e.addressSelector,translations:null==(t=this.defaultTranslations)?void 0:t.addressSelector})}show(){var e;let t=document.getElementById(this.collectContainer.id);if(!t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw ti.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(t.style,null==(e=this.defaultStyles)?void 0:e.wrapper),this.element.style.display="flex"}hide(e={}){this.element.style.display="none",e.reset&&this.reset()}triggerOnReady(){var e,t;this.formFields.reduce((e,t)=>e&&t.isReady,!0)&&(this.updateTranslations(this.defaultTranslations||{}),this.updateStyles(this.defaultStyles||{}),null==(t=null==(e=this.eventsRef)?void 0:e.onReady)||t.call(e))}prepareErrorStyles(e){var t,i;let n={base:{}};return n.base=Object.assign(Object.assign({},(null==(i=null==(t=this.defaultStyles)?void 0:t.errorTextStyles)?void 0:i.base)||{}),(null==e?void 0:e.base)||{}),n}prepareLabelStyles(e,t){var i,n,s,o,r;let a={};return a.base=Object.assign(Object.assign(Object.assign(Object.assign({},(null==(i=this.defaultStyles)?void 0:i.base)||{}),(null==(s=null==(n=this.defaultStyles)?void 0:n.labels)?void 0:s.all)||{}),(null==(r=null==(o=this.defaultStyles)?void 0:o.labels)?void 0:r[e])||{}),t||{}),a}prepareInputStyles(e,t){var i;let n={};return["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach(i=>{var s,o,r,a,l,c;n[i]=Object.assign(Object.assign(Object.assign({},(null==(r=null==(o=null==(s=this.defaultStyles)?void 0:s.inputFields)?void 0:o.all)?void 0:r[i])||{}),(null==(c=null==(l=null==(a=this.defaultStyles)?void 0:a.inputFields)?void 0:l[t])?void 0:c[i])||{}),(null==e?void 0:e[i])||{})}),(null==(i=this.options)?void 0:i.showCardHolderName)&&t===M.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n.base=Object.assign(Object.assign(Object.assign({},n_.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"}),n.base)),n}validate(){return this.collectContainer.validate()}focus(){let e=this.formFields.find(e=>!e.isValid)||this.formFields[0];if(!e)return;let t=document.getElementById(this.collectContainer.id)||this.element;t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({behavior:"smooth",block:"center"}),window.requestAnimationFrame(()=>{e.focus()})}get isValid(){var e;let t=this.formFields.reduce((e,t)=>e&&t.isValid,!0);return this.addressComponent?t&&!!(null==(e=this.addressComponent)?void 0:e.isValid):t}get cardNetwork(){var e,t;return null!=(t=null==(e=this.formFields.find(e=>!!e.cardNetwork))?void 0:e.cardNetwork)?t:""}onChange(){var e;
1(null==(e=this.eventsRef)?void 0:e.onChange)&&(this.eventsRef.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),t4.isPaymentInstallmentsEnabled(b.CARD)&&this.bin.length>=6&&this.throttledFetchBinLookupIfChanged().then(e=>{this.updateInstallments(e)}))}updateInstallments(e){var t;if(this.paymentInstallmentsDropdown&&this.isBinLookupEnabled){let i=this.getinstallmentOptions(null==(t=null==e?void 0:e.issuerCountry)?void 0:t.code);i?this.paymentInstallmentsDropdown.updateInstallmentOptions(i):this.paymentInstallmentsDropdown.updateInstallmentOptions([])}}reset(){this.collectContainer.reset()}collectValues(){return s(this,void 0,void 0,function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,selectedInstallment:this.selectedInstallment,enrollInstrumentToNetworkOffers:!!this.enforceEnrollInstrumentToNetworkOffersForMasterCard(),billingInfo:this.billingAddress}})}get selectedInstallment(){var e;return null==(e=this.paymentInstallmentsDropdown)?void 0:e.selectedInstallmentValue}get billingAddress(){var e;return null==(e=this.addressComponent)?void 0:e.fullAddress}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null==(e=this.options)?void 0:e.enrollInstrumentToNetworkOffers)}fetchBinLookup(){return s(this,void 0,void 0,function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin})}getinstallmentOptions(e){if(e){let t=t4.getPaymentInstallmentOptions(b.CARD);return t?t[e]:null}return null}unmount(){this.hide({reset:!0}),super.unmount()}mount(e){super.mount(e),this.show()}}class ny{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t;this.vaultElement=e.createCollectElement(t),this.type=t.type,(null==i?void 0:i.onFocus)&&this.vaultElement.on("FOCUS",i.onFocus),this.vaultElement.on("READY",()=>{var e,i;this.isReady=!0,null==(i=null==(e=t.events)?void 0:e.onReady)||i.call(e)}),this.vaultElement.on("CHANGE",e=>{let{isEmpty:t,isValid:n,network:s}=e;this.isValid=!t&&n,this.cardNetwork=null!=s?s:"",(null==i?void 0:i.onChange)&&i.onChange(this)})}updateStyles(e){var t,i;
1null==(i=(t=this.vaultElement).update)||i.call(t,{type:this.type,errorTextStyles:(null==e?void 0:e.errorTextStyles)||{base:{}},inputStyles:(null==e?void 0:e.inputStyles)||{},labelStyles:(null==e?void 0:e.labelStyles)||{}})}updateTranslations(e){var t,i,n,s;let o=null==(i=null==(t=null==e?void 0:e.translations)?void 0:t.error)?void 0:i.default;null==(s=(n=this.vaultElement).update)||s.call(n,Object.assign(Object.assign(Object.assign({type:this.type},void 0!==(null==e?void 0:e.label)&&{label:e.label}),void 0!==o&&{translations:{error:{default:o}}}),void 0!==(null==e?void 0:e.placeholder)&&{placeholder:e.placeholder}))}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations)}focus(){var e,t;null==(t=(e=this.vaultElement).focus)||t.call(e)}}class nv extends i3{constructor(e,t,i,n,s){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=s,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.element.setAttribute("data-testid",`dropin-item-${e}`),this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o),r.setAttribute("data-testid",`dropin-item-label-${e}`);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),a.setAttribute("data-testid",`dropin-item-radio-${e}`),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)||t.call(e,new Event("change"))}),this.element.appendChild(r);const c=document.createElement("div");c.setAttribute("class",this.mountContainerClass),c.setAttribute("data-testid","dropin-item-container"),this.element.appendChild(c)}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)||e.unmount(),(null==(t=this.events)?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.active)||{}).forEach(e=>{this.element.style.removeProperty(e)}),Object.assign(this.element.style,null==(t=this.styles)?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.base,null==(t=this.styles)?void 0:t.active)}activate(){var e,t,i;this.isActive||(null==(e=this.component)||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null==(t=this.events)?void 0:t.onActivate)&&this.events.onActivate(),(null==(i=this.events)?void 0:i.onPaymentOptionVisibilityChange)&&this.events.onPaymentOptionVisibilityChange())}mount(e){var t,i;super.mount(e),null==(i=null==(t=this.events)?void 0:t.onAvailable)||i.call(t)}}(A=e4||(e4={})).AMEX="amex",A.DINERS="diners",A.DISCOVER="discover",A.HIPERCARD="hipercard",A.JCB="jcb",A.MAESTRO="maestro",A.MASTERCARD="mastercard",A.UNIONPAY="unionpay",A.VISA="visa";let nI={[b.CARD]:"https://assets.payrails.io/img/logos/card/",[b.PAYPAL]:"https://assets.payrails.io/img/logos/paypal/",[b.APPLE_PAY]:"https://assets.payrails.io/img/logos/applepay/",[b.GOOGLE_PAY]:"https://assets.payrails.io/img/logos/googlepay/"};class nf extends nv{constructor(e,t,i,n,s){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,nf.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1),this.installmentDropdown&&this.component.setPaymentInstallmentsDropdown(this.installmentDropdown)}},n),this.installmentDropdown=null,s&&(this.installmentDropdown=s),this.instrumentData=e,this.component=new ng(t,s)}static getInstrumentIcon(e){var t;if(e.paymentMethod===b.CARD){let i=nI[b.CARD];switch(null==(t=null==e?void 0:e.data)?void 0:t.network){case e4.AMEX:return i+"amex.svg";case e4.DINERS:return i+"diners-club.svg";case e4.DISCOVER:return i+"discover.svg";case e4.HIPERCARD:return i+"hipercard.svg";case e4.JCB:return i+"jcb.svg";case e4.MAESTRO:return i+"maestro.svg";case e4.MASTERCARD:return i+"mastercard.svg";case e4.UNIONPAY:return i+"unionpay.svg";case e4.VISA:return i+"visa.svg"}return i+"default.svg"}return e.paymentMethod===b.PAYPAL?nI[b.PAYPAL]+"logo.svg":e.paymentMethod===b.APPLE_PAY?nI[b.APPLE_PAY]+"logo.svg":e.paymentMethod===b.GOOGLE_PAY?nI[b.GOOGLE_PAY]+"logo.svg":""}updateInstallmentConfig(e){var t,i,n,s,o;if(!this.installmentDropdown||this.instrumentData.paymentMethod!==b.CARD)return;let r=t4.getPaymentInstallmentOptions(b.CARD),a=null==(n=null==(i=null==(t=this.instrumentData.data)?void 0:t.binLookup)?void 0:i.issuerCountry)?void 0:n.code,l={installmentCurrency:(null==(s=t6.getInstance().config.amount)?void 0:s.currency)||""};e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(l.defaultInstallment=null!=(o=e.defaultInstallment)?o:null),l.installmentOptions=(a&&r?r[a]:void 0)||[],this.installmentDropdown.updateInstallmentConfig(l)}}class ng extends i3{constructor(e,t){super("div",{id:"stored-instrument-container",className:"payrails-stored-instrument-container"}),this.paymentButton=e,this.paymentInstallmentDropdown=t,this.paymentInstallmentDropdown&&this.subElements.push(this.paymentInstallmentDropdown),this.subElements.push(this.paymentButton)}setDisabled(e){this.paymentButton.setDisabled(e),this.paymentInstallmentDropdown&&this.paymentInstallmentDropdown.setDisabled(e)}setPaymentInstallmentsDropdown(e){this.paymentInstallmentDropdown=e,this.paymentButton.setPaymentInstallmentsDropdown(e)}}class nA extends i3{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],t4.savedCreditCards.forEach(t=>{let i=new nL(()=>{(null==e?void 0:e.onCardChange)&&e.onCardChange(t)}
1,t);this.listItems.push(i),this.subElements.push(i)})}reset(){this.element.querySelectorAll("input").forEach(e=>e.checked=!1)}}class nL extends i3{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",s=document.createElement("label");s.setAttribute("for",i),s.addEventListener("click",e);const o=document.createElement("input");o.setAttribute("type","radio"),o.setAttribute("name","payment-option"),o.setAttribute("id",i),o.setAttribute("value",i),s.appendChild(o);const r=document.createElement("span");r.className="payment-option-text",s.appendChild(r);const a=document.createElement("img");a.src=nf.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class nO extends i3{constructor(e){var t;super("div",{id:"authorization-failed-message"}),this.options=e;const i=(null==(t=null==e?void 0:e.translations)?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`
2      <div>
3        <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
4          <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>
5          <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>
6        </svg>
7      </div>
8      <div class="payrails-auth-failed-label">${i}</div>`,this.element.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()})}mount(e){super.mount(e),this.scheduleAutoHide()}setStyles(e){Object.keys(e).forEach(t=>{this.element.style[t]=e[t]})}scheduleAutoHide(){var e,t;let i=null==(t=null==(e=this.options)?void 0:e.configuration)?void 0:t.autoHideTTL;i&&setTimeout(()=>{this.unmount()},i)}}class nC extends i3{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`
9      <div class="checkmark-wrapper">
10        <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
11          <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
12            <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
13          </svg>
14      </div>
15      <div id="payrails-authorization-success">${(null==(t=null==e?void 0:e.translations)?void 0:t.label)||"Payment successful"}</div`}setStyles(e){Object.keys(e).forEach(t=>{this.element.style[t]=e[t]})}}class nR extends i3{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[e6.overlay]:".loading-overlay",[e6.loader]:".lds-ring .loading-ring"},this.element.innerHTML="\n    <div class='loading-overlay'>\n      <div class='lds-ring'>\n        <div></div>\n        <div></div>\n        <div></div>\n        <div class='loading-ring'></div>\n      </div>\n    </div>\n    "}mount(e){var t;(null==(t=this.options)?void 0:t.styles)&&this.setStyles(this.options.styles),super.mount(e)}setStyles(e){Object.keys(e).forEach(t=>{e[t]&&this.applyStyles(t,e[t])})}applyStyles(e,t){let i=this.element.querySelector(this.selectors[e]);i&&Object.keys(t).forEach(e=>{i.style[e]=t[e]})}}(L=e6||(e6={})).overlay="overlay",L.loader="loader";let nT="https://assets.payrails.io/img/logos";function nS(e=""){switch(e=e.trim().split(/\s+/).join("").toLowerCase()){case"adyen-old":e="adyen";break;case"checkout.com":e="checkout";break;case"visaoffersplatform":e="visa";break;case"bankAccount":e="banktransfer"}return"card"!==e?`${nT}/${e}/logo.svg`:`${nT}/card/credit-card-regular.svg`}class nP extends nv{constructor(){super(...arguments),this.buttonShown=!1}activate(){var e,t;if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0;let i=this.element.querySelector(this.component.selector);i&&(i.style.display="block"),null==(t=null==(e=this.events)?void 0:e.onPaymentOptionVisibilityChange)||t.call(e)}deactivate(){if(!this.isActive)return;this.isActive=!1,this.applyBaseStyles();let e=this.element.querySelector(this.component.selector);e&&(e.style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null==(t=null==(e=this.events)?void 0:e.onAvailable)||t.call(e)}mount(e){let t=document.querySelector(e);
15if(!t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw ti.PayrailsLogger.error(e.message,{error:e}),e}let 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}`))||e.remove()}}class nb extends nP{constructor(e){var t,i;super("apple-pay-dropin",(null==(i=null==(t=e.translations)?void 0:t.labels)?void 0:i.label)||"Apple Pay",e.showPaymentMethodLogo?nS("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new i5(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class nN extends nv{constructor(e,t,i){var n,s;super("payrails-credit-card-wrapper",(null==(s=null==(n=i.translations)?void 0:n.labels)?void 0:s.label)||"Card",i.showPaymentMethodLogo?nS("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new nw(e,t)}activate(){var e,t,i;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null==(e=this.component)||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.onActivate)&&this.events.onActivate(),(null==(i=this.events)?void 0:i.onPaymentOptionVisibilityChange)&&this.events.onPaymentOptionVisibilityChange())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null==(e=this.events)?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class nw extends i3{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class nD{constructor(e,t,i,n=e5.THREE_DS){this.link=e,this.paymentExecutor=t,this.options=i,this.type=n,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,450]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===e5.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;{let e=document.createElement("div");e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popupCancelButton(){let e=document.createElement("button");return e.setAttribute("id","payrails-popup-cancel-button"),e.setAttribute("type","button"),e.setAttribute("aria-label","Close"),e.addEventListener("click",()=>{t8.getEventBus().emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),sd(e8.AUTHORIZE,this.options.events,{code:te.USER_CANCELLED,message:"User cancelled the authorization."}),this.unmount()}),e}get popup(){let e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),!0===this.options.showCancelButton&&e.appendChild(this.popupCancelButton),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){let 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.setAttribute("allow","clipboard-write; clipboard-read"),e}handleMessages(){let e=t=>s(this,void 0,void 0,function*(){var i,n,s,o,r;if(t.data&&'{"type":"3DS-challenge-completed"}'===t.data){window.removeEventListener("message",e);let t=yield this.paymentExecutor.pollForAuthorizationResult(t4.url);switch(null==(i=t.finalState)?void 0:i.code){case"authorizeSuccessful":sc(e8.AUTHORIZE,this.options.events);break;case"authorizePending":sh(e8.AUTHORIZE,this.options.events);break;default:sd(e8.AUTHORIZE,this.options.events,{code:te.AUTHORIZATION_ERROR,message:(null==(r=null==(o=null==(s=null==(n=t.finalState)?void 0:n.errors)?void 0:s[0])?void 0:o.reason)?void 0:r.result)||"Authorization failed after 3DS challenge."})}this.unmount()}});window.addEventListener("message",e)}mount(){var e;
15this.popup.remove(),null==(e=document.querySelector("body"))||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}(O=e5||(e5={}))[O.THREE_DS=0]="THREE_DS",O[O.GENERIC_REDIRECT=1]="GENERIC_REDIRECT";let nM="https://assets.payrails.io/img/logos/revolutpay/button",nk={backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"contain",backgroundColor:"transparent",fontSize:"0",color:"transparent",padding:"0",display:"block",maxWidth:"100%",margin:"0 auto",aspectRatio:"250 / 44",border:"none",cursor:"pointer",transition:"opacity 0.2s ease"},nY={dark:{base:{backgroundImage:`url(${nM}/dark/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#191C1F",color:"#FFFFFF"}},light:{base:{backgroundImage:`url(${nM}/white/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#FFFFFF",color:"#191C1F"}},lightOutline:{base:{backgroundImage:`url(${nM}/outline/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#FFFFFF",color:"#191C1F"}}};function nU(e){var t;let i=null==e?void 0:e.theme,n=nY[i&&i in nY?i:"lightOutline"],s={width:null!=(t=null==e?void 0:e.width)?t:"250px"};return(null==e?void 0:e.borderRadius)&&(s.borderRadius=e.borderRadius),{base:Object.assign(Object.assign(Object.assign({},nk),null==n?void 0:n.base),s),hover:Object.assign({},null==n?void 0:n.hover),loading:Object.assign(Object.assign({},null==n?void 0:n.loading),s)}}let nx="__PAYRAILS__TAB_MANUAL_CLOSE_ERROR__",nj="Generic redirect",nF={pix:75e4,modo:6e5},nB={showCancelButton:!0};class nV extends i3{constructor(e,t){var i,n,s;super("button",{id:`payrails-generic-redirect-${e.paymentMethod.paymentMethodCode}`,className:"payrails-generic-button"}),this.returnInfo=t,this.popup=null,this.isDisabled=!1,this.isLoading=!1,this.isRevolutPay=e.paymentMethod.paymentMethodCode===b.REVOLUT_PAY,this.options=Object.assign(Object.assign({},e),{styles:this.isRevolutPay?nU(e.styles):e.styles,translations:this.isRevolutPay?{label:"Pay with Revolut Pay"}:e.translations}),this.element.innerText=null!=(n=null==(i=this.options.translations)?void 0:i.label)?n:nj,(null==(s=this.options.styles)?void 0:s.base)&&this.setStyles(this.options.styles.base),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",()=>{var e;!this.isDisabled&&(null==(e=this.options.styles)?void 0:e.hover)&&this.setStyles(this.options.styles.hover)}),this.element.addEventListener("mouseleave",()=>{var e;!this.isDisabled&&(null==(e=this.options.styles)?void 0:e.hover)&&this.removeStyles(this.options.styles.hover)}),this.paymentExecutor=new iq(this.returnInfo),this.eventBus.on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>{this.triggerLoading(!1)})}setStyles(e){var t;let i=Object.assign(Object.assign({},null==(t=this.options.styles)?void 0:t.base),e);
15Object.keys(i).forEach(e=>{this.element.style[e]=i[e]})}removeStyles(e){var t;let i=Object.keys((null==(t=this.options.styles)?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.base)?void 0:n[e]:this.element.style[e]=""})}triggerLoading(e){var t,i,n,s;this.isDisabled=e,this.isLoading=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.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null!=(n=null==(i=this.options.translations)?void 0:i.label)?n:nj,this.removeStyles((null==(s=this.options.styles)?void 0:s.loading)||{}))}isSafari(){let e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")&&!e.includes("chromium")}onClick(){return s(this,void 0,void 0,function*(){var e,t;if(this.isDisabled)return;let i=null;this.options.openInNewTab&&this.isSafari()&&(i=window.open("","_blank"));try{if(this.triggerLoading(!0),!(yield sp(e8.AUTHORIZE,null!=(e=this.options.events)?e:{})))return this.triggerLoading(!1),void(i&&!i.closed&&i.close());let n=null==(t=t4.availablePaymentMethods.find(({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode))?void 0:t.integrationType;if(!n)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);let s=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:n,amount:t6.getInstance().config.amount}]),{action:o,link:r}=this.handleAuthorizationResult(s);if("redirect"!==o)return void(i&&!i.closed&&i.close());if(!r)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Object.keys(nF).includes(this.options.paymentMethod.paymentMethodCode)){i&&!i.closed&&i.close();let e=nF[this.options.paymentMethod.paymentMethodCode],t=Math.ceil((e-2e4)/2e3);return new iq(this.returnInfo,2e3,t,2e4).pollForAuthorizationResult(t4.url,0,["authorizeSuccessful","authorizeFailed"]).then(e=>{var t;this.handleAuthorizationResult(e),null==(t=this.popup)||t.unmount()}),this.createPopupWithTimeout(r,e)}return this.redirectToPaymentLink(r,i)}catch(e){i&&!i.closed&&i.close(),e instanceof tt.PayrailsError&&ti.PayrailsLogger.error(e.message,{error:e}),sd(e8.AUTHORIZE,this.options.events),this.triggerLoading(!1)}finally{this.isLoading||this.triggerLoading(!1)}})}handleAuthorizationResult(e){var t,i;if("authorizePending"===(null==(t=null==e?void 0:e.finalState)?void 0:t.code)){let t=e.response.links.redirect;if(!t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return{code:"authorizePending",link:t,action:"redirect"}}return"authorizeSuccessful"===(null==(i=null==e?void 0:e.finalState)?void 0:i.code)?(sc(e8.AUTHORIZE,this.options.events),{code:"authorizeSuccessful",action:"success"}):(sd(e8.AUTHORIZE,this.options.events,e),this.triggerLoading(!1),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise(()=>{let i=new nD(e,this.paymentExecutor,Object.assign(Object.assign({},this.options),nB));this.popup=i,this.popup.mount(),setTimeout(()=>{null==i||i.unmount(),sd(e8.AUTHORIZE,this.options.events),this.triggerLoading(!1)},t)})}redirectToPaymentLink(e,t=null){return new Promise(i=>{if(this.options.openInNewTab){let n=t||window.open(e,"_blank");if(!n||n.closed||void 0===n.closed){ti.PayrailsLogger.warn("Popup blocked. Falling back to same tab redirect."),window.location.href=e;let t=setTimeout(()=>{var e;sd(e8.AUTHORIZE,this.options.events),(null==(e=this.returnInfo)?void 0:e.error)?window.location.href=this.returnInfo.error:(this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}))},6e4);return window.addEventListener("pagehide",()=>{clearTimeout(t)}),void i()}t&&(n.location.href=e),this.monitorRedirectInNewTab(n).finally(()=>{i()})}else{window.location.href=e;let t=setTimeout(()=>{var e;sd(e8.AUTHORIZE,this.options.events),(null==(e=this.returnInfo)?void 0:e.error)?window.location.href=this.returnInfo.error:(this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}))},6e4);window.addEventListener("pagehide",()=>{clearTimeout(t)}),i()}})}monitorRedirectInNewTab(e){return s(this,void 0,void 0,function*(){var t,i,n,s,o,r;let a;try{a=t4.url}catch(n){return ti.PayrailsLogger.error("Unable to resolve workflow execution URL.",{error:n}),this.triggerLoading(!1),e.closed||e.close(),void(null==(i=null==(t=this.options.events)?void 0:t.onAuthorizeFailed)||i.call(t,{code:te.UNKNOWN_ERROR,message:"Unable to resolve workflow execution URL.",rawError:n}))}let l=new iq(this.returnInfo),c=new AbortController,{promise:d,cleanup:u}=this.watchTabClosure(e,()=>{c.signal.aborted||c.abort(nx),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{})});try{let e=yield Promise.race([l.pollForAuthorizationResult(a,0,["authorizeSuccessful","authorizeFailed"],{signal:c.signal}),d]);c.signal.aborted||c.abort("authorization-completed"),this.handleAuthorizationResult(e)}catch(e){if(c.signal.aborted||c.abort(e),e===nx){try{let e=new iq(this.returnInfo,1e3,3,0),t=yield e.pollForAuthorizationResult(a,0,["authorizeSuccessful","authorizeFailed"]);return void this.handleAuthorizationResult(t)}catch(e){}null==(s=null==(n=this.options.events)?void 0:n.onAuthorizeFailed)||s.call(n,{code:te.USER_CANCELLED,message:"User closed the payment window before completion."})}else ti.PayrailsLogger.error("Failed to retrieve authorization result after redirect.",{error:e}),null==(r=null==(o=this.options.events)?void 0:o.onAuthorizeFailed)||r.call(o,{code:te.UNKNOWN_ERROR,message:"Failed to retrieve authorization result after redirect.",rawError:e})}finally{c.signal.aborted||c.abort("cleanup"),u(),e.closed||e.close(),this.triggerLoading(!1)}})}watchTabClosure(e,t){let i,n=!0,s=()=>{void 0!==i&&(window.clearInterval(i),i=void 0),n=!1};return{promise:new Promise((o,r)=>{i=window.setInterval(()=>{if(!n)return;let i=!1;try{i=e.closed}catch(e){i=!0}i&&(s(),null==t||t(),r(nx))},500)}),cleanup:s}}updateStyles(e){var t,i;this.isRevolutPay?this.options.styles=nU(e):this.options.styles=Object.assign(Object.assign({},this.options.styles||{}),e),this.isLoading?this.setStyles((null==(t=this.options.styles)?void 0:t.loading)||{}):this.setStyles((null==(i=this.options.styles)?void 0:i.base)||{})}updateTranslations(e){var t,i;this.isRevolutPay||(this.options.translations=Object.assign(Object.assign({},this.options.translations||{}),e),this.element.innerText=null!=(i=null==(t=this.options.translations)?void 0:t.label)?i:nj)}updateEvents(e){this.options.events=Object.assign(Object.assign({},this.options.events||{}),e)}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations),e.events&&this.updateEvents(e.events)}}let nX=e=>e===b.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};
15class nz extends nv{constructor(e,t){var i,n,s,o,r,a;super(`payrails-${e.paymentMethod.paymentMethodCode}-dropin-element`,(null==(i=null==e?void 0:e.translations)?void 0:i.label)||nX(e.paymentMethod.paymentMethodCode).translations.label,(null==(n=e.config)?void 0:n.showPaymentMethodLogo)?nS(e.paymentMethod.paymentMethodCode):void 0,null==e?void 0:e.events,null==(s=null==e?void 0:e.styles)?void 0:s.element),this.returnInfo=t,this.component=new nV({styles:null==(o=null==e?void 0:e.styles)?void 0:o.button,translations:(null==(r=null==e?void 0:e.translations)?void 0:r.button)||nX(e.paymentMethod.paymentMethodCode).translations.button,events:null==e?void 0:e.events,paymentMethod:e.paymentMethod,openInNewTab:null==(a=e.config)?void 0:a.openInNewTab},this.returnInfo)}}class nG{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(e){var t,i,n;try{null==(i=null==(t=this.options.events)?void 0:t.onThreeDSecureChallenge)||i.call(t)}catch(e){}let s=null==(n=null==e?void 0:e.response)?void 0:n.links["3ds"];s&&(this.options.redirectFor3DS?window.location.assign(s):new nD(s,this.paymentExecutor,this.options).mount())}}let nH={apiVersion:2,apiVersionMinor:0},nW=new Set(["BHD","IQD","JOD","KWD","LYD","OMR","TND"]);class n$ extends i6{static getGooglePayConfigAsArray(e){return Array.isArray(e)?e:e.allowedPaymentMethods?e.allowedPaymentMethods:[]}static getSDKClient(){return s(this,arguments,void 0,function*(e=e7.TEST,t){return yield iQ.load(e2.GooglePay),n$.googleSDKClient||(n$.googleSDKClient=new google.payments.api.PaymentsClient({environment:e,merchantInfo:t})),n$.googleSDKClient})}static isGooglePayAvailable(e){return s(this,arguments,void 0,function*(e,t=e7.TEST,i){try{let n=yield n$.getSDKClient(t,i),s=n$.getGooglePayConfigAsArray(e),o=Object.assign(Object.assign(Object.assign({},nH),{allowedPaymentMethods:s}),!Array.isArray(e)&&void 0!==e.existingPaymentMethodRequired&&{existingPaymentMethodRequired:e.existingPaymentMethodRequired}),{result:r}=yield n.isReadyToPay(o);return r}catch(e){return!1}})}constructor(e){var t;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${tH()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.sdkLoadedCalled=!1,this.isProcessing=!1,this.buttonElement=null,this.paymentExecutor=new iq(null==(t=this.options)?void 0:t.returnInfo),n$.isGooglePayAvailable(t4.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.events)?void 0:i.onGooglePayAvailable)||n.call(i))}),this.action="tokenization"===t6.getInstance().config.type?e8.TOKENIZE:e8.AUTHORIZE}sdkLoaded(e){return s(this,void 0,void 0,function*(){var t,i,n,o,r,a,l,c,d,u,h,p;if(this.sdkLoadedCalled)return this.buttonElement;this.sdkLoadedCalled=!0;let _=(null==(i=null==(t=this.options)?void 0:t.styles)?void 0:i.buttonColor)||"black",m=(null==(o=null==(n=this.options)?void 0:n.styles)?void 0:o.buttonType)||"long",E=(null==(a=null==(r=this.options)?void 0:r.styles)?void 0:a.buttonSizeMode)||"fill";(null==(c=null==(l=this.options)?void 0:l.styles)?void 0:c.buttonLocale)&&console.warn("Payrails: styles.buttonLocale is deprecated and will be removed in a future release. Use styles.locale instead.");let y=(null==(u=null==(d=this.options)?void 0:d.styles)?void 0:u.locale)||(null==(p=null==(h=this.options)?void 0:h.styles)?void 0:p.buttonLocale),v=y?i2(y).replace("_","-").split("-")[0]:void 0,I=n$.getGooglePayConfigAsArray(t4.googlePayConfig);return this.buttonElement=e.createButton({buttonColor:_,buttonType:m,buttonSizeMode:E,buttonLocale:v,onClick:()=>s(this,void 0,void 0,function*(){this.isProcessing||(this.isProcessing=!0,(yield sp(this.action,this.options.events))?yield this.authorize(e):this.isProcessing=!1)}),allowedPaymentMethods:I}),this.element.appendChild(this.buttonElement),this.buttonElement})}authorize(e){return s(this,void 0,void 0,function*(){var t,i,n,s,o,r,a,l;let c=t4.googlePayConfig,d=!Array.isArray(c),u=t6.getInstance().config.amount,h=null==(s=null==(n=null==(i=null==(t=t4.meta)?void 0:t.order)?void 0:i.billingAddress)?void 0:n.country)?void 0:s.code,p=!!(null==u?void 0:u.currency)&&nW.has(u.currency);p&&ti.PayrailsLogger.debug(`Payrails: 3-decimal currency ${null==u?void 0:u.currency}, omitting totalPrice`);let _=Object.assign(Object.assign({},d&&void 0!==c.apiVersion?{apiVersion:c.apiVersion,apiVersionMinor:c.apiVersionMinor}:nH),{allowedPaymentMethods:n$.getGooglePayConfigAsArray(c),transactionInfo:p?{totalPriceStatus:"NOT_CURRENTLY_KNOWN",currencyCode:null==u?void 0:u.currency,countryCode:h}:{totalPriceStatus:"FINAL",totalPrice:null==u?void 0:u.value,currencyCode:null==u?void 0:u.currency,countryCode:h},merchantInfo:{merchantId:(null==(o=c.merchantInfo)?void 0:o.merchantId)||(null==(r=this.options.merchantInfo)?void 0:r.merchantId)||"",merchantName:(null==(a=c.merchantInfo)?void 0:a.merchantName)||(null==(l=this.options.merchantInfo)?void 0:l.merchantName)||""}});d&&(void 0!==c.emailRequired&&(_.emailRequired=c.emailRequired),void 0!==c.shippingAddressRequired&&(_.shippingAddressRequired=c.shippingAddressRequired),c.shippingAddressParameters&&(_.shippingAddressParameters=c.shippingAddressParameters));try{let t=yield e.loadPaymentData(_);yield this.onLoadPaymentData(t)}catch(e){this.isProcessing=!1,sd(this.action,this.options.events,e)}})}onLoadPaymentData(e){return s(this,void 0,void 0,function*(){(yield iG(this.action,this.options.events))&&(this.action===e8.TOKENIZE?yield this.doTokenize(e):yield this.doAuthorizePayment(e)),this.isProcessing=!1})}doTokenize(e){return s(this,void 0,void 0,function*(){let t,i=t6.getInstance().config,n=t4.createInstrumentLink,s=i.token;if(!n)return this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events);try{t=JSON.stringify(e)}catch(e){return this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events,e)}let o={holderReference:i.holderReference,paymentMethod:b.GOOGLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:t}};try{let e=yield t1({url:n,token:s,body:o});return e.ok?(this.isProcessing=!1,sc(e8.TOKENIZE,this.options.events,e.res),e.res):(this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events))}catch(e){return this.isProcessing=!1,void sd(e8.TOKENIZE,this.options.events,e)}})}doAuthorizePayment(e){return s(this,void 0,void 0,function*(){var t,i,n,s,o,r;let a={paymentToken:JSON.stringify(e)},l=[{paymentMethodCode:b.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:a,amount:t6.getInstance().config.amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(l);"authorizePending"===(null==(t=null==c?void 0:c.finalState)?void 0:t.code)?new nG(this.options,this.paymentExecutor).handle3ds(c):"authorizeSuccessful"===(null==(i=null==c?void 0:c.finalState)?void 0:i.code)?sc(e8.AUTHORIZE,this.options.events):sd(e8.AUTHORIZE,this.options.events,{code:te.AUTHORIZATION_ERROR,message:(null==(r=null==(o=null==(s=null==(n=c.finalState)?void 0:n.errors)?void 0:s[0])?void 0:o.reason)?void 0:r.result)||"Authorization Failed"})})}mount(e){super.mount(e),s(this,void 0,void 0,function*(){var e;try{if(yield n$.isGooglePayAvailable(t4.googlePayConfig,this.options.environment,this.options.merchantInfo)){let t=yield n$.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null==(e=this.storeInstrumentCheckbox)||e.mount(this.selector)}}catch(e){}})}unmount(){var e;null==(e=this.storeInstrumentCheckbox)||e.unmount(),this.buttonElement=null,super.unmount()}}n$.googleSDKClient=null;class nq extends nP{constructor(e){var t,i;super("google-pay-dropin",(null==(i=null==(t=e.translations)?void 0:t.labels)?void 0:i.label)||"Google Pay",e.showPaymentMethodLogo?nS("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new n$(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}let nK="Pay by bank with Al Tareq";(C=e9||(e9={})).SUCCESS="success",C.ERROR="error",C.CANCELLED="cancelled";class nZ extends i3{constructor(e){var t,i,n,s,o,r,a;super("button",{id:e.id||"payrails-lean-button",className:"payrails-lean-button",styles:null!=(n=null==(i=null==(t=e.styles)?void 0:t.button)?void 0:i.base)?n:{}}),this.isLoading=!1,this.handleClick=()=>{this.onClick()},this.handleMouseEnter=()=>{var e,t;(null==(t=null==(e=this.options.styles)?void 0:e.button)?void 0:t.hover)&&this.setStyles(this.options.styles.button.hover)},this.handleMouseLeave=()=>{var e,t;(null==(t=null==(e=this.options.styles)?void 0:e.button)?void 0:t.hover)&&this.removeStyles(this.options.styles.button.hover)},this.handleSessionExpired=()=>{this.triggerLoading(!1)},this.options=e,this.paymentExecutor=new iq(null==(s=this.options)?void 0:s.returnInfo),this.element.innerText=(null==(o=e.translations)?void 0:o.label)||nK,this.setStyles((null==(a=null==(r=this.options.styles)?void 0:r.button)?void 0:a.base)||{})}mount(e){this.unmount(),super.mount(e),this.bindEvents(),nZ.preloadLeanSDK()}unmount(){this.unbindEvents(),super.unmount()}static initializeLeanSDK(){return window.Lean||nZ.leanSdkClient||(nZ.leanSdkClient=iQ.load(e2.Lean)),nZ.leanSdkClient}static preloadLeanSDK(){let e=nZ.initializeLeanSDK();null==e||e.catch(()=>{nZ.leanSdkClient===e&&(nZ.leanSdkClient=null)})}static getLeanSDK(){return s(this,void 0,void 0,function*(){nZ.initializeLeanSDK();try{yield nZ.leanSdkClient}catch(e){throw nZ.leanSdkClient=null,e}let e=window.Lean;if(!e)throw nZ.leanSdkClient=null,iQ.invalidate(e2.Lean),new tt.PayrailsError(tt.ER
15ROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:"Lean SDK is not available"});return e})}static resetLeanSDK(){nZ.leanSdkClient=null}bindEvents(){this.element.addEventListener("click",this.handleClick),this.element.addEventListener("mouseenter",this.handleMouseEnter),this.element.addEventListener("mouseleave",this.handleMouseLeave),this.eventBus.on("PAYRAILS_CLIENT_SESSION_EXPIRED",this.handleSessionExpired)}unbindEvents(){var e,t;this.element.removeEventListener("click",this.handleClick),this.element.removeEventListener("mouseenter",this.handleMouseEnter),this.element.removeEventListener("mouseleave",this.handleMouseLeave),null==(t=(e=this.eventBus).off)||t.call(e,"PAYRAILS_CLIENT_SESSION_EXPIRED",this.handleSessionExpired)}setStyles(e){var t,i;let n=Object.assign(Object.assign({},null==(i=null==(t=this.options.styles)?void 0:t.button)?void 0:i.base),e);Object.keys(n).forEach(e=>{this.element.style[e]=n[e]})}removeStyles(e){var t,i;let n=Object.keys((null==(i=null==(t=this.options.styles)?void 0:t.button)?void 0:i.base)||{});Object.keys(e).forEach(e=>{var t,i,s;n.includes(e)?this.element.style[e]=null==(s=null==(i=null==(t=this.options.styles)?void 0:t.button)?void 0:i.base)?void 0:s[e]:this.element.style[e]=""})}triggerLoading(e){var t,i,n,s,o;this.isLoading=e,e?(this.element.innerHTML=this.renderLoadingMarkup(),(null==(i=null==(t=this.options.styles)?void 0:t.button)?void 0:i.loading)&&this.setStyles(this.options.styles.button.loading)):(this.element.innerText=(null==(n=this.options.translations)?void 0:n.label)||nK,this.removeStyles((null==(o=null==(s=this.options.styles)?void 0:s.button)?void 0:o.loading)||{}))}renderLoadingMarkup(){return'<div class="dot-flashing-container">  <div class="dot-flashing"></div>  <span class="dot-flashing-text" aria-hidden="true">Loading</span></div>'}getConfirmActionParameters(e){var t,i,n;let s=null==(n=null==(i=null==(t=e.response)?void 0:t.links)?void 0:i.confirm)?void 0:n.action;if(!((null==s?void 0:s.paymentId)&&(null==s?void 0:s.appToken)&&(null==s?void 0:s.sdkToken)&&(null==s?void 0:s.successUrl)&&(null==s?void 0:s.failureUrl)))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:"Lean payment parameters are missing from authorize polling response."});return{appToken:s.appToken,paymentId:s.paymentId,sdkToken:s.sdkToken,successUrl:s.successUrl,failureUrl:s.failureUrl,sandbox:s.sandbox}}startLeanCheckout(e,t){return s(this,void 0,void 0,function*(){return new Promise(i=>{var n;let s=this.toLeanCustomizationPayload(null==(n=this.options.styles)?void 0:n.dialog);e.checkout(Object.assign(Object.assign({app_token:t.appToken,access_token:t.sdkToken,payment_intent_id:t.paymentId,success_redirect_url:t.successUrl,fail_redirect_url:t.failureUrl},void 0!==t.sandbox?{sandbox:t.sandbox}:{}),{customization:s,callback:e=>{try{this.handleLeanCheckoutResponse(e)}finally{this.triggerLoading(!1),i()}}}))})})}handleLeanCheckoutResponse(e){var t;switch(null==(t=null==e?void 0:e.status)?void 0:t.toLowerCase()){case e9.SUCCESS:return void sc(e8.AUTHORIZE,this.options.events,e);case e9.ERROR:case e9.CANCELLED:return this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),void sd(e8.AUTHORIZE,this.options.events,e)}}toLeanCustomizationPayload(e){if(!e)return;let{themeColor:t,buttonTextColor:i,buttonBorderRadius:n,linkColor:s,overlayColor:o}=e;return{theme_color:t,button_text_color:i,button_border_radius:n,link_color:s,overlay_color:o}}onClick(){return s(this,void 0,void 0,function*(){var e;if(!this.isLoading)try{if(this.triggerLoading(!0),!(yield sp(e8.AUTHORIZE,null!=(e=this.options.events)?e:{})))return void this.triggerLoading(!1);let t=yield nZ.getLeanSDK(),i=[{paymentMethodCode:b.LEAN,integrationType:"api",amount:t6.getInstance().config.amount,paymentInstrumentData:{},storeInstrument:!1}],n=yield this.paymentExecutor.pay(i),s=this.getConfirmActionParameters(n);yield this.startLeanCheckout(t,s),this.triggerLoading(!1)}catch(e){this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),sd(e8.AUTHORIZE,this.options.events,e)}})}}nZ.leanSdkClient=null;class nJ extends nv{constructor(e,t){var i;super("lean-dropin",(null==(i=e.translations)?void 0:i.label)||"Pay by bank with Al Tareq",void 0,e.events,e.elementStyles),this.returnInfo=t,this.component=new nZ(Object.assign(Object.assign({},e),{id:e.id||"payrails-lean-button-dropin",styles:e.styles,events:Object.assign({},e.events),returnInfo:this.returnInfo}))}}class nQ extends i6{constructor(e){var t;nQ.instance&&(nQ.instance=void 0);const i="express"===(null==(t=null==t4?void 0:t4.paypalConfig)?void 0:t.integrationMode),n=!i&&(null==e?void 0:e.showStoreInstrumentCheckbox),o=i?"unchecked":null==e?void 0:e.defaultStoreInstrumentState;super("div",Object.assign(Object.assign({},e),{showStoreInstrumentCheckbox:n,defaultStoreInstrumentState:o,id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==e?void 0:e.events),{onSaveInstrumentCheckboxChanged:t=>s(this,void 0,void 0,function*(){var i,n,s;null==(n=null==(i=null==e?void 0:e.events)?void 0:i.onSaveInstrumentCheckboxChanged)||n.call(i,t),null==(s=this.button)||s.close(),this.debouncedRender()})})})),this.options=e,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>s(this,void 0,void 0,function*(){var e,t,i,n,s;let o=[{paymentMethodCode:b.PAYPAL,integrationType:"api",amount:t6.getInstance().config.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],r=yield this.paymentExecutor.pay(o),a=null==(i=null==(t=null==(e=r.response.links.confirm)?void 0:e.action)?void 0:t.parameters)?void 0:i.orderId;if(!a)throw sd(e8.AUTHORIZE,null==(n=this.options)?void 0:n.events),new n0("No order id returned");return this.confirmLink=null==(s=r.response.links.confirm)?void 0:s.href,a}),this.loadPaypal().catch(()=>{}),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new iq}loadPaypal(){return s(this,void 0,void 0,function*(){let e=yield iQ.load(e2.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)})}debouncedRender(){return this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),new Promise(e=>{this.renderDebounceTimeout=setTimeout(()=>s(this,void 0,void 0,function*(){try{yield this.renderButton(),e()}catch(t){console.error("Failed to render PayPal button:",t),e()}}),300)})}get paypalScriptConfig(){var e,t;let i=this.shouldStoreInstrument?"tokenize":"Instant"===t4.paypalConfig.captureMode?"capture":"authorize";return Object.assign({clientId:t4.paypalConfig.clientId,intent:i,
15currency:t6.getInstance().config.amount.currency,vault:this.shouldStoreInstrument},(null==(t=null==(e=this.options)?void 0:e.styles)?void 0:t.locale)&&{locale:i2(this.options.styles.locale).replace("_","-").replace("-","_")})}createPaypalButton(e){return s(this,void 0,void 0,function*(){var t,i,n;if(!e.Buttons)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);let s=e.Buttons(this.createPayPalButtonConfig());return null==(n=null==(i=null==(t=this.options)?void 0:t.events)?void 0:i.onPaypalAvailable)||n.call(i),s})}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>s(this,void 0,void 0,function*(){var e,t,i,n;let s=[{paymentMethodCode:b.PAYPAL,integrationType:"api",amount:t6.getInstance().config.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],o=yield this.paymentExecutor.pay(s);return this.confirmLink=null==(e=o.response.links.confirm)?void 0:e.href,(null==(n=null==(i=null==(t=o.response.links.confirm)?void 0:t.action)?void 0:i.parameters)?void 0:n.tokenId)||""})})}onCancel(){var e;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),sd(e8.AUTHORIZE,null==(e=this.options)?void 0:e.events)}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,t,i,n,o,r,a,l,c,d;return{fundingSource:"paypal",style:{color:(null==(t=null==(e=this.options)?void 0:e.styles)?void 0:t.color)||"gold",height:(null==(n=null==(i=this.options)?void 0:i.styles)?void 0:n.height)||40,label:(null==(r=null==(o=this.options)?void 0:o.styles)?void 0:r.label)||"paypal",shape:(null==(l=null==(a=this.options)?void 0:a.styles)?void 0:l.shape)||"rect",tagline:(null==(d=null==(c=this.options)?void 0:c.styles)?void 0:d.tagline)||!1,disableMaxWidth:!0},onError:e=>{var t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),sd(e8.AUTHORIZE,null==(t=this.options)?void 0:t.events,e)},onClick:(e,t)=>s(this,void 0,void 0,function*(){var e;return(yield sp(e8.AUTHORIZE,null==(e=this.options)?void 0:e.events))?t.resolve():t.reject()}),onCancel:this.onCancel.bind(this),onShippingAddressChange:(e,t)=>
15s(this,void 0,void 0,function*(){var i;let n,o,r;if(e.shippingAddress&&(n={deliveryAddress:{city:e.shippingAddress.city,postalCode:e.shippingAddress.postalCode,state:e.shippingAddress.state,country:{code:e.shippingAddress.countryCode}}}),!(yield(o=null==(i=this.options)?void 0:i.events,r=n,s(void 0,void 0,void 0,function*(){if(null==o?void 0:o.onDeliveryAddressChanged)try{let e=yield o.onDeliveryAddressChanged(r);if(!e){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged resolved to false"});return ti.PayrailsLogger.error(e.message,{error:e}),!1}return e}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged threw an error",cause:t});return ti.PayrailsLogger.error(e.message,{error:e}),!1}return!0}))))return t.reject()})}}approvePayment(e){return s(this,void 0,void 0,function*(){var t,i,n,s,o,r,a,l,c;if(!this.confirmLink)throw sd(e8.AUTHORIZE,null==(t=this.options)?void 0:t.events),new n0("No confirm link");let d={};if(this.shouldStoreInstrument&&e.billingToken&&(d.tokenId=e.billingToken),this.fraudNetGuid&&(d.riskSessionCorrelationId=this.fraudNetGuid),!(yield iG(e8.AUTHORIZE,null==(i=this.options)?void 0:i.events)))throw new n0("Authorization request start validation failed");let u=yield this.paymentExecutor.confirm(this.confirmLink,d);"authorizeSuccessful"===(null==(n=u.finalState)?void 0:n.code)?sc(e8.AUTHORIZE,null==(s=this.options)?void 0:s.events):sd(e8.AUTHORIZE,null==(o=this.options)?void 0:o.events,{code:te.AUTHORIZATION_ERROR,message:(null==(c=null==(l=null==(a=null==(r=u.finalState)?void 0:r.errors)?void 0:a[0])?void 0:l.reason)?void 0:c.result)||"Authorization Failed"})})}get fraudNetGuid(){var e,t;return null==(t=null==(e=window.PayrailsData)?void 0:e.riskIds)?void 0:t.fraudNet}mount(e){nQ.instance||(super.mount(e),nQ.instance=this,s(this,void 0,void 0,function*(){yield this.debouncedRender()}))}renderButton(){return s(this,void 0,void 0,function*(){var e;this.isRendering&&this.currentAbortController&&this.currentAbortController.abort(),this.currentAbortController=new AbortController;let t=this.currentAbortController.signal;try{this.isRendering=!0,this.button&&(this.button.close(),this.button=void 0);let i=yield Promise.race([this.loadPaypal(),new Promise((e,i)=>{t.addEventListener("abort",()=>i(new n1("PayPal button loading aborted")))})]);if(t.aborted)return;i&&(this.button=i,yield null==(e=this.button)?void 0:e.render(`#${this.buttonWrapperId}`))}catch(e){if(!t.aborted)throw e}finally{t.aborted||(this.isRendering=!1,this.currentAbortController=null)}})}unmount(){var e;this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),null==(e=this.button)||e.close(),this.isRendering=!1,nQ.instance=void 0,super.unmount()}}class n0 extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class n1 extends tt.PayrailsError{constructor(e,t){super(tt.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class n2 extends nP{constructor(e){var t,i;super("payrails-paypal-button-dropin",(null==(i=null==(t=null==e?void 0:e.translations)?void 0:t.labels)?void 0:i.label)||"PayPal",(null==e?void 0:e.showPaymentMethodLogo)?nS("paypal"):void 0,{onActivate:()=>{var t;super.activate(),(null==(t=null==e?void 0:e.events)?void 0:t.onPaymentOptionVisibilityChange)&&e.events.onPaymentOptionVisibilityChange()}},null==e?void 0:e.styles),this.loadElementId="paypal-dropin-load-element",this.component=new nQ(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class n3 extends i3{constructor(e,t,i){var n,s,o;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.applyStyles(),void 0!==(null==(s=null==(n=this.dropinConfig.paymentMethodsConfiguration)?void 0:n.cards)?void 0:s.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const r=new Map;
15t4.storedDropinInstruments.forEach(e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();let t=this.createStoredInstrumentElement(e);t&&r.set(t.identifier,t)}});const a={[b.CARD]:this.createCreditCardButton.bind(this),[b.PAYPAL]:this.createPayPalButton.bind(this),[b.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[b.APPLE_PAY]:this.createApplePayButton.bind(this),[b.LEAN]:this.createLeanButton.bind(this)};t4.availablePaymentMethods.forEach(e=>{let t=e.paymentMethodCode;if(t&&a[t]){let i=(0,a[t])(t4.getPaymentMethodConfig(e));r.set(i.identifier,i)}else if(this.isHppIntegration(e)&&t){let t=this.createHppIntegrationElement(e);r.set(t.identifier,t)}}),this.element.addEventListener("change",e=>{var t,i;let n=(null==(t=null==e?void 0:e.target)?void 0:t.value)||"";r.forEach(e=>{e.deactivate()}),null==(i=r.get(n))||i.activate()}),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(r.values())),this.loadingScreen=new nR({styles:null==(o=this.dropinConfig.styles)?void 0:o.loadingScreen})}get returnInfo(){return this.dropinConfig.returnInfo||this.clientConfig.returnInfo}isHppIntegration(e){var t;return e.paymentMethodCode===b.GENERIC_REDIRECT||(null==(t=e.clientConfig)?void 0:t.flow)===w.REDIRECT}createStoredInstrumentElement(e){var t;let i;if(this.cardPaymentButton=this.createCardPaymentButton(),e.paymentMethod!==b.BANK_ACCOUNT)return e.paymentMethod===b.CARD&&t4.isPaymentInstallmentsEnabled(e.paymentMethod)&&(i=this.createInstallmentsDropdown(e)),new nf(e,this.cardPaymentButton,e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;let n=t4.getPaymentMethodForStoredInstrument(e);null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:n,instrument:e})}},null==(t=this.dropinConfig.styles)?void 0:t.element,i)}createInstallmentsDropdown(e){var t,i,n;let s=this.getInstallmentOptionsForInstrument(e);return new na("span",{installmentConfig:{installmentCurrency:t6.getInstance().config.amount.currency,installmentOptions:s,defaultInstallment:null==(n=null==(i=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.cards)?void 0:i.installmentConfig)?void 0:n.defaultInstallment},id:`payrails-card-form-payment-installments-${e.id}`,className:"payrails-card-form-payment-installments-container"})}getInstallmentOptionsForInstrument(e){var t,i,n;let s=e.paymentMethod,o=t4.getPaymentInstallmentOptions(s),r=null==(n=null==(i=null==(t=null==e?void 0:e.data)?void 0:t.binLookup)?void 0:i.issuerCountry)?void 0:n.code;return r?o[r]:null}updateInstallmentConfig(e){var t,i,n;let s=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.cards;s&&e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(s.installmentConfig={defaultInstallment:null!=(i=e.defaultInstallment)?i:null}),null==(n=this.cardForm)||n.updateInstallmentConfig(e),this.subElements.forEach(t=>{t instanceof nf&&t.updateInstallmentConfig(e)})}createHppIntegrationElement(e){var t,i,n,s,o,r,a,l,c,d,u,h;let p=e.paymentMethodCode;if(!p){let t=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw ti.PayrailsLogger.error(t.message,{error:t}),t}return new nz({paymentMethod:e,config:Object.assign(Object.assign({},null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t[p]),{showPaymentMethodLogo:null!=(r=null!=(s=null==(n=null==(i=this.dropinConfig.paymentMethodsConfiguration)?void 0:i[p])?void 0:n.showPaymentMethodLogo)?s:null==(o=this.dropinConfig.paymentMethodsConfiguration)?void 0:o.showPaymentMethodLogo)&&r}),styles:{element:null==(l=null==(a=this.dropinConfig)?void 0:a.styles)?void 0:l.element,button:null==(u=null==(d=null==(c=this.dropinConfig)?void 0:c.styles)?void 0:d[p])?void 0:u.button},translations:null==(h=this.dropinConfig.translations)?void 0:h[p],events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:e})}})},this.returnInfo)}get totalPaymentOptions(){return t4.availablePaymentMethods.length+t4.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,s,o,r,a;return this.creditCard=new nN(this.createCardForm(),this.createCardPaymentButton(),{events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:e})}}),styles:null==(t=this.dropinConfig.styles)?void 0:t.element,showPaymentMethodLogo:null!=(r=null!=(s=null==(n=null==(i=this.dropinConfig.paymentMethodsConfiguration)?void 0:i.cards)?void 0:n.showPaymentMethodLogo)?s:null==(o=this.dropinConfig.paymentMethodsConfiguration)?void 0:o.showPaymentMethodLogo)&&r,translations:null==(a=this.dropinConfig.translations)?void 0:a.cardForm}),this.creditCard}createGooglePayButton(e){var t,i,n,s,o,r,a,l;return this.googlePay=new nq(Object.assign({environment:this.clientConfig.environment||e7.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:e})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null!=(o=null!=(n=null==(i=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.googlePay)?void 0:i.showPaymentMethodLogo)?n:null==(s=this.dropinConfig.paymentMethodsConfiguration)?void 0:s.showPaymentMethodLogo)&&o,styles:Object.assign(Object.assign({},null==(r=this.dropinConfig.styles)?void 0:r.googlePayButton),null==(a=this.dropinConfig.styles)?void 0:a.element),returnInfo:this.returnInfo},null==(l=this.dropinConfig.paymentMethodsConfiguration)?void 0:l.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n,s,o,r,a,l;return this.paypal=new n2(Object.assign(Object.assign({showPaymentMethodLogo:null!=(o=null!=(n=null==(i=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.payPal)?void 0:i.showPaymentMethodLogo)?n:null==(s=this.dropinConfig.paymentMethodsConfiguration)?void 0:s.showPaymentMethodLogo)&&o},null==(r=this.dropinConfig.paymentMethodsConfiguration)?void 0:r.payPal),{styles:Object.assign(Object.assign({},null==(a=this.dropinConfig.styles)?void 0:a.paypalButton),null==(l=this.dropinConfig.styles)?void 0:l.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:e})}})})),this.paypal}createLeanButton(e){var t,i,n,s;return this.lean=new nJ(Object.assign(Object.assign({paymentMethod:e},null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.lean),{styles:null==(i=this.dropinConfig.styles)?void 0:i.leanButton,elementStyles:null==(n=this.dropinConfig.styles)?void 0:n.element,translations:null==(s=this.dropinConfig.translations)?void 0:s.leanButton,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:e})}})}),this.returnInfo),this.lean}createCardForm(){var e,t,i,n,s,o,r,a;
15if(!this.cardForm){let l=null==(e=this.dropinConfig.paymentMethodsConfiguration)?void 0:e.cards,c=!!(null==l?void 0:l.showStoreInstrumentCheckbox),d=!!(null==l?void 0:l.showCardHolderName),u=!!(null==l?void 0:l.alwaysStoreInstrument),h=!!(null==l?void 0:l.showSingleExpiryDateField),p=(null==l?void 0:l.layout)||[];this.cardForm=new nE(this.collectContainer,{showStoreInstrumentCheckbox:c,showCardHolderName:d,showSingleExpiryDateField:h,alwaysStoreInstrument:u,installmentConfig:null==(i=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.cards)?void 0:i.installmentConfig,layout:p,translations:Object.assign(Object.assign({},null==(n=this.dropinConfig.translations)?void 0:n.cardForm),{addressSelector:null==(s=this.dropinConfig.translations)?void 0:s.addressSelector}),styles:Object.assign(Object.assign(Object.assign({},null==(o=this.dropinConfig.styles)?void 0:o.cardForm),null==(r=this.dropinConfig.styles)?void 0:r.element),{addressSelector:null==(a=this.dropinConfig.styles)?void 0:a.addressSelector}),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null==(e=this.creditCard)||e.activate()},onChange:({isValid:e})=>{var t,i,n,s,o,r,a;let l="boolean"!=typeof(null==(i=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.cards)?void 0:i.disablePaymentButton)||(null==(s=null==(n=this.dropinConfig.paymentMethodsConfiguration)?void 0:n.cards)?void 0:s.disablePaymentButton)?!e:null==(r=null==(o=this.dropinConfig.paymentMethodsConfiguration)?void 0:o.cards)?void 0:r.disablePaymentButton;null==(a=this.cardPaymentButton)||a.setDisabled(l)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onSaveInstrumentCheckboxChanged)||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(e){var t,i,n,o,r,a,l,c,d;return this.applePay=new nb(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null==(t=null==e?void 0:e.finalState)?void 0:t.code)?this.onAuthorizeSuccess():this.onAuthorizeFailed())},onPaymentOptionVisibilityChange:()=>{var t,i;null==(i=null==(t=this.dropinConfig.events)?void 0:t.onPaymentOptionSelected)||i.call(t,{paymentMethod:e})},onPaymentButtonClicked:e=>s(this,void 0,void 0,function*(){var t,i,n;return!(null==(t=this.dropinConfig.events)?void 0:t.onPaymentButtonClicked)||!!(yield null==(n=null==(i=this.dropinConfig.events)?void 0:i.onPaymentButtonClicked)?void 0:n.call(i,e))})})},null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.applePay),{styles:Object.assign(Object.assign({},null==(i=this.dropinConfig.styles)?void 0:i.applePayButton),null==(n=this.dropinConfig.styles)?void 0:n.element),translations:null==(o=this.dropinConfig.translations)?void 0:o.applePayButton,showPaymentMethodLogo:null!=(d=null!=(l=null==(a=null==(r=this.dropinConfig.paymentMethodsConfiguration)?void 0:r.applePay)?void 0:a.showPaymentMethodLogo)?l:null==(c=this.dropinConfig.paymentMethodsConfiguration)?void 0:c.showPaymentMethodLogo)&&d})),this.applePay}createCardPaymentButton(){var e,t,i,n;return this.cardPaymentButton||(this.cardPaymentButton=new s_({styles:null==(e=this.dropinConfig.styles)?void 0:e.cardPaymentButton,translations:null==(t=this.dropinConfig.translations)?void 0:t.cardPaymentButton,redirectFor3DS:this.clientConfig.redirectFor3DS,disabledByDefault:null==(n=null==(i=this.dropinConfig.paymentMethodsConfiguration)?void 0:i.cards)?void 0:n.disablePaymentButton,events:this.getElementEvents()},this.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,s,o,r;null==(e=this.loadingScreen)||e.unmount(),this.subElements.forEach(e=>e.unmount()),new nC({translations:{label:null==(n=null==(i=null==(t=this.dropinConfig)?void 0:t.translations)?void 0:i.paymentResult)?void 0:n.success},styles:null==(o=null==(s=this.dropinConfig)?void 0:s.styles)?void 0:o.authSuccess}).mount(this.selector),(null==(r=this.dropinConfig.events)?void 0:r.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAuthorizePending:this.onAuthorizePending.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null==(e=this.dropinConfig.paymentMethodsConfiguration)?void 0:e.preselectFirstPaymentOption))&&setTimeout(()=>{try{this.subElements[0].activate()}catch(e){ti.PayrailsLogger.error("Error while auto-activating the first payment option",{error:new tt.PayrailsError(tt.ER
15ROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{cause:e})})}},0)},onPaymentButtonClicked:e=>s(this,void 0,void 0,function*(){var t,i,n,s;null==(t=this.loadingScreen)||t.mount(this.selector);let o=!0;return(null==(i=this.dropinConfig.events)?void 0:i.onPaymentButtonClicked)&&(o=!!(yield null==(s=null==(n=this.dropinConfig.events)?void 0:n.onPaymentButtonClicked)?void 0:s.call(n,e))),o})})}onAuthorizePending(){var e,t,i,n,s,o,r,a;null==(e=this.loadingScreen)||e.unmount(),this.subElements.forEach(e=>e.unmount()),new nC({translations:{label:(null==(n=null==(i=null==(t=this.dropinConfig)?void 0:t.translations)?void 0:i.paymentResult)?void 0:n.pending)||"Payment pending"},styles:null==(o=null==(s=this.dropinConfig)?void 0:s.styles)?void 0:o.authSuccess}).mount(this.selector),null==(a=null==(r=this.dropinConfig.events)?void 0:r.onAuthorizePending)||a.call(r)}getErrorMessage(e){var t,i,n,s,o,r;let a=null==(i=null==(t=this.dropinConfig.translations)?void 0:t.paymentResult)?void 0:i.fail;return(null==e?void 0:e.message)&&(null==(s=null==(n=this.dropinConfig.translations)?void 0:n.errorMessages)?void 0:s[null==e?void 0:e.message])&&(a=null==(r=null==(o=this.dropinConfig.translations)?void 0:o.errorMessages)?void 0:r[null==e?void 0:e.message]),a}onAuthorizeFailed(e){return s(this,void 0,void 0,function*(){var t,i,n,s,o;null==(t=this.loadingScreen)||t.unmount(),(null==e?void 0:e.code)!==te.USER_CANCELLED&&new nO({translations:{label:this.getErrorMessage(e)},styles:null==(i=this.dropinConfig.styles)?void 0:i.authFailed,configuration:null==(n=this.dropinConfig.configuration)?void 0:n.authFailMsg}).mount(this.selector),null==(o=null==(s=this.dropinConfig.events)?void 0:s.onAuthorizeFailed)||o.call(s,e)})}isStoredInstrumentEnabled(e){var t,i,n,s,o,r;switch(e){case b.CARD:return!1!==(null==(i=null==(t=this.dropinConfig.paymentMethodsConfiguration)?void 0:t.cards)?void 0:i.showStoredInstruments)&&!1!==(null==(s=null==(n=this.dropinConfig.paymentMethodsConfiguration)?void 0:n.cards)?void 0:s.showExistingCards);case b.PAYPAL:case b.GOOGLE_PAY:case b.APPLE_PAY:return!1!==(null==(r=null==(o=this.dropinConfig.paymentMethodsConfiguration)?void 0:o[e])?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null==(e=this.dropinConfig.styles)?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container.styles)}fetchBinLookup(){return s(this,void 0,void 0,function*(){var e;return null==(e=this.cardForm)?void 0:e.fetchBinLookup()})}}class n4 extends i3{tokenize(e){return s(this,void 0,void 0,function*(){let t=yield this.collect(),i=t6.getInstance().config,n=i.vaultConfiguration.links.saveInstrument,s=i.token;if(!n.href){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw ti.PayrailsLogger.error(e.message,{error:e}),e}let o=yield this.constructSaveInstrumentBody(t,e);return(yield t1({url:n.href,token:s,body:o})).res})}}class n6{static minLength(e,t){return!!(t.minLength&&e.length<t.minLength)}static maxLength(e,t){return!!(t.maxLength&&e.length>t.maxLength)}static required(e,t,i){return!(!t||e)}static pattern(e,t){return!!t.pattern&&!new RegExp(t.pattern).test(e)}static oneOf(e,t){return!!t.oneOf&&0!==t.oneOf.length&&!t.oneOf.map(e=>e.const).includes(e)}}class n5 extends i3{get name(){return this.options.name}get isVisible(){return this._isVisible}get isRequired(){return this._isRequired}constructor(e){super("div",{id:e.id,className:"payrails-dynamic-element-form-field"}),this.options=e,this.errors=[],this._isVisible=!0,this._isRequired=!!this.options.required,this.makeField()}setVisible(e){this._isVisible=e,this.element.style.display=e?"block":"none"}setRequired(e){this._isRequired=e}validate(e=!1){e||this.clearError();let t=[];return(this._isVisible&&this._isRequired&&n6.required(this.value,!0,this.options.property)&&t.push(this.options.errors.required),this.value&&(n6.minLength(this.value,this.options.property)&&t.push(this.options.errors.minLength),n6.maxLength(this.value,this.options.property)&&t.push(this.options.errors.maxLength),n6.pattern(this.value,this.options.property)&&t.pu
15sh(this.options.errors.pattern),n6.oneOf(this.value,this.options.property)&&t.push(this.options.errors.oneOf)),e)?0===t.length:(this.setErrors(t),this.isValid?this.updateStyles("base"):this.updateStyles("invalid"),this.isValid)}makeField(){this.createLabel(),this.createComponentContainer(),this.createErrorMessageContainer()}createLabel(){this.label=document.createElement("label"),this.label.textContent=this.options.label,this.label.className="payrails-dynamic-element-form-field-label",this.label.htmlFor=this.options.name,this.element.appendChild(this.label)}createComponentContainer(){this.componentContainer=document.createElement("div"),this.componentContainer.className="payrails-dynamic-element-form-field-component",this.element.appendChild(this.componentContainer)}createErrorMessageContainer(){this.errorMessage=document.createElement("div"),this.errorMessage.className="payrails-dynamic-element-form-field-error",this.errorMessage.style.display="none",this.element.appendChild(this.errorMessage)}setErrors(e){var t;if(this.errors=e,this.errorMessage){for(;this.errorMessage.firstChild;)this.errorMessage.removeChild(this.errorMessage.firstChild);if(e.length>0){let t=document.createElement("ul");e.forEach(e=>{var i;let n=document.createElement("li");n.textContent=e,(null==(i=this.options.styles)?void 0:i.errors)&&Object.assign(n.style,this.options.styles.errors),t.appendChild(n)}),this.errorMessage.appendChild(t),this.errorMessage.style.display="block"}else this.errorMessage.style.display="none";(null==(t=this.options.styles)?void 0:t.errors)&&Object.assign(this.errorMessage.style,this.options.styles.errors),this.isValid?this.element.classList.remove("error"):this.element.classList.add("error")}}clearError(){this.errors=[],this.errorMessage&&(this.errorMessage.textContent="",this.errorMessage.style.display="none",this.element.classList.remove("error"))}injectElement(e){this.componentContainer&&(e.id=this.options.name,e.setAttribute("name",this.options.name),this.componentContainer.appendChild(e),this.options.events.onReady(this.value))}get isValid(){return 0===this.errors.length}}class n9 extends n5{constructor(e){super(e),this.makeComponent(),this.attachEvents()}makeComponent(){this.component=document.createElement("input"),this.component.type="text",this.component.className="payrails-dynamic-element-input",this.component.placeholder=this.options.placeholder,this.updateStyles("base"),this.injectElement(this.component)}attachEvents(){this.component&&(this.component.addEventListener("change",e=>{var t,i;e.stopPropagation(),null==(i=null==(t=this.options.events)?void 0:t.onChange)||i.call(t,this.value)}),this.component.addEventListener("input",()=>{var e,t;this.updateValidationState(),null==(t=null==(e=this.options.events)?void 0:e.onChange)||t.call(e,this.value)}),this.component.addEventListener("blur",()=>{var e,t;this.updateStyles("base"),this.updateValidationState(),null==(t=null==(e=this.options.events)?void 0:e.onBlur)||t.call(e)}),this.component.addEventListener("focus",()=>{this.updateStyles("focus")}))}updateValidationState(){this.validate(),this.isValid?(this.updateStyles("complete"),this.updateCustomValidity(!0)):(this.updateStyles("invalid"),this.updateCustomValidity(!1))}updateStyles(e){var t,i;(null==(i=null==(t=this.options.styles)?void 0:t.input)?void 0:i[e])&&this.component&&Object.assign(this.component.style,this.options.styles.input[e])}updateCustomValidity(e){this.component&&this.component.setCustomValidity(e?"":this.errors.join(", "))}get value(){var e;return(null==(e=this.component)?void 0:e.value)||""}set value(e){this.component&&(this.component.value=e,this.updateValidationState())}}class n8 extends n5{get value(){var e;return(null==(e=this.component)?void 0:e.value)||""}set value(e){this.component&&(this.component.value=e)}constructor(e){super(e),this.selectOptions=e.options,this.makeComponent(),this.attachEvents()}attachEvents(){this.component&&(this.component.addEventListener("change",e=>{var t,i;e.stopPropagation(),this.validate(),null==(i=null==(t=this.options.events)?void 0:t.onChange)||i.call(t,this.value)}),this.component.addEventListener("blur",()=>{var e,t;this.updateStyles("base"),this.validate(),null==(t=null==(e=this.options.events)?void 0:e.onBlur)||t.call(e)}),this.component.addEventListener("focus",()=>{this.updateStyles("focus")}))}makeComponent(){this.component=document.createElement("select"),this.component.className="payrails-dynamic-element-select",this.selectOptions.forEach(e
15=>{let t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.component&&this.component.appendChild(t)}),this.updateStyles("base"),this.injectElement(this.component)}updateStyles(e){var t,i;(null==(i=null==(t=this.options.styles)?void 0:t.select)?void 0:i[e])&&this.component&&Object.assign(this.component.style,this.options.styles.select[e])}}class n7 extends n5{get value(){return this.currentValue}set value(e){this.currentValue!==e&&(this.currentValue=e,this.updateTabStates())}constructor(e){var t,i,n,s;super(e),this.tabs=new Map,this.options=e,this.tabOptions=e.options,this.currentValue=(null==(t=this.tabOptions[0])?void 0:t.value)||"",this.component=document.createElement("div"),this.component.className="payrails-dynamic-element-tabs",(null==(s=null==(n=null==(i=this.options.styles)?void 0:i.tabs)?void 0:n.container)?void 0:s.base)&&Object.assign(this.component.style,this.options.styles.tabs.container.base),this.makeTabs(),this.injectElement(this.component)}createTab(e){var t,i,n;let s=document.createElement("button");return s.type="button",s.textContent=e.label,s.className="payrails-dynamic-element-tab",(null==(n=null==(i=null==(t=this.options.styles)?void 0:t.tabs)?void 0:i.tab)?void 0:n.base)&&Object.assign(s.style,this.options.styles.tabs.tab.base),s.addEventListener("click",t=>{var i,n;t.stopPropagation(),t.stopImmediatePropagation(),this.value=e.value,this.options.events.onChange(this.value),null==(n=null==(i=this.options.events)?void 0:i.onBlur)||n.call(i)}),s}makeTabs(){this.component.innerHTML="",this.tabs.clear(),this.tabOptions.forEach(e=>{let t=this.createTab(e);this.component.appendChild(t),this.tabs.set(e.value,t)}),this.updateTabStates()}
15updateTabStates(){this.tabs.forEach((e,t)=>{var i,n,s,o,r,a;e.classList.toggle("active",t===this.currentValue),e.removeAttribute("style"),t===this.currentValue&&(null==(s=null==(n=null==(i=this.options.styles)?void 0:i.tabs)?void 0:n.tab)?void 0:s.active)?Object.assign(e.style,this.options.styles.tabs.tab.active):(null==(a=null==(r=null==(o=this.options.styles)?void 0:o.tabs)?void 0:r.tab)?void 0:a.base)&&Object.assign(e.style,this.options.styles.tabs.tab.base)})}updateStyles(){}}let se="ui:position";function st(e){var t,i;return null!=(i=null==(t=e.oneOf)?void 0:t.map(e=>({value:String(e.const),label:e.title})))?i:[]}class si extends n4{constructor(e,t,i){super("div",{id:"payrails-dynamic-element-form",className:"payrails-dynamic-element-form"}),this.options=e,this.formConfig=t,this.returnInfo=i,this.formFields=new Map,this.formData={},this.__schema=null,this._previousFormValidState=null}collect(){return s(this,void 0,void 0,function*(){if(!this.parentElement)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED,{description:"Dynamic element form is not mounted"});let e={};if(Object.values(Object.fromEntries(this.formFields.entries())).forEach(t=>{t.validate(),t.isVisible&&(e=iM(e,t.name,t.value))}),!this.isFormValid())throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID,{description:"Dynamic element form is invalid"});return e})}constructSaveInstrumentBody(e,t){return s(this,void 0,void 0,function*(){var i;return{data:e,merchantReference:t4.response.merchantReference,holderReference:t4.response.holderReference,holderId:t4.response.holderId,paymentMethod:this.options.paymentMethod.paymentMethodCode,storeInstrument:null!=(i=null==t?void 0:t.storeInstrument)&&i}})}isFormValid(){return Object.values(this.formFields).filter(e=>e.isVisible).every(e=>e.isValid)}isFormValidSilent(){return Object.values(this.formFields).filter(e=>e.isVisible).every(e=>e.validate(!0))}checkAndTriggerValidationChange(){var e,t;let i=this.isFormValidSilent();this._previousFormValidState!==i&&(this._previousFormValidState=i,null==(t=null==(e=this.options.events)?void 0:e.onValidationChange)||t.call(e,i))}mount(e){let t=Object.create(null,{mount:{get:()=>super.mount}});return s(this,void 0,void 0,function*(){var i,n;yield this.makeForm(),t.mount.call(this,e),null==(n=null==(i=this.options.events)?void 0:i.onReady)||n.call(i)})}makeForm(){return s(this,void 0,void 0,function*(){var e;if(null==(e=this.formConfig)?void 0:e.schema){for(let e of(this.__schema=yield function(e){return s(this,void 0,void 0,function*(){if(!e||"object"!=typeof e)return e;let t=function e(t,i=new Set){return Array.isArray(t)?t.forEach(t=>e(t,i)):t&&"object"==typeof t&&(t.$ref&&/^https?:\/\//.test(t.$ref)&&i.add(t.$ref),Object.values(t).forEach(t=>e(t,i))),i}(e);return 0===t.size?e:function e(t,i){if(Array.isArray(t))return t.map(t=>e(t,i));if(t&&"object"==typeof t){if(t.$ref&&/^https?:\/\//.test(t.$ref)){if(!i.has(t.$ref))return;let n=e(i.get(t.$ref),i);return void 0!==t[se]?Object.assign(Object.assign({},n),{[se]:t[se]}):n}let n={};for(let[s,o]of Object.entries(t)){let t=e(o,i);void 0!==t&&(n[s]=t)}return n}return t}(e,(yield function(e){return s(this,void 0,void 0,function*(){let t=new Map,i=Array.from(e).map(e=>s(this,void 0,void 0,function*(){try{let i=(yield i8({url:e})).res;t.set(e,i)}catch(t){console.warn(`Failed to fetch schema from ${e}:`,t)}}));return yield Promise.all(i),t})}(t)))})}(this.formConfig.schema),Object.values(function(e,t){let i={};if(!(e&&"object"==typeof e))return i;let n=(e,s)=>{var o;if(e.properties)for(let[r,a]of Object.entries(e.properties)){let l=s?`${s}.${r}`:r;"object"===a.type&&a.properties?n(a,l):i[l]=function(e,t,i,n){var s,o,r,a,l,c,d,u,h,p,_,m;return{id:`payrails-dynamic-element-field:${e}`,name:e,property:t,label:null!=(a=null!=(r=null==(o=null==(s=null==n?void 0:n.fields)?void 0:s[e])?void 0:o.label)?r:t.title)?a:`${e}:label`,placeholder:null!=(d=null==(c=null==(l=null==n?void 0:n.fields)?void 0:l[e])?void 0:c.placeholder)?d:`${e}:placeholder`,errors:t2({required:"This field is required",minLength:"This field is too short",maxLength:"This field is too long",pattern:"This field is invali
15d",oneOf:"This field is invalid"},null!=(u=t.errorMessage)?u:{},null!=(h=null==n?void 0:n.errors)?h:{},null!=(m=null==(_=null==(p=null==n?void 0:n.fields)?void 0:p[e])?void 0:_.errors)?m:{}),required:i}}(l,a,(null==(o=e.required)?void 0:o.includes(r))||!1,t)}};return n(e,""),i}(this.__schema,this.options.translations)).sort((e,t)=>{var i,n;return(null!=(i=e.property[se])?i:0)-(null!=(n=t.property[se])?n:0)})))this.createField(e);this.evaluateDependencies()}})}createField(e){let t=this.createFieldSync(e);t&&(this.formFields.set(e.name,t),this.subElements.push(t))}createFieldSync(e){var t,i;return(t=e.property).oneOf&&t.oneOf.length>0?this.createOneOfField(e):"string"!==(i=e.property).type||i.oneOf?null:this.createStringField(e)}createOneOfField(e){let t="bankAccount.holder.type"===e.name?"tabs":"select";return this.createFieldByType(e,t)}createStringField(e){return this.createFieldByType(e,"input")}createFieldByType(e,t){let i=this.extractStyles(e.name,t),n=this.makeFieldEvents(e.name);switch(t){case"tabs":return new n7(Object.assign(Object.assign({},e),{events:n,styles:i,options:st(e.property)}));case"select":return new n8(Object.assign(Object.assign({},e),{events:n,styles:i,options:st(e.property)}));case"input":return new n9(Object.assign(Object.assign({},e),{events:n,styles:i}));default:throw Error(`Unsupported component type: ${t}`)}}extractStyles(e,t){var i,n,s,o,r,a,l,c,d,u,h,p,_,m;let E=t2({},null!=(s=null==(n=null==(i=this.options.styles)?void 0:i.all)?void 0:n[t])?s:{},null!=(l=null==(a=null==(r=null==(o=this.options.styles)?void 0:o.fields)?void 0:r[e])?void 0:a[t])?l:{});return{[t]:E,errors:t2({},null!=(u=null==(d=null==(c=this.options.styles)?void 0:c.all)?void 0:d.errors)?u:{},null!=(m=null==(_=null==(p=null==(h=this.options.styles)?void 0:h.fields)?void 0:p[e])?void 0:_.errors)?m:{})}}makeFieldEvents(e){return{onChange:(t=>{this.formData=iM(this.formData,e,t),this.evaluateDependencies()}).bind(this),onReady:(t=>{this.formData=iM(this.formData,e,t)}).bind(this),onBlur:(()=>{this.checkAndTriggerValidationChange()}).bind(this)}}evaluateDependencies(){if(this.__schema)for(let[e,t]of Object.entries(function(e,t){let i={};if(!e.dependentSchemas)return i;for(let[n,s]of Object.entries(e.dependentSchemas)){let e=iD(t,n);s.oneOf&&Object.assign(i,function(e,t,i){var n,s;let o=null==(n=e.oneOf)?void 0:n.find(e=>{var n,s;return(null==(s=null==(n=e.properties)?void 0:n[t])?void 0:s.const)===i});if(!o)return{};let r=new Set(o.required||[]);return Object.fromEntries(Array.from(new Set((null==(s=e.oneOf)?void 0:s.flatMap(e=>e.required||[]))||[])).filter(e=>e!==t).map(e=>[e,{isVisible:r.has(e),isRequired:r.has(e)}]))}(s,n,e))}return i}(this.__schema,this.formData))){let i=this.formFields.get(e);i&&(i.setVisible(t.isVisible),i.setRequired(t.isRequired))}}}let sn=e=>s(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onSessionExpired)try{let t=yield e.onSessionExpired();if(t)t5(t),(null==e?void 0:e.onClientInitialized)&&e.onClientInitialized(t4);else{let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});ti.PayrailsLogger.error(e.message,{error:e})}}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Callback passed to onSessionExpired threw an error",cause:t});ti.PayrailsLogger.error(e.message,{error:e})}}),ss=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;class so{static setSelectedInstrument(e){if(!e||!e.id.match(ss))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Instrument is not valid"});this._selectedInstrument=e}static getSelectedInstrument(){return this._selectedInstrument}static clearSelectedInstrument(){this._selectedInstrument=null}}so._selectedInstrument=null;let sr={deleteInstrument:{linkKey:"instrumentDelete",method:P.DELETE,createRequest:e=>{var t,i;if(!e.resourceId)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR);let n=null==(i=null==(t=t6.getInstance().config.links)?void 0:t.instrumentDelete)?void 0:i.href;
15if(!n)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);return{url:e.resourceId?null==n?void 0:n.replace(":instrumentId",e.resourceId):n}},requestType:void 0,responseType:{}},updateInstrument:{linkKey:"instrumentUpdate",method:P.PATCH,createRequest:e=>{var t,i;let n=null==(i=null==(t=t6.getInstance().config.links)?void 0:t.instrumentUpdate)?void 0:i.href;if(!n)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);return{url:e.resourceId?null==n?void 0:n.replace(":instrumentId",e.resourceId):n,body:e.body}},requestType:{},responseType:{}},payout:{linkKey:"payout",method:P.POST,createRequest:()=>{let e=t4.payoutLink;if(!e)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);let t=so.getSelectedInstrument();if(!t)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED,{cause:Error("No selected instrument for payout, set an instrument first using setState")});let i=[{integrationType:"api",amount:t6.getInstance().config.amount,paymentMethodCode:t.paymentMethod,paymentInstrumentId:t.id}];return{url:e,body:{amount:t6.getInstance().config.amount,payoutComposition:i}}},onSuccess:e=>s(void 0,void 0,void 0,function*(){let t=new iq;return yield t.pollForAuthorizationResult(e.links.execution)}),requestType:{},responseType:{}}},sa={holderReference:{path:["holderReference"],returnType:""},amount:{path:["amount"],returnType:{}},binLookup:{path:["links","binLookup"],returnType:{}},instrumentUpdate:{path:["links","instrumentUpdate"],returnType:{}},instrumentDelete:{path:["links","instrumentDelete"],returnType:{}},executionId:{path:["execution","id"],returnType:void 0},paymentMethodConfig:{path:[],returnType:{}},paymentMethodInstruments:{path:[],returnType:{}}};class sl{static init(e,t){var i,n,s,o,r,a,l,c,d,u,h,p;try{let _="5.44.1",m="web-sdk";((e={})=>{let t,i;return document.getElementById("sdk-observer")||((t=document.createElement("iframe")).id="sdk-observer",i=new URLSearchParams(e).toString(),t.src=`https://assets.payrails.io/2089b54/observability/index.html?${i}`,t.width="1px",t.height="1px",document.body.appendChild(t))})({version:_,packageName:m}),ti.PayrailsLogger.init({enabled:(null==(i=null==t?void 0:t.telemetry)?void 0:i.enabled)||!0,logLevel:(null==(n=null==t?void 0:t.telemetry)?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:m,version:_}}),t5(e);let E=t6.getInstance().config;ti.PayrailsLogger.setState({payrails:{execution_id:null==(s=null==E?void 0:E.execution)?void 0:s.id,holder_reference:null==E?void 0:E.holderReference,vault_provider:null==(o=null==E?void 0:E.vaultConfiguration)?void 0:o.vaultType,merchant_reference:null==(r=null==E?void 0:E.execution)?void 0:r.merchantReference,workflow:{code:(null==(l=null==(a=null==E?void 0:E.execution)?void 0:a.workflow)?void 0:l.code)||"",version:(null==(d=null==(c=null==E?void 0:E.execution)?void 0:c.workflow)?void 0:d.version)||0}}});let{vaultConfiguration:{vaultId:y,vaultUrl:v,token:I},execution:f}=E;null==(u=E.vaultConfiguration)||u.vaultId;let g=iz.init({vaultID:y,vaultURL:v,getBearerToken:()=>I?Promise.resolve(I):Promise.resolve(""),options:{initResponse:e,deserializedData:Object.assign({},E),logLevel:(null==(p=null==(h=null==t?void 0:t.telemetry)?void 0:h.logLevel)?void 0:p.toUpperCase())||"ERROR"}});return f&&(t4.setResponse(f),t4.isPaymentMethodAvailable(b.CARD)&&iQ.preloadCardForm()),new sl(g,t)}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:t});throw ti.PayrailsLogger.error(e.message,{error:e}),e}}update(e){var t,i,n,s;void 0!==e.value&&void 0!==e.currency&&(t6.getInstance().config.amount={value:e.value,currency:e.currency}),e.meta&&t4.updateMeta(e.meta.key,e.meta.value);let o=e.installmentConfig;if(!o||0===Object.keys(o).length)return;let r=t4.getPaymentInstallmentOptions(b.CARD)||{},a=null==(t=o.installmentCountry)?void 0:t.toString();if(a&&Object.prototype.hasOwnProperty.call(o,"installmentOptions")){let e=Array.isArray(o.installmentOptions)?o.installmentOptions:[],t=Object.assign(Object.assign({},r),{[a]:e});t4.updateInstallmentOptions(t)}let l={};Object.prototype.hasOwnProperty.call(o,"defaultInstallment")&&(l.defaultInstallment=null!=(i=o.defaultInstallment)?i:null),null==(n=this.__cardForm)||n.updateInstallmentConfig(l),null==(s=this.__dropin)||s.updateInstallmentConfig(l)}collectContainer(e){var t;if("COMPOSABLE"===e.containerType&&!e.layout){let e=new tt.PayrailsError(tt.ER
15ROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw ti.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=t9.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null==(t=t6.getInstance().config.vaultConfiguration)?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new n$(Object.assign({environment:null==(t=this.options)?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return n$.isGooglePayAvailable(t4.googlePayConfig,null==(t=this.options)?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new i5(e)}isApplePayAvailable(){return i5.isApplePayAvailable()}setState({instrument:e}){e&&so.setSelectedInstrument(e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new nA({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){let n=this.getContainerLayout(null==e?void 0:e.showCardHolderName,null==e?void 0:e.showSingleExpiryDateField,null==e?void 0:e.layout);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.errorTextStyles),{styles:{base:null==(i=null==e?void 0:e.styles)?void 0:i.base},fonts:null==e?void 0:e.fonts})),this.__cardForm=new nE(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;if(this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm)){let e=!!this.__cardPaymentButton.disabledByDefault&&!this.__cardForm.isValid;this.__cardPaymentButton.setDisabled(e)}(null==(i=null==e?void 0:e.events)?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;if(this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm)){let e=!!this.__cardPaymentButton.disabledByDefault&&!this.__cardForm.isValid;this.__cardPaymentButton.setDisabled(e)}(null==(t=null==e?void 0:e.events)?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i,n,s,o,r;this.logIntegrationMode("dropin");let a=this.getContainerLayout(null==(i=null==(t=e.paymentMethodsConfiguration)?void 0:t.cards)?void 0:i.showCardHolderName,null==(s=null==(n=e.paymentMethodsConfiguration)?void 0:n.cards)?void 0:s.showSingleExpiryDateField,null==(r=null==(o=e.paymentMethodsConfiguration)?void 0:o.cards)?void 0:r.layout);return this.__container=this.collectContainer({layout:a,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new n3(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),t4.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),t4.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),t4.savedApplePayAccounts}query(e,t){return this.logIntegrationMode("headless"),((e,t)=>{try{let i=t6.getInstance().config,n=sa[e];if(!n)return ti.PayrailsLogger.warn(`No query definition found for key: ${e}`),null;if("paymentMethodConfig"===e){let e=null==t?void 0:t.paymentMethodCode;return e?function(e){var t;try{if(!e)return ti.PayrailsLogger.error("Payment method code is required"),null;let i=t4.availablePaymentMethods;return"all"===e?i:"redirect"===e?i.filter(e=>{var t;return(null==(t=e.clientConfig)?void 0:t.flow)===w.REDIRECT}):null!=(t=i.find(({paymentMethodCode:t})=>t===e))?t:null}catch(t){return ti.PayrailsLogger.error(`Error getting config for payment method: ${e}`,{error:t}),null}}(e):(ti.PayrailsLogger.warn("Payment method code is required for paymentMethodConfig query"),null)}if("paymentMethodInstruments"===e){let e=null==t?void 0:t.paymentMethodCode;return e?t4.getStoredInstrumentForPaymentMethod(e):(ti.PayrailsLogger.warn("Payment method code is required for paymentMethodInstruments query"),null)}let{path:s}=n;return function(e,t){if(!e||!t||!t.length)return;let i=e;for(let e of t){if(null==i)return;i=i[e]}return i}(i,s)||null}catch(e){return ti.PayrailsLogger.error("Error querying SDK Configuration",{error:e}),null}})(e,t)}api(e){return s(this,void 0,void 0,function*(){return this.logIntegrationMode("headless"),s(void 0,void 0,void 0,function*(){let{operation:t}=e,i=t6.getInstance().config,n=sr[t];try{let t=n.createRequest(e),s=yield tW(Object.assign({url:t.url,token:i.token,method:n.method},void 0!==t.body&&{body:t.body}));return n.onSuccess?yield n.onSuccess(s.res):s.res}
15catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{cause:t});throw ti.PayrailsLogger.error(e.message,{error:e}),e}})})}getStoredInstruments(){return this.logIntegrationMode("elements"),t4.storedPaymentInstruments}getStoredInstrumentsByPaymentMethod(e){return this.logIntegrationMode("elements"),t4.storedPaymentInstruments.filter(t=>t.paymentMethod===e)}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),t4.availablePaymentMethods.map(({paymentMethodCode:e})=>e).filter(e=>!!e)}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new s_(e,(null==(t=this.options)?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!!e.disabledByDefault),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){return this.logIntegrationMode("elements"),this.__paypalButton=new nQ(Object.assign({},e)),this.__paypalButton}leanButton(e){return this.logIntegrationMode("elements"),this.__leanButton=new nZ(e),this.__leanButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new nV(e,e.returnInfo),this.__genericRedirectButton}dynamicElement(e){var t;this.logIntegrationMode("elements");let i=t4.getFullPaymentMethodConfig(e.paymentMethod.paymentMethodCode);if(!(null==(t=null==i?void 0:i.clientConfig)?void 0:t.instrumentDataSchema))throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG,{description:`Form schema not found for payment method ${e.paymentMethod.paymentMethodCode}`});let n={schema:i.clientConfig.instrumentDataSchema};return this.__dynamicElementForm=new si(e,n),this.__dynamicElementForm}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),t4.savedPaypalAccounts||[]}logIntegrationMode(e){ti.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,t){var i,n;this.vaultClient=e,this.options=t,null==(n=null==(i=null==t?void 0:t.events)?void 0:i.onClientInitialized)||n.call(i,t4),iH=this.options||{},t8.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>s(this,void 0,void 0,function*(){var e;yield null==sn?void 0:sn(null==(e=this.options)?void 0:e.events)}))}getContainerLayout(e,t,i){let n=[];return i?i.forEach(e=>{n.push(e.length)}):(n.push(1),e&&n.push(1),t?n.push(2):n.push(3)),n}binLookup(){return s(this,void 0,void 0,function*(){var e,t;let i;return this.__dropin||this.__cardForm||this.__container?(this.__dropin?i=yield this.__dropin.fetchBinLookup():this.__cardForm?i=yield null==(e=this.__cardForm)?void 0:e.fetchBinLookup():this.__container&&(i=yield null==(t=this.__container)?void 0:t.fetchBinLookup(this.__container.bin)),i):void console.warn("No container found")})}}sl.preloadCardForm=iQ.preloadCardForm,(R=e8||(e8={})).AUTHORIZE="AUTHORIZE",R.TOKENIZE="TOKENIZE",(T=e7||(e7={})).TEST="TEST",T.PRODUCTION="PRODUCTION";let sc=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeSuccess)&&e===e8.AUTHORIZE&&(console.warn("onAuthorizeSuccess is marked as deprecated and will be removed in future releases. Use `onSuccess` instead."),t.onAuthorizeSuccess(i)),null==(n=null==t?void 0:t.onSuccess)||n.call(t,e,i)},sd=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeFailed)&&e===e8.AUTHORIZE&&(console.warn("onAuthorizeFailed is marked as deprecated and will be removed in future releases. Use `onFailed` instead."),t.onAuthorizeFailed(i)),null==(n=null==t?void 0:t.onFailed)||n.call(t,e,i)},su=(e,t)=>s(void 0,void 0,void 0,function*(){return t?(t.onAuthorizeRequestStart&&e===e8.AUTHORIZE&&console.warn("onAuthorizeRequestStart is marked as deprecated and will be removed in future releases. Use `onRequestStart` instead."),Promise.all(["function"==typeof t.onAuthorizeRequestStart&&e===e8.AUTHORIZE?t.onAuthorizeRequestStart():Promise.resolve(!0),"function"==typeof t.onRequestStart?t.onRequestStart(e):Promise.resolve(!0)]).then(e=>e.every(e=>!0===e))):Promise.resolve(!0)}),sh=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizePending)&&e===e8.AUTHORIZE&&(console.warn("onAuthorizePending is marked as deprecated and will be removed in future releases. Use `onPending` instead."),t.onAuthorizePending(i)),null==(n=null==t?void 0:t.onPending)||n.call(t,e,i)},sp=(e,t,i)=>s(void 0,void 0,void 0,function*(){try{let n=yield s(void 0,void 0,void 0,function*(){if(!t)return Promise.resolve(!0);t.onPaymentButtonClicked&&console.warn("onPaymentButtonClicked is marked as deprecated and will be removed in future releases. Use `onButtonClicked` instead.");let n="function"==typeof t.onPaymentButtonClicked&&e===e8.AUTHORIZE?t.onPaymentButtonClicked(i):Promise.resolve(!0),s="function"==typeof t.onButtonClicked?t.onButtonClicked(e,i):Promise.resolve(!0);return Promise.all([n,s]).then(e=>e.every(e=>!0===e))});
15if(!n){let i=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked resolved to false"});return sd(e,t,{code:te.VALIDATION_FAILED,message:i.message}),n}}catch(n){let i=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked threw an error",cause:n});return sd(e,t,{code:te.VALIDATION_FAILED,message:i.message}),!1}return!0});class s_ extends i3{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null==(e=this.cardForm)?void 0:e.bin)||""}constructor(e,t){var i;super("button",{id:"payrails-card-payment-button"}),this.options=e,this.returnInfo=t,this.selectedInstrument=null,this.paymentInstallmentElement=null,this.isLoading=!1,this.disabledByDefault=!0,this.element.innerText=(null==(i=null==e?void 0:e.translations)?void 0:i.label)||"Pay",this.disabledByDefault="boolean"!=typeof e.disabledByDefault||e.disabledByDefault,this.setDisabled(this.disabledByDefault),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.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.hover)||{}))}),this.paymentExecutor=new iq(this.returnInfo)}setDisabled(e){var t,i,n,s,o;this.element.classList.contains("disabled")!==e&&(null==(i=null==(t=this.options.events)?void 0:t.onStateChanged)||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null==(n=this.options.styles)?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null==(s=this.options.styles)?void 0:s.disabled)||{}),(null==(o=this.options.styles)?void 0:o.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;let i=Object.assign(Object.assign({},null==(t=this.options.styles)?void 0:t.base),e);
15Object.keys(i).forEach(e=>{this.element.style[e]=i[e]})}removeStyles(e){var t;let i=Object.keys((null==(t=this.options.styles)?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.base)?void 0:n[e]:this.element.style[e]=""})}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}setPaymentInstallmentsDropdown(e){this.paymentInstallmentElement=e}triggerLoading(e){var t,i,n,s;let o=this.element.offsetWidth;this.element.style.minWidth=`${o}px`,this.isLoading=e,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null==(t=this.options.styles)?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null==(n=null==(i=this.options)?void 0:i.translations)?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null==(s=this.options.styles)?void 0:s.loading)||{}))}onAuthorizationFailed(e){this.setDisabled(!1),this.triggerLoading(!1),sd(e8.AUTHORIZE,this.options.events,e)}onPay(){return s(this,void 0,void 0,function*(){var e,t,i,n,s,o,r,a,l,c,d,u,h,p;let _;if(this.setDisabled(!0),this.triggerLoading(!0),!(null==(e=this.selectedInstrument)?void 0:e.id)){let e=yield null==(t=this.cardForm)?void 0:t.validate();if(_=!!(null==e?void 0:e.isValid),null==(n=null==(i=this.options.events)?void 0:i.onValidate)||n.call(i,{isValid:!!_,error:null==e?void 0:e.error,fieldErrors:null==e?void 0:e.fieldErrors}),!_)return this.setDisabled(!1),void this.triggerLoading(!1)}if(!(_=yield sp(e8.AUTHORIZE,this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:b.CARD,integrationType:"api",amount:t6.getInstance().config.amount,storeInstrument:!1}];if(null==(s=this.selectedInstrument)?void 0:s.id)e[0].paymentInstrumentId=null==(o=this.selectedInstrument)?void 0:o.id,e[0].paymentMethodCode=null==(r=this.selectedInstrument)?void 0:r.paymentMethod,this.paymentInstallmentElement&&(null==(a=this.paymentInstallmentElement)?void 0:a.selectedInstallmentValue)&&(e[0].installments={count:null==(l=this.paymentInstallmentElement)?void 0:l.selectedInstallmentValue});else{if(!this.cardForm){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw ti.PayrailsLogger.error(e.message,{error:e}),e}e=yield this.constructEncryptedPayment(e)}let t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(t){let e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof t$||[401,403].includes(null==(c=null==t?void 0:t.error)?void 0:c.code)?(null==(u=null==(d=this.options.events)?void 0:d.onPaymentSessionExpired)||u.call(d),e.message="API token is not valid or expired.",ti.PayrailsLogger.error(e.message,{error:e}),this.onAuthorizationFailed({code:te.AUTHENTICATION_ERROR,message:e.message})):t.toString().includes("Invalid token")?(null==(p=null==(h=this.options.events)?void 0:h.onPaymentSessionExpired)||p.call(h),e.message="Vault token is not valid or expired.",ti.PayrailsLogger.error(e.message,{error:e})):e=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:te.AUTHENTICATION_ERROR,message:e.message})}})}constructEncryptedPayment(e){return s(this,void 0,void 0,function*(){if(!this.cardForm)throw new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);let{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n,selectedInstallment:s,billingInfo:o}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign(Object.assign({},t),{billingAddress:o}),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,s&&(e[0].installments={count:s}),e})}updateStyles(e){this.options.styles&&(this.options.styles=Object.assign(Object.assign({},this.options.styles),e)),this.isLoading?this.setStyles((null==e?void 0:e.loading)||{}):this.setStyles((null==e?void 0:e.base)||{})}updateTranslations(e){this.options.translations&&(this.options.translations=Object.assign(Object.assign({},this.options.translations),e)),(null==e?void 0:e.label)&&this.setLabel(e.label)}updateEvents(e){this.options.events&&(this.options.events=Object.assign(Object.assign({},this.options.events),e))}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations),e.events&&this.updateEvents(e.events)}handleAuthorizationResult(e){var t,i,n,s,o,r,a;let l;switch(null==(t=null==e?void 0:e.finalState)?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),sc(e8.AUTHORIZE,this.options.events);break;case"authorizePending":"3ds"===(null==(i=null==e?void 0:e.response)?void 0:i.actionRequired)?new nG(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor).handle3ds(e):(null==(n=null==e?void 0:e.response)?void 0:n.actionRequired)||(this.triggerLoading(!1),sh(e8.AUTHORIZE,this.options.events));break;
15default:l=new tt.PayrailsError(tt.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:te.AUTHORIZATION_ERROR,message:(null==(a=null==(r=null==(o=null==(s=e.finalState)?void 0:s.errors)?void 0:o[0])?void 0:r.reason)?void 0:a.result)||l.message})}}}(S=te||(te={})).VALIDATION_FAILED="VALIDATION_FAILED",S.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",S.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",S.UNKNOWN_ERROR="UNKNOWN_ERROR",S.USER_CANCELLED="USER_CANCELLED"}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.