Woo, Sue, and ARPU: What Publisher Earnings Reveal About Their AI Strategies
The New York Times, News Corp, USA Today Co. and People Inc. reported this week, each of which is grappling with AI-driven pressure on traffic.

本条来自 Adweek(Marketing / 创意),聚焦 brand、consumer。 Subscribe Sign In Agencies Brands Creativity Media TV Commerce Tech Dealroom // Check if the menuHtml is stored in local storage if (!localStorage.getItem('menuHtml')) { // Set the value in local storage localStorage.setItem('menuHtml', ""); } SUBSCRIPTION ONLY if (!window.Zephr) window.Zephr = {}; if (!window.Zephr.outcomes) window.Zephr.outcomes = {}; window.Zephr.outcomes['subscriber-only-lock-on-articles'] = { featureLabel: 'Subscriber Only Lock on Articles', outcomeId: 'transformation/2', outcomeLabel: 'Lock Before Article Heading' }; Earnings Reports Woo, Sue, and ARPU: What Publisher Earnings Reveal About Their AI Strategies The New York Times, News Corp, USA Today Co., and People Inc. are each grappling with AI-driven pressure on traffic Getty Images By Mark Stenberg --> if (!window.Zephr) window.Zephr = {}; if (!window.Zephr.outcomes) window.Zephr.outcomes = {}; window.Zephr.outcomes['nativead'] = { featureLabel: 'nativead', outcomeId: 'graph/2#95', outcomeLabel: 'Show nativead (copy)' }; Traffic is down across the media industry, and AI is the main reason why.
The New York Times, News Corp, USA Today Co
- Subscribe Sign In Agencies Brands Creativity Media TV Commerce Tech Dealroom // Check if the menuHtml is stored in local storage if (
The New York Times, News Corp, USA Today Co
and People Inc
reported this week, each of which is grappling with AI-driven pressure on traffic
Subscribe Sign In Agencies Brands Creativity Media TV Commerce Tech Dealroom // Check if the menuHtml is stored in local storage if (!localStorage.getItem('menuHtml')) { // Set the value in local storage localStorage.setItem('menuHtml', ""); } SUBSCRIPTION ONLY if (!window.Zephr) window.Zephr = {}; if (!window.Zephr.outcomes) window.Zephr.outcomes = {}; window.Zephr.outcomes['subscriber-only-lock-on-articles'] = { featureLabel: 'Subscriber Only Lock on Articles', outcomeId: 'transformation/2', outcomeLabel: 'Lock Before Article Heading' }; Earnings Reports Woo, Sue, and ARPU: What Publisher Earnings Reveal About Their AI Strategies The New York Times, News Corp, USA Today Co., and People Inc. are each grappling with AI-driven pressure on traffic Getty Images By Mark Stenberg --> if (!window.Zephr) window.Zephr = {}; if (!window.Zephr.outcomes) window.Zephr.outcomes = {}; window.Zephr.outcomes['nativead'] = { featureLabel: 'nativead', outcomeId: 'graph/2#95', outcomeLabel: 'Show nativead (copy)' }; Traffic is down across the media industry, and AI is the main reason why.
That was the throughline connecting the second-quarter earnings from The New York Times, News Corp, USA Today Co., and People Inc., all of which were reported this week.
In response to the declines, each company is implementing some version of the same three-part playbook: licensing their content to AI companies where they can; suing or blocking where they cannot; and squeezing more revenue out of the readers they have.
In describing his approach to the problem, News Corp CEO Robert Thomson has called the strategy a “woo and sue” framework.
} props * @returns {void} */ $set(props) { if (this.$$set && !is_empty(props)) { this.$$.skip_bound = true; this.$$set(props); this.$$.skip_bound = false; } } } /** * @typedef {Object} CustomElementPropDefinition * @property {string} [attribute] * @property {boolean} [reflect] * @property {'String'|'Boolean'|'Number'|'Array'|'Object'} [type] */ // generated during release, do not modify const PUBLIC_VERSION = '4'; if (typeof window !== 'undefined') // @ts-ignore (window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION); // Some height larger than whats resonable expected, // but not so large as to infulence the transition time const TRANSITION_OPEN_HEIGHT = '700px'; // Absolute max height const MAX_OPEN_HEIGHT = '10000px'; const CLOSED_HEIGHT = '0px'; const DURATION_MS = 500; function accordion(node, isOpen) { let currentState = isOpen; node.style.maxHeight = isOpen ? MAX_OPEN_HEIGHT : CLOSED_HEIGHT; node.style.overflow = isOpen ? "unset" : "hidden"; const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)'); const animationsDisabled = mediaQuery.matches; if (animationsDisabled) { node.style.display = isOpen ? 'unset' : 'none'; } return { update(isOpen) { if (animationsDisabled) { node.style.display = isOpen ? 'unset' : 'none'; return; } if (isOpen === currentState) { return; } currentState = isOpen; const toHeight = isOpen ? TRANSITION_OPEN_HEIGHT : CLOSED_HEIGHT; const fromHeight = isOpen ? CLOSED_HEIGHT : TRANSITION_OPEN_HEIGHT; node.animate([ { maxHeight: fromHeight, overflow: 'hidden' }, { maxHeight: toHeight, overflow: 'hidden' }, ], { duration: DURATION_MS, fill: 'both', }).addEventListener("finish", () => { // After the opening transition, unset the max height so if it's larger than OPEN_HEIGHT the content // will be shown, but via a quick jump if (!isOpen) { return; } node.animate([ { maxHeight: toHeight, overflow: 'hidden' }, { maxHeight: MAX_OPEN_HEIGHT, overflow: 'hidden' }, ], { duration: 100, fill: 'both', }); }); } }; } const elementTypes = { PROGRESS_BAR: 'progress_bar', PAYMENT_OPTION_SELECTION: 'payment_option_selection', PASSWORD: 'password', VERIFICATION_CODE: 'otp_code', BUTTON: 'button', PAYMENT: 'payment', PAYMENT_PRE_LOADER: 'payment-pre-loader', EMAIL_ADDRESS: 'email_address', SUCCESS_MESSAGE: 'success_message', TEXT: 'text', USER_ATTRIBUTE: 'user_attribute', RESET_PASSWORD_LINK: 'link', RESEND_LOGIN_LINK: 'resend_login_link', SOCIAL_SIGNIN: 'social_sign_in', PAYMENT_SUMMARY: 'payment_summary', DIVIDER: 'divider', LOGIN_LINK: 'show_login_link', ACCOUNT_MEMBERSHIP_CODE: 'account_code', MOBILE_PAYMENT: 'mobile_payment', INVITATION: 'invitation', TEMPLATE_COMPONENT: 'template_component', SUBSCRIPTION_SELECT: 'subscription_select', EVENT_LINK: 'event_link', SUBSCRIPTIONS_LIST: 'subscriptions_list', PAST_SUBSCRIPTIONS_LINK: 'past_subscriptions_link', BILLING_HISTORY: 'billing_history', CHNAGE_PAYMENT_METHOD_BUTTON: 'change_payment_method_button', READ_ONLY_EMAIL_ADDRESS: 'read_only_email_address', READ_ONLY_PASSWORD: 'read_only_password', READ_ONLY_USER_ATTRIBUTE: 'read_only_user_attribute', CHNAGE_PAYMENT_METHOD: 'change_payment_method', DEVICES_SESSIONS_LIST: 'devices_list', SIGN_OUT_ALL_OTHER_DEVICES: 'sign_out_of_devices_button', TABLINK: 'tablink', BUTTON_GROUP: 'button_group', LINK_BUTTON: 'link_button', RECIPIENT_NAME: 'recipient_name', RECIPIENT_EMAIL: 'recipient_email', RECIPIENT_ADDRESS: 'recipient_address', RECIPIENT_MESSAGE: 'recipient_message', GIFT_CODE: 'gift_code', GIFT_SUBSCRIPTIONS_LIST: 'gift_subscriptions_list', GIFT_TOGGLE: 'gift_toggle', GIFT_FUTURE_DATE_TOGGLE: 'gift_future_date_toggle', GIFT_FUTURE_DATE_INPUT: 'gift_future_date_input', PAYMENT_AUTO_RENEW_TOGGLE: 'payment_auto_renew_toggle', SUSPEND_RESUME_SUBSCRIPTION: 'suspend_resume_subscription', SUBSCRIPTION_CUSTOM_FIELDS_UPDATE: 'subscription_custom_fields_update', SUBSCRIPTION_CUSTOM_FIELDS_LIST: 'subscription_custom_fields_list', BILL_TO_CONTACT: 'bill_to_contact', BILLING_COUNTRY: 'billing_country', BILLING_STATE: 'billing_state', CATALOG_PAYMENT_OPTION_SELECTION: 'catalog_payment_option_selection', RECAPTCHA: 'recaptcha', }; var FormEvent; (function (FormEvent) { FormEvent["FORM_START"] = "FORM_START"; FormEvent["LOGIN_REGISTRATION_COMPLETE"] = "LOGIN_REGISTRATION_COMPLETE"; FormEvent["SECTION_EMAIL_COMPLETE"] = "SECTION_EMAIL_COMPLETE"; FormEvent["SECTION_PASSWORD_RESET_COMPLETE"] = "SECTION_PASSWORD_RESET_COMPLETE"; FormEvent["SECTION_FORGOT_PASSWORD_COMPLETE"] = "SECTION_FORGOT_PASSWORD_COMPLETE"; FormEvent["PART_PLAN_SELECT_COMPLETE"] = "PART_PLAN_SELECT_COMPLETE"; FormEvent["PART_ACCOUNT_VERIFICATION_COMPLETE"] = "PART_ACCOUNT_VERIFICATION_COMPLETE"; FormEvent["PART_GIFT_RECIPIENT_COMPLETE"] = "PART_GIFT_RECIPIENT_COMPLETE"; FormEvent["PART_PAYMENT_COMPLETE"] = "PART_PAYMENT_COMPLETE"; FormEvent["PART_SUCCESS_COMPLETE"] = "PART_SUCCESS_COMPLETE"; FormEvent["PART_CONTACT_VERIFICATION_COMPLETE"] = "PART_CONTACT_VERIFICATION_COMPLETE"; FormEvent["PART_PROFILE_UPDATE_COMPLETE"] = "PART_PROFILE_UPDATE_COMPLETE"; FormEvent["PART_EMAIL_UPDATE_COMPLETE"] = "PART_EMAIL_UPDATE_COMPLETE"; FormEvent["PART_EMAIL_UPDATE_OTP_COMPLETE"] = "PART_EMAIL_UPDATE_OTP_COMPLETE"; FormEvent["PART_EMAIL_UPDATE_CONFIRMATION_COMPLETE"] = "PART_EMAIL_UPDATE_CONFIRMATION_COMPLETE"; FormEvent["PART_PASSWORD_UPDATE_COMPLETE"] = "PART_PASSWORD_UPDATE_COMPLETE"; FormEvent["PART_PASSWORD_UPDATE_OTP_COMPLETE"] = "PART_PASSWORD_UPDATE_OTP_COMPLETE"; FormEvent["PART_ATTRIBUTES_UPDATE_COMPLETE"] = "PART_ATTRIBUTES_UPDATE_COMPLETE"; FormEvent["REGISTRATION_CUSTOM_COMPLETE"] = "REGISTRATION_CUSTOM_COMPLETE"; FormEvent["SELECT_SUBSCRIPTION_COMPLETE"] = "SELECT_SUBSCRIPTION_COMPLETE"; FormEvent["UPDATE"] = "UPDATE"; FormEvent["GO_BACK"] = "GO_BACK"; FormEvent["VERIFY_EMAIL_UPDATE_OTP"] = "VERIFY_EMAIL_UPDATE_OTP"; FormEvent["VERIFY_PASSWORD_UPDATE_OTP"] = "VERIFY_PASSWORD_UPDATE_OTP"; FormEvent["PART_CHANGE_PAYMENT_COMPLETE"] = "PART_CHANGE_PAYMENT_COMPLETE"; FormEvent["LIST_DEVICES_SESSIONS"] = "LIST_DEVICES_SESSIONS"; FormEvent["SIGN_OUT_ALL_DEVICES"] = "SIGN_OUT_ALL_DEVICES"; FormEvent["SIGN_OUT_SINGLE_DEVICE"] = "SIGN_OUT_SINGLE_DEVICE"; FormEvent["GIFT_REDEMPTION_COMPLETE"] = "GIFT_REDEMPTION_COMPLETE"; FormEvent["SUSPEND_RESUME_SUBSCRIPTION_COMPLETE"] = "SUSPEND_RESUME_SUBSCRIPTION_COMPLETE"; FormEvent["BILL_TO_CONTACT_COMPLETE"] = "BILL_TO_CONTACT_COMPLETE"; })(FormEvent || (FormEvent = {})); const partTypes = { PLAN_SELECT: { type: 'plan-select', order: 0, completionEvent: FormEvent.PART_PLAN_SELECT_COMPLETE }, ACCOUNT_VERIFICATION: { type: 'account-verification', order: 1, completionEvent: FormEvent.PART_ACCOUNT_VERIFICATION_COMPLETE }, GIFT_RECIPIENT: { type: 'gift-recipient', order: 1, completionEvent: FormEvent.PART_GIFT_RECIPIENT_COMPLETE }, PAYMENT: { type: 'payment', order: 2, completionEvent: FormEvent.PART_PAYMENT_COMPLETE }, SUCCESS: { type: 'success', order: 3, completionEvent: FormEvent.PART_SUCCESS_COMPLETE }, CONTACT_VERIFICATION: { type: 'contact-verification', order: 1, completionEvent: FormEvent.PART_CONTACT_VERIFICATION_COMPLETE }, PROFILE_UPDATE: { type: 'profile-update', order: 0, completionEvent: FormEvent.PART_PROFILE_UPDATE_COMPLETE }, SELECT_SUBSCRIPTION: { type: 'select-subscription', order: 0, completionEvent: FormEvent.SELECT_SUBSCRIPTION_COMPLETE }, EMAIL_UPDATE: { type: 'email-update', order: 0, completionEvent: FormEvent.PART_EMAIL_UPDATE_COMPLETE }, EMAIL_UPDATE_OTP: { type: 'email-update-otp', order: 0, completionEvent: FormEvent.PART_EMAIL_UPDATE_OTP_COMPLETE }, EMAIL_UPDATE_CONFIRMATION: { type: 'email-update-confirmation', order: 0, completionEvent: FormEvent.PART_EMAIL_UPDATE_CONFIRMATION_COMPLETE }, PASSWORD_UPDATE: { type: 'password-update', order: 0, completionEvent: FormEvent.PART_PASSWORD_UPDATE_COMPLETE }, PASSWORD_UPDATE_OTP: { type: 'password-update-otp', order: 0, completionEvent: FormEvent.PART_PASSWORD_UPDATE_OTP_COMPLETE }, ATTRIBUTES_UPDATE: { type: 'attributes-update', order: 0, completionEvent: FormEvent.PART_ATTRIBUTES_UPDATE_COMPLETE }, LIST_SUBSCRIPTIONS: { type: 'list-subscriptions', order: 0, }, BILLING_HISTORY: { type: 'billing-history', order: 0, }, PAST_SUBSCRIPTIONS: { type: 'past-subscriptions', order: 0, }, CHANGE_PAYMENT: { type: 'change-payment', order: 2, completionEvent: FormEvent.PART_CHANGE_PAYMENT_COMPLETE }, DEVICES_SESSIONS: { type: 'devices-sessions', order: 0, completionEvent: FormEvent.LIST_DEVICES_SESSIONS }, CANCEL_SUCCESS: { type: 'cancel-success', order: 3, }, GIFT_REDEMPTION: { type: 'gift_redemption', order: 4 }, GIFT_DETAILS: { type: 'gift-details', order: 1 }, SUSPEND_RESUME_SUBSCRIPTION: { type: 'suspend-resume-subscription', order: 0, completionEvent: FormEvent.SUSPEND_RESUME_SUBSCRIPTION_COMPLETE }, SUBSCRIPTION_CUSTOM_FIELDS: { type: 'subscription-custom-fields', order: 0, }, BILL_TO_CONTACT: { type: 'bill-to-contact', order: 0, completionEvent: FormEvent.BILL_TO_CONTACT_COMPLETE } }; const partTypeFor = (type) => Object.values(partTypes).find(p => p.type == type) || (() => { throw `No part ${type} found`; })(); var ServerError; (function (ServerError) { ServerError[ServerError["USER_DOES_NOT_EXIST"] = 0] = "USER_DOES_NOT_EXIST"; ServerError[ServerError["USER_ALREADY_EXISTS"] = 1] = "USER_ALREADY_EXISTS"; ServerError[ServerError["PASSWORD_NOT_STRONG_ENOUGH"] = 2] = "PASSWORD_NOT_STRONG_ENOUGH"; ServerError[ServerError["EMAIL_VERIFICATION_REQUIRED"] = 3] = "EMAIL_VERIFICATION_REQUIRED"; ServerError[ServerError["VERIFICATION_CODE_OR_PASSWORD_INCORRECT"] = 4] = "VERIFICATION_CODE_OR_PASSWORD_INCORRECT"; ServerError[ServerError["VERIFICATION_CODE_INCORRECT"] = 5] = "VERIFICATION_CODE_INCORRECT"; ServerError[ServerError["LOGIN_FAILED"] = 6] = "LOGIN_FAILED"; ServerError[ServerError["UNKNOWN_LOGIN_REGISTER_ERROR"] = 7] = "UNKNOWN_LOGIN_REGISTER_ERROR"; ServerError[ServerError["NO_COOKIE_FROM_LOGIN_REGISTER_ERROR"] = 8] = "NO_COOKIE_FROM_LOGIN_REGISTER_ERROR"; ServerError[ServerError["NO_ACCOUNT_ACCESS"] = 9] = "NO_ACCOUNT_ACCESS"; ServerError[ServerError["ACCOUNT_NOT_FOUND"] = 10] = "ACCOUNT_NOT_FOUND"; ServerError[ServerError["PAYMENT_PROCESSING_ERROR"] = 11] = "PAYMENT_PROCESSING_ERROR"; ServerError[ServerError["MOBILE_PAYMENT_PROCESSING_ERROR"] = 12] = "MOBILE_PAYMENT_PROCESSING_ERROR"; ServerError[ServerError["PASSWORD_RESET_LINK_SEND_ERROR"] = 13] = "PASSWORD_RESET_LINK_SEND_ERROR"; ServerError[ServerError["PASSWORD_RESET_ERROR"] = 14] = "PASSWORD_RESET_ERROR"; ServerError[ServerError["VERIFICATION_CODE_SEND_ERROR"] = 15] = "VERIFICATION_CODE_SEND_ERROR"; ServerError[ServerError["SOCIAL_SIGNIN_REGISTRATION_LOGIN_ERROR"] = 16] = "SOCIAL_SIGNIN_REGISTRATION_LOGIN_ERROR"; ServerError[ServerError["PROMO_CODE_EXPIRED_ERROR"] = 17] = "PROMO_CODE_EXPIRED_ERROR"; ServerError[ServerError["PROMO_CODE_INVALID_ERROR"] = 18] = "PROMO_CODE_INVALID_ERROR"; ServerError[ServerError["PROMO_CODE_NOT_VALID_FOR_PLAN_ERROR"] = 19] = "PROMO_CODE_NOT_VALID_FOR_PLAN_ERROR"; ServerError[ServerError["INVITATION_FAILED_LIMIT_REACHED"] = 20] = "INVITATION_FAILED_LIMIT_REACHED"; ServerError[ServerError["INVITATION_FAILED_DUPLICATE_EMAIL"] = 21] = "INVITATION_FAILED_DUPLICATE_EMAIL"; ServerError[ServerError["INVITATION_FAILED_INVALID_EMAIL"] = 22] = "INVITATION_FAILED_INVALID_EMAIL"; ServerError[ServerError["INVITATION_FAILED_NO_PRODUCT_ACCESS"] = 23] = "INVITATION_FAILED_NO_PRODUCT_ACCESS"; ServerError[ServerError["INVITATION_FAILED_UNKNOWN"] = 24] = "INVITATION_FAILED_UNKNOWN"; ServerError[ServerError["TOO_MANY_SESSIONS"] = 25] = "TOO_MANY_SESSIONS"; ServerError[ServerError["INVALID_USER_ATTRIBUTES"] = 26] = "INVALID_USER_ATTRIBUTES"; ServerError[ServerError["CONTACT_CREATION_NOT_ENABLED"] = 27] = "CONTACT_CREATION_NOT_ENABLED"; ServerError[ServerError["NO_AUTHENTICATED_SESSION"] = 28] = "NO_AUTHENTICATED_SESSION"; ServerError[ServerError["BLOCKED_EMAIL_DOMAIN"] = 29] = "BLOCKED_EMAIL_DOMAIN"; ServerError[ServerError["UNKNOWN"] = 30] = "UNKNOWN"; ServerError[ServerError["GIFT_CODE_INVALID"] = 31] = "GIFT_CODE_INVALID"; ServerError[ServerError["GIFT_CODE_ALREADY_REDEEMED"] = 32] = "GIFT_CODE_ALREADY_REDEEMED"; ServerError[ServerError["GIFT_CODE_SERVER_ERROR"] = 33] = "GIFT_CODE_SERVER_ERROR"; })(ServerError || (ServerError = {})); const ServerErrors = { [ServerError.USER_DOES_NOT_EXIST]: { languagePackKey: 'forms.errors.user-not-found', fallbackMessage: 'User not found.', jumpToPart: partTypes.ACCOUNT_VERIFICATION.type, displayOnElements: [elementTypes.EMAIL_ADDRESS] }, [ServerError.USER_ALREADY_EXISTS]: { languagePackKey: 'forms.errors.email-taken', fallbackMessage: 'This email address is already registered. Please log in to continue.', jumpToPart: partTypes.ACCOUNT_VERIFICATION.type, displayOnElements: [elementTypes.EMAIL_ADDRESS] }, [ServerError.EMAIL_VERIFICATION_REQUIRED]: { languagePackKey: 'forms.errors.email-verification-required', fallbackMessage: 'Email verification is required', jumpToPart: partTypes.ACCOUNT_VERIFICATION.type, displayOnElements: [elementTypes.EMAIL_ADDRESS] }, [ServerError.VERIFICATION_CODE_OR_PASSWORD_INCORRECT]: { languagePackKey: 'forms.errors.otp-or-password-incorrect', fallbackMessage: 'The password or code you entered is incorrect.', displayOnElements: [elementTypes.VERIFICATION_CODE, elementTypes.PASSWORD] }, [ServerError.VERIFICATION_CODE_INCORRECT]: { languagePackKey: 'forms.errors.otp-incorrect', fallbackMessage: 'The code you entered is incorrect.', displayOnElements: [elementTypes.VERIFICATION_CODE] }, [ServerError.LOGIN_FAILED]: { languagePackKey: 'forms.errors.login-failed', fallbackMessage: 'The email address or password you entered is incorrect.', displayOnElements: [elementTypes.PASSWORD, elementTypes.VERIFICATION_CODE] }, [ServerError.PASSWORD_NOT_STRONG_ENOUGH]: { languagePackKey: 'n/a', fallbackMessage: '', useDymamicMessage: true, displayOnElements: [elementTypes.PASSWORD] }, [ServerError.UNKNOWN_LOGIN_REGISTER_ERROR]: { languagePackKey: 'forms.errors.unknown-error', fallbackMessage: 'Something went wrong. Please try again later', displayOnElements: [elementTypes.PASSWORD, elementTypes.VERIFICATION_CODE] }, [ServerError.NO_COOKIE_FROM_LOGIN_REGISTER_ERROR]: { languagePackKey: 'forms.errors.unknown-error', fallbackMessage: 'Something went wrong. Please try again later', displayOnElements: [elementTypes.PASSWORD, elementTypes.VERIFICATION_CODE] }, [ServerError.NO_ACCOUNT_ACCESS]: { languagePackKey: 'forms.errors.too-many-requests', fallbackMessage: 'To gain login access, please contact your administrator.', displayOnElements: [elementTypes.PASSWORD] }, [ServerError.ACCOUNT_NOT_FOUND]: { languagePackKey: 'forms.errors.company-account-not-found', fallbackMessage: 'Account not found.', jumpToPart: partTypes.ACCOUNT_VERIFICATION.type, displayOnElements: [elementTypes.ACCOUNT_MEMBERSHIP_CODE] }, [ServerError.PAYMENT_PROCESSING_ERROR]: { languagePackKey: 'forms.errors.unknown-payment-error', fallbackMessage: 'Something went wrong when processing your payment. Please try again later.', displayOnElements: [elementTypes.PAYMENT] }, [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR]: { languagePackKey: 'forms.errors.unknown-payment-error', fallbackMessage: 'Something went wrong when processing your payment. Please try again later.', displayOnElements: [elementTypes.MOBILE_PAYMENT] }, [ServerError.PASSWORD_RESET_LINK_SEND_ERROR]: { languagePackKey: 'forms.errors.password-reset-link-send-failed', fallbackMessage: 'Unable to send a password reset link. Please try again later', displayOnElements: [elementTypes.RESET_PASSWORD_LINK] }, [ServerError.VERIFICATION_CODE_SEND_ERROR]: { languagePackKey: 'forms.errors.otp-send-failed', fallbackMessage: 'Unable to send a verification code. Please try again later', displayOnElements: [elementTypes.VERIFICATION_CODE] }, [ServerError.PASSWORD_RESET_ERROR]: { languagePackKey: 'forms.errors.password-reset-failed', fallbackMessage: 'Unable to reset your password. Please try again later', displayOnElements: [elementTypes.PASSWORD] }, [ServerError.SOCIAL_SIGNIN_REGISTRATION_LOGIN_ERROR]: { languagePackKey: 'forms.errors.unknown-error', fallbackMessage: 'Something went wrong. Please try again later', displayOnElements: [elementTypes.SOCIAL_SIGNIN] }, [ServerError.PROMO_CODE_EXPIRED_ERROR]: { languagePackKey: 'forms.errors.promo-code-expired', fallbackMessage: 'Promo code expired', displayOnElements: [elementTypes.PAYMENT_SUMMARY] }, [ServerError.PROMO_CODE_INVALID_ERROR]: { languagePackKey: 'forms.errors.promo-code-invalid', fallbackMessage: 'Invalid promo code', displayOnElements: [elementTypes.PAYMENT_SUMMARY] }, [ServerError.PROMO_CODE_NOT_VALID_FOR_PLAN_ERROR]: { languagePackKey: 'forms.errors.promo-code-invalid-for-payment-option', fallbackMessage: 'Promo code cannot be applied to selected option', displayOnElements: [elementTypes.PAYMENT_SUMMARY] }, [ServerError.INVITATION_FAILED_LIMIT_REACHED]: { languagePackKey: 'forms.errors.invitation-failed-limit-reached', fallbackMessage: 'You have reached the sharing limit for this product', displayOnElements: [elementTypes.INVITATION] }, [ServerError.INVITATION_FAILED_DUPLICATE_EMAIL]: { languagePackKey: 'forms.errors.invitation-failed-duplicate-email', fallbackMessage: 'An invite has already been created for this email', displayOnElements: [elementTypes.INVITATION] }, [ServerError.INVITATION_FAILED_INVALID_EMAIL]: { languagePackKey: 'forms.errors.invitation-failed-invalid-email', fallbackMessage: 'Invalid email address', displayOnElements: [elementTypes.INVITATION] }, [ServerError.INVITATION_FAILED_NO_PRODUCT_ACCESS]: { languagePackKey: 'forms.errors.invitation-failed-no-product-access', fallbackMessage: 'You do not currently have access to this product', displayOnElements: [elementTypes.INVITATION] }, [ServerError.INVITATION_FAILED_UNKNOWN]: { languagePackKey: 'forms.errors.unknown-error', fallbackMessage: 'Something went wrong. Please try again later', displayOnElements: [elementTypes.INVITATION] }, [ServerError.TOO_MANY_SESSIONS]: { languagePackKey: 'forms.errors.session-limit-reached', fallbackMessage: 'You have reached the session limit. Please log out from another device to access this content.', displayOnElements: [elementTypes.EMAIL_ADDRESS] }, [ServerError.INVALID_USER_ATTRIBUTES]: { languagePackKey: 'forms.errors.user-attribute-invalid', fallbackMessage: 'Invalid User Attribute', displayOnElements: [elementTypes.USER_ATTRIBUTE] }, [ServerError.CONTACT_CREATION_NOT_ENABLED]: { languagePackKey: 'forms.errors.contact-creation-disabled', fallbackMessage: 'This operation is not possible at the moment, please try again later.', jumpToPart: partTypes.ACCOUNT_VERIFICATION.type, displayOnElements: [elementTypes.EMAIL_ADDRESS] }, [ServerError.NO_AUTHENTICATED_SESSION]: { languagePackKey: 'forms.errors.no-authenticated-session', fallbackMessage: 'Please login to update your profile', }, [ServerError.BLOCKED_EMAIL_DOMAIN]: { languagePackKey: 'forms.errors.email-domain-blocked', fallbackMessage: 'Please use a different email address, this domain is not supported.', jumpToPart: partTypes.ACCOUNT_VERIFICATION.type, displayOnElements: [elementTypes.EMAIL_ADDRESS] }, [ServerError.UNKNOWN]: { languagePackKey: 'forms.errors.unknown-error', fallbackMessage: 'Something went wrong. Please try again later', }, [ServerError.GIFT_CODE_INVALID]: { languagePackKey: 'forms.errors.gift-code-invalid', fallbackMessage: 'Invalid gift code', displayOnElements: [elementTypes.GIFT_CODE] }, [ServerError.GIFT_CODE_ALREADY_REDEEMED]: { languagePackKey: 'forms.errors.gift-code-already-redeemed', fallbackMessage: 'Gift code already redeemed', displayOnElements: [elementTypes.GIFT_CODE] }, [ServerError.GIFT_CODE_SERVER_ERROR]: { languagePackKey: 'forms.errors.gift-code-server-error', fallbackMessage: 'Something went wrong with the gift code. Please try again later', displayOnElements: [elementTypes.GIFT_CODE] } }; const serverErrorForElement = (elementType, formState) => formState.serverErrors.find(e => ServerErrors[e].displayOnElements?.includes(elementType)) ?? undefined; const sectionTypes = { PLAN_SELECT: { type: 'plan_select', defaultLabel: 'Plan Select', fullWidth: true }, EMAIL: { type: 'email', defaultLabel: 'Account Verification', completionEvent: FormEvent.SECTION_EMAIL_COMPLETE, }, RECIPIENT_DETAILS: { type: 'recipient_details', defaultLabel: 'Recipient', }, PASSWORD_SETUP: { type: 'password_setup', defaultLabel: 'Password Setup' }, PASSWORDLESS_VIA_LOGIN_LINK: { type: 'passwordless_login_via_link', defaultLabel: 'Passwordless Login via Login Link' }, VERIFICATION_CODE_LOGIN: { type: 'verification_code_login', defaultLabel: '' }, VERIFICATION_CODE_REGISTRATION: { type: 'verification_code_registration', defaultLabel: '' }, LOGIN_PASSWORD: { type: 'login_password', defaultLabel: 'Login' }, REGISTRATION_CUSTOM: { type: 'registration_custom', defaultLabel: '', }, FORGOT_PASSWORD: { type: 'forgot_password', defaultLabel: '', completionEvent: FormEvent.SECTION_FORGOT_PASSWORD_COMPLETE, }, PASSWORD_RESET: { type: 'reset_password', defaultLabel: '', completionEvent: FormEvent.SECTION_PASSWORD_RESET_COMPLETE, }, SUCCESS: { type: 'success', defaultLabel: '' }, EMAIL_VERIFIED: { type: 'email_verified', defaultLabel: '' }, READ_ONLY_PROFILE: { type: 'read_only_profile', defaultLabel: 'Read Only Profile' }, UPDATE_EMAIL: { type: 'update_email', defaultLabel: 'Update Email' }, EMAIL_UPDATE_CONFIRMATION: { type: 'email_update_confirmation', defaultLabel: 'Email Update Confirmation' }, UPDATE_PASSWORD: { type: 'update_password', defaultLabel: 'Update Password' }, UPDATE_ATTRIBUTES: { type: 'update_attributes', defaultLabel: 'Update Attributes' }, CHANGE_PAYMENT: { type: 'change-payment', completionEvent: FormEvent.PART_CHANGE_PAYMENT_COMPLETE, defaultLabel: '' }, SELECT: { type: 'select', defaultLabel: '', fullWidth: true, }, LIST: { type: 'list', defaultLabel: '', fullWidth: true, }, PAST_SUBSCRIPTIONS: { type: 'past-subscriptions', defaultLabel: '', fullWidth: true, }, GIFT_REDEMPTION: { type: 'gift_redemption', defaultLabel: 'Gift Code Redemption', completionEvent: FormEvent.GIFT_REDEMPTION_COMPLETE }, GIFT_REDEEMED: { type: 'gift_redeemed', defaultLabel: 'Gift Redeemed' }, GIFT_DETAIL: { type: 'gift-detail', defaultLabel: 'Gift Details' }, SUSPEND_RESUME_SUBSCRIPTION: { type: 'suspend_resume_subscription', defaultLabel: 'Suspend/Resume Subscription', }, BILL_TO_CONTACT: { type: 'bill_to_contact', defaultLabel: 'Update Bill To Contact Address', }, RECAPTCHA: { type: 'recaptcha', defaultLabel: '', }, }; const sectionTypeFor = (type) => Object.values(sectionTypes).find(s => s.type == type); function logDataLayerEvent(form, eventName, customDimensions) { const event = { event: eventName, formType: form.formType, formId: form.formId, ruleId: form.ruleId, outcomeId: form.outcomeId, ...customDimensions }; window.postMessage({ 'zephr-form-datalayer-event': event }, window.origin); if (!form.organisationConfiguration.trackFormDataLayerEvents) { return; } const dataLayerName = form.organisationConfiguration.dataLayerName || 'dataLayer'; window[dataLayerName] = window[dataLayerName] || []; window[dataLayerName].push(event); } const reScrollToFormTop = (formId) => { try { const formRootElement = document.getElementById(formId); if (!formRootElement) return; const { top } = formRootElement.getBoundingClientRect(); if (top { return form.parts .flatMap(part => part.sections.map(section => ({ part, section }))) .find(partSection => partSection.section.type === sectionType); }; const findSectionByAddress = (address, form) => { const [part, section] = address.includes(':') ? address.split(':') : [null, address]; return form.parts .flatMap(part => part.sections.map(section => ({ part, section }))) .find(partSection => partSection.section.type === section && (!part || partSection.part.type === part)); }; const jumpToSection = (sectionType, form, formActions) => { const destination = findSection(sectionType, form); if (!destination) { throw `Cannot find section ${sectionType}`; } const formState = formActions.getFormState(); setSection({ form, formActions, part: destination.part, section: destination.section, previousPart: formState.currentPart, previousSection: formState.currentSection }); return Promise.resolve(); }; const jumpToPart = (partType, form, formActions) => { if (form.environment.previewMode) { return; } const part = form.parts.find(p => p.type == partType); const formState = formActions.getFormState(); setSection({ form, formActions, part, section: part.sections[0], previousPart: formState.currentPart, previousSection: formState.currentSection }); return Promise.resolve(); }; const findNextPart = (currentPart, form) => { const partType = partTypeFor(currentPart.type); if (partType) { const nextPart = form.parts.find((p) => partTypeFor(p.type).order === partType.order + 1) ?? form.parts[form.parts.indexOf(currentPart) + 1]; if (nextPart) { return { section: nextPart.sections[0], part: nextPart }; } } return null; }; const findNextSection = (currentSection, currentPart, form) => { // Next section in part ... const currentSectionIndex = currentPart.sections.findIndex((s) => s.order == currentSection.order); if (currentPart.sections.length > currentSectionIndex + 1) { return { section: currentPart.sections[currentSectionIndex + 1], part: currentPart }; } // ... or the first setion in next part return findNextPart(currentPart, form); }; const mapCustomSectionType = (sectionType) => { return sectionType?.startsWith('custom_') ? 'registration_custom' : sectionType; }; const isSectionVisible = (section, form, formState) => form.sectionFlow.sectionVisibilities.find((s) => s.type === mapCustomSectionType(section.type)) ?.isVisible(form, formState) ?? true; const isSectionDisplayedInProgressBar = (section, form, formState) => { const sectionConfig = form.sectionFlow.sectionVisibilities .find((s) => (s.type === mapCustomSectionType(section.type))); return (sectionConfig?.isDisplayedInProgressBar && isSectionVisible(section, form, formState)) ?? true; }; const moveToNextSection = (form, formState, formActions) => { if (form.environment.previewMode) { return; } // Find the next visible section let i = 0; let nextPartSection = { part: formState.currentPart, section: formState.currentSection }; do { i++; if (i > 50) { throw new Error(`Cannot move from ${formState.currentPart.type}:${formState.currentSection.type}. Exceeded max loop size after ${nextPartSection?.part?.type}:${nextPartSection?.section?.type} `); } const next = findNextSection(nextPartSection?.section, nextPartSection?.part, form); if (next?.part.type === nextPartSection?.part?.type && next?.section.type === nextPartSection?.section?.type && next?.section.order === nextPartSection?.section?.order) { throw new Error(`Cannot move from ${formState.currentPart.type}:${formState.currentSection.type}. Infinte loop found at next section ${next?.part?.type}:${next?.section?.type} `); } nextPartSection = next; } while (nextPartSection && !isSectionVisible(nextPartSection.section, form, formState)); if (!nextPartSection || nextPartSection.part !== formState.currentPart) { const part = partTypeFor(formState.currentPart.type); const action = part?.completionEvent && form.sectionFlow.eventHandlers[part.completionEvent]; if (action) { return action(form, formState, formActions); } } if (!nextPartSection) { throw "No next section"; } setSection({ form, formActions, part: nextPartSection.part, section: nextPartSection.section, previousPart: formState.currentPart, previousSection: formState.currentSection }); return Promise.resolve(); }; const completeSection = (form, formState, formActions) => { if (form.environment.previewMode) { return; } const sectionType = sectionTypeFor(formState.currentSection.type); const action = (sectionType && form.sectionFlow.eventHandlers[sectionType.completionEvent]) ?? moveToNextSection; return action(form, formState, formActions); }; const attemptCompleteSection = (form, _, formActions) => { if (formActions.getFormState().canAttemptSectionCompletion) { const updatedState = formActions.updateFormState({ showFieldErrors: false }); return completeSection(form, updatedState, formActions); } formActions.updateFormState({ showFieldErrors: true }); return Promise.resolve(); }; const setSection = ({ form, formActions, part, section, previousSection, previousPart }) => { formActions.updateFormState({ currentPart: part, currentSection: section }); logDataLayerEvent(form, 'zephr_form_section_change', { sectionId: section.type, previousSectionId: previousSection.type, partId: part.type, previousPartId: previousPart.type }); reScrollToFormTop(form.formId); }; /* src/components/elements/progressBar/ProgressBar.svelte generated by Svelte v4.2.12 */ function get_each_context$j(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[7] = list[i]; const constants_0 = !/*disabled*/ child_ctx[0] && !/*item*/ child_ctx[7].isDisabled && /*item*/ child_ctx[7].order { item.onSelect(); }; $$self.$$set = $$props => { if ('disabled' in $$props) $$invalidate(0, disabled = $$props.disabled); if ('items' in $$props) $$invalidate(5, items = $$props.items); if ('isPaymentForm' in $$props) $$invalidate(1, isPaymentForm = $$props.isPaymentForm); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*items*/ 32) { $$invalidate(2, currentItem = items.find(i => i.isCurrent)); } if ($$self.$$.dirty & /*items*/ 32) { $$invalidate(3, visibleItems = items.filter(i => i.isVisible)); } if ($$self.$$.dirty & /*visibleItems, currentItem*/ 12) { $$invalidate(4, value = Math.floor(100 / (visibleItems.length - 1) * (currentItem.isVisible ? currentItem.visibleOrder : Math.max.apply(Math, visibleItems.filter(i => i.order i.visibleOrder))))); } }; return [ disabled, isPaymentForm, currentItem, visibleItems, value, items, click_handler ]; } class ProgressBar extends SvelteComponent { constructor(options) { super(); init(this, options, instance$1d, create_fragment$1f, safe_not_equal, { disabled: 0, items: 5, isPaymentForm: 1 }); } } var FormType; (function (FormType) { FormType["EMPTY"] = "EMPTY"; FormType["PAYMENT"] = "PAYMENT"; FormType["CHANGE_SUBSCRIPTION"] = "CHANGE_SUBSCRIPTION"; FormType["REGISTRATION"] = "REGISTRATION"; FormType["CONTACT"] = "CONTACT"; FormType["DATA_CAPTURE"] = "DATA_CAPTURE"; FormType["COMPLETE_REGISTRATION"] = "COMPLETE_REGISTRATION"; FormType["UPDATE_PROFILE"] = "UPDATE_PROFILE"; FormType["CANCEL_SUBSCRIPTION"] = "CANCEL_SUBSCRIPTION"; FormType["LIST_SUBSCRIPTIONS"] = "LIST_SUBSCRIPTIONS"; FormType["SUSPEND_RESUME_SUBSCRIPTION"] = "SUSPEND_RESUME_SUBSCRIPTION"; FormType["DEVICES"] = "DEVICES"; FormType["GIFT_SUBSCRIPTION"] = "GIFT_SUBSCRIPTION"; FormType["GIFT_REDEMPTION"] = "GIFT_REDEMPTION"; FormType["LIST_GIFT_SUBSCRIPTIONS_SENT"] = "LIST_GIFT_SUBSCRIPTIONS_SENT"; FormType["BILL_TO_CONTACT"] = "BILL_TO_CONTACT"; FormType["CATALOG_PAYMENT"] = "CATALOG_PAYMENT"; })(FormType || (FormType = {})); const toProgressBarItems = (form, formState, formActions) => { let order = 0; let visibleOrder = 0; return form.parts.flatMap(part => part.sections .map(section => ({ part, section }))) .map(({ part, section }) => ({ type: section.type, isVisible: isSectionDisplayedInProgressBar(section, form, formState), label: (section.label ?? part.label) ?? sectionTypeFor(section.type)?.defaultLabel, isCurrent: formState.currentSection == section, // Do not allow users to go backwards from PAYMENT if they have just registered isDisabled: formState.loginRegistrationComplete && ![partTypes.PLAN_SELECT.type ].includes(part.type), order: order++, visibleOrder: isSectionDisplayedInProgressBar(section, form, formState) ? visibleOrder++ : null, onSelect: () => setSection({ form, formActions, part, section, previousSection: formState.currentSection, previousPart: formState.currentPart }) })); }; const factory$w = { matches: (sectionElement) => sectionElement.type === elementTypes.PROGRESS_BAR, create: (form, formState, formActions) => { return { component: ProgressBar, props: { disabled: formState.isBusy, items: toProgressBarItems(form, formState, formActions), isPaymentForm: form.formType === FormType.PAYMENT, } }; } }; const formConfigAs = (form) => { return form.typeConfiguration; }; /* src/components/elements/button/Button.svelte generated by Svelte v4.2.12 */ function create_fragment$1e(ctx) { let button; let t; let button_style_value; let mounted; let dispose; return { c() { button = element("button"); t = text(/*text*/ ctx[1]); attr(button, "class", "zephr-form-button svelte-gd8hr6"); attr(button, "type", "submit"); button.hidden = /*hidden*/ ctx[6]; attr(button, "style", button_style_value = /*hidden*/ ctx[6] ? 'display:none' : undefined); button.disabled = /*disabled*/ ctx[0]; toggle_class(button, "zephr-payment-form-button", /*isPaymentForm*/ ctx[5]); toggle_class(button, "zephr-form-button-top-margin", !/*noMargin*/ ctx[2]); toggle_class(button, "zephr-payment-form-button-top-margin", /*isPaymentForm*/ ctx[5] && !/*noMargin*/ ctx[2]); toggle_class(button, "inputHeight", /*inputHeight*/ ctx[3]); toggle_class(button, "aside", /*aside*/ ctx[4]); }, m(target, anchor) { insert(target, button, anchor); append(button, t); if (!mounted) { dispose = listen(button, "click", prevent_default(function () { if (is_function(/*onClick*/ ctx[7])) /*onClick*/ ctx[7].apply(this, arguments); })); mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if (dirty & /*text*/ 2) set_data(t, /*text*/ ctx[1]); if (dirty & /*hidden*/ 64) { button.hidden = /*hidden*/ ctx[6]; } if (dirty & /*hidden*/ 64 && button_style_value !== (button_style_value = /*hidden*/ ctx[6] ? 'display:none' : undefined)) { attr(button, "style", button_style_value); } if (dirty & /*disabled*/ 1) { button.disabled = /*disabled*/ ctx[0]; } if (dirty & /*isPaymentForm*/ 32) { toggle_class(button, "zephr-payment-form-button", /*isPaymentForm*/ ctx[5]); } if (dirty & /*noMargin*/ 4) { toggle_class(button, "zephr-form-button-top-margin", !/*noMargin*/ ctx[2]); } if (dirty & /*isPaymentForm, noMargin*/ 36) { toggle_class(button, "zephr-payment-form-button-top-margin", /*isPaymentForm*/ ctx[5] && !/*noMargin*/ ctx[2]); } if (dirty & /*inputHeight*/ 8) { toggle_class(button, "inputHeight", /*inputHeight*/ ctx[3]); } if (dirty & /*aside*/ 16) { toggle_class(button, "aside", /*aside*/ ctx[4]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(button); } mounted = false; dispose(); } }; } function instance$1c($$self, $$props, $$invalidate) { let { disabled } = $$props; let { text } = $$props; let { noMargin = false } = $$props; let { inputHeight = false } = $$props; let { aside = false } = $$props; let { isPaymentForm = false } = $$props; let { hidden = false } = $$props; let { onClick } = $$props; $$self.$$set = $$props => { if ('disabled' in $$props) $$invalidate(0, disabled = $$props.disabled); if ('text' in $$props) $$invalidate(1, text = $$props.text); if ('noMargin' in $$props) $$invalidate(2, noMargin = $$props.noMargin); if ('inputHeight' in $$props) $$invalidate(3, inputHeight = $$props.inputHeight); if ('aside' in $$props) $$invalidate(4, aside = $$props.aside); if ('isPaymentForm' in $$props) $$invalidate(5, isPaymentForm = $$props.isPaymentForm); if ('hidden' in $$props) $$invalidate(6, hidden = $$props.hidden); if ('onClick' in $$props) $$invalidate(7, onClick = $$props.onClick); }; return [disabled, text, noMargin, inputHeight, aside, isPaymentForm, hidden, onClick]; } class Button extends SvelteComponent { constructor(options) { super(); init(this, options, instance$1c, create_fragment$1e, safe_not_equal, { disabled: 0, text: 1, noMargin: 2, inputHeight: 3, aside: 4, isPaymentForm: 5, hidden: 6, onClick: 7 }); } } /* src/components/elements/paymentOptionSelection/PaymentOptionComponent.svelte generated by Svelte v4.2.12 */ function create_if_block_1$z(ctx) { let div; let t_value = /*paymentOption*/ ctx[1].highlightedText + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "box-top-text svelte-hcxnnv"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*paymentOption*/ 2 && t_value !== (t_value = /*paymentOption*/ ctx[1].highlightedText + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (38:8) {#if paymentOption.disclaimerMessage} function create_if_block$M(ctx) { let span; let t_value = /*paymentOption*/ ctx[1].disclaimerMessage + ""; let t; return { c() { span = element("span"); t = text(t_value); attr(span, "class", "button-sub-text svelte-hcxnnv"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty & /*paymentOption*/ 2 && t_value !== (t_value = /*paymentOption*/ ctx[1].disclaimerMessage + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(span); } } }; } function create_fragment$1d(ctx) { let div5; let input; let input_id_value; let input_value_value; let t0; let div4; let div0; let t1; let div3; let div1; let raw_value = (/*paymentOption*/ ctx[1].description ?? '') + ""; let t2; let div2; let button; let t3; let div3_class_value; let div4_class_value; let current; let mounted; let dispose; let if_block0 = /*paymentOption*/ ctx[1].highlightedText && create_if_block_1$z(ctx); button = new Button({ props: { disabled: false, text: /*paymentOption*/ ctx[1].selectButtonText ?? 'Select Plan', onClick: /*onSelect*/ ctx[0], isPaymentForm: true } }); let if_block1 = /*paymentOption*/ ctx[1].disclaimerMessage && create_if_block$M(ctx); return { c() { div5 = element("div"); input = element("input"); t0 = space(); div4 = element("div"); div0 = element("div"); if (if_block0) if_block0.c(); t1 = space(); div3 = element("div"); div1 = element("div"); t2 = space(); div2 = element("div"); create_component(button.$$.fragment); t3 = space(); if (if_block1) if_block1.c(); attr(input, "type", "radio"); attr(input, "name", "boxSelect"); attr(input, "id", input_id_value = "boxSelect-" + /*paymentOption*/ ctx[1].slug + "-" + /*paymentOption*/ ctx[1].productId + "}"); input.value = input_value_value = /*paymentOption*/ ctx[1].price; attr(input, "class", "svelte-hcxnnv"); attr(div0, "class", "box-top svelte-hcxnnv"); attr(div1, "class", "box-content svelte-hcxnnv"); toggle_class(div1, "styled-box-content", /*styleDescription*/ ctx[2]); attr(div2, "class", "box-bottom svelte-hcxnnv"); attr(div3, "class", div3_class_value = "inner-box " + (/*paymentOption*/ ctx[1].highlightedText || '') + " svelte-hcxnnv"); attr(div4, "class", div4_class_value = "box-container " + (/*paymentOption*/ ctx[1].highlightedText ? 'highlighted' : '') + " svelte-hcxnnv"); attr(div4, "aria-hidden", "true"); set_style(div4, "cursor", "pointer"); attr(div5, "class", "payment-option-wrapper svelte-hcxnnv"); }, m(target, anchor) { insert(target, div5, anchor); append(div5, input); append(div5, t0); append(div5, div4); append(div4, div0); if (if_block0) if_block0.m(div0, null); append(div4, t1); append(div4, div3); append(div3, div1); div1.innerHTML = raw_value; append(div3, t2); append(div3, div2); mount_component(button, div2, null); append(div2, t3); if (if_block1) if_block1.m(div2, null); current = true; if (!mounted) { dispose = listen(div4, "click", prevent_default(function () { if (is_function(/*onSelect*/ ctx[0])) /*onSelect*/ ctx[0].apply(this, arguments); })); mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if (!current || dirty & /*paymentOption*/ 2 && input_id_value !== (input_id_value = "boxSelect-" + /*paymentOption*/ ctx[1].slug + "-" + /*paymentOption*/ ctx[1].productId + "}")) { attr(input, "id", input_id_value); } if (!current || dirty & /*paymentOption*/ 2 && input_value_value !== (input_value_value = /*paymentOption*/ ctx[1].price)) { input.value = input_value_value; } if (/*paymentOption*/ ctx[1].highlightedText) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$z(ctx); if_block0.c(); if_block0.m(div0, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if ((!current || dirty & /*paymentOption*/ 2) && raw_value !== (raw_value = (/*paymentOption*/ ctx[1].description ?? '') + "")) div1.innerHTML = raw_value; if (!current || dirty & /*styleDescription*/ 4) { toggle_class(div1, "styled-box-content", /*styleDescription*/ ctx[2]); } const button_changes = {}; if (dirty & /*paymentOption*/ 2) button_changes.text = /*paymentOption*/ ctx[1].selectButtonText ?? 'Select Plan'; if (dirty & /*onSelect*/ 1) button_changes.onClick = /*onSelect*/ ctx[0]; button.$set(button_changes); if (/*paymentOption*/ ctx[1].disclaimerMessage) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$M(ctx); if_block1.c(); if_block1.m(div2, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (!current || dirty & /*paymentOption*/ 2 && div3_class_value !== (div3_class_value = "inner-box " + (/*paymentOption*/ ctx[1].highlightedText || '') + " svelte-hcxnnv")) { attr(div3, "class", div3_class_value); } if (!current || dirty & /*paymentOption*/ 2 && div4_class_value !== (div4_class_value = "box-container " + (/*paymentOption*/ ctx[1].highlightedText ? 'highlighted' : '') + " svelte-hcxnnv")) { attr(div4, "class", div4_class_value); } }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div5); } if (if_block0) if_block0.d(); destroy_component(button); if (if_block1) if_block1.d(); mounted = false; dispose(); } }; } function instance$1b($$self, $$props, $$invalidate) { let { onSelect } = $$props; let { paymentOption } = $$props; let { styleDescription } = $$props; $$self.$$set = $$props => { if ('onSelect' in $$props) $$invalidate(0, onSelect = $$props.onSelect); if ('paymentOption' in $$props) $$invalidate(1, paymentOption = $$props.paymentOption); if ('styleDescription' in $$props) $$invalidate(2, styleDescription = $$props.styleDescription); }; return [onSelect, paymentOption, styleDescription]; } class PaymentOptionComponent extends SvelteComponent { constructor(options) { super(); init(this, options, instance$1b, create_fragment$1d, safe_not_equal, { onSelect: 0, paymentOption: 1, styleDescription: 2 }); } } /* src/components/elements/paymentOptionSelection/PaymentOptionSelectionComponent.svelte generated by Svelte v4.2.12 */ function get_each_context$i(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[6] = list[i]; return child_ctx; } // (12:2) {#each orderedPaymentOptions as paymentOption} function create_each_block$i(ctx) { let paymentoptioncomponent; let current; function func() { return /*func*/ ctx[5](/*paymentOption*/ ctx[6]); } paymentoptioncomponent = new PaymentOptionComponent({ props: { paymentOption: /*paymentOption*/ ctx[6], styleDescription: /*config*/ ctx[0].styleDescription, onSelect: func } }); return { c() { create_component(paymentoptioncomponent.$$.fragment); }, m(target, anchor) { mount_component(paymentoptioncomponent, target, anchor); current = true; }, p(new_ctx, dirty) { ctx = new_ctx; const paymentoptioncomponent_changes = {}; if (dirty & /*orderedPaymentOptions*/ 4) paymentoptioncomponent_changes.paymentOption = /*paymentOption*/ ctx[6]; if (dirty & /*config*/ 1) paymentoptioncomponent_changes.styleDescription = /*config*/ ctx[0].styleDescription; if (dirty & /*onSelect, orderedPaymentOptions*/ 6) paymentoptioncomponent_changes.onSelect = func; paymentoptioncomponent.$set(paymentoptioncomponent_changes); }, i(local) { if (current) return; transition_in(paymentoptioncomponent.$$.fragment, local); current = true; }, o(local) { transition_out(paymentoptioncomponent.$$.fragment, local); current = false; }, d(detaching) { destroy_component(paymentoptioncomponent, detaching); } }; } function create_fragment$1c(ctx) { let div; let current; let each_value = ensure_array_like(/*orderedPaymentOptions*/ ctx[2]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { div = element("div"); for (let i = 0; i onSelect(paymentOption); $$self.$$set = $$props => { if ('paymentOptions' in $$props) $$invalidate(3, paymentOptions = $$props.paymentOptions); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('onSelect' in $$props) $$invalidate(1, onSelect = $$props.onSelect); if ('logView' in $$props) $$invalidate(4, logView = $$props.logView); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*paymentOptions*/ 8) { $$invalidate(2, orderedPaymentOptions = paymentOptions.sort((a, b) => a.fieldOrder - b.fieldOrder)); } }; return [config, onSelect, orderedPaymentOptions, paymentOptions, logView, func]; } class PaymentOptionSelectionComponent extends SvelteComponent { constructor(options) { super(); init(this, options, instance$1a, create_fragment$1c, safe_not_equal, { paymentOptions: 3, config: 0, onSelect: 1, logView: 4 }); } } const filterValidPaymentOptions$1 = (form, formState) => { if (!formConfigAs(form).changeSubscriptionMode) { return formConfigAs(form).paymentOptions; } return formConfigAs(form).paymentOptions .filter(paymentOption => formState .validChangeFromPlans .some(validPlan => validPlan.productId === paymentOption.productId && validPlan.planSlug === paymentOption.slug)); }; const factory$v = { matches: (sectionElement) => sectionElement.type === elementTypes.PAYMENT_OPTION_SELECTION, create: (form, formState, formActions, elementConfig) => ({ component: PaymentOptionSelectionComponent, props: { paymentOptions: filterValidPaymentOptions$1(form, formState), config: elementConfig ? elementConfig : {}, onSelect: (paymentOption) => { const paymentOptionKey = `${paymentOption.productId}-${paymentOption.slug}`; const updateState = { paymentOption: { ...paymentOption, autoRenewConfig: paymentOption.autoRenewConfig, autoRenewToggleLabel: paymentOption.autoRenewToggleLabel }, serverErrors: [], billingAddress: { country: null, postalCode: null, } }; // Only initialize auto-renew state for payment options with custom_toggle config if (paymentOption.autoRenewConfig === 'custom_toggle') { updateState.paymentOptionAutoRenew = { ...formState.paymentOptionAutoRenew, [paymentOptionKey]: paymentOption.terms?.autoRenew ?? false }; } formActions.updateFormState(updateState); if (form.organisationConfiguration.trackFormDataLayerEvents) { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); } void formActions.completeSection(); }, logView: () => { filterValidPaymentOptions$1(form, formState).forEach(paymentOption => logDataLayerEvent(form, 'view_item', { ecommerce: { currency: formConfigAs(form).formCurrency ?? paymentOption?.currencyCode, value: paymentOption.price, items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOption.price, quantity: 1 }] } })); } } }) }; /* src/components/elements/ErrorMessage.svelte generated by Svelte v4.2.12 */ function create_fragment$1b(ctx) { let div1; let div0; let t; return { c() { div1 = element("div"); div0 = element("div"); t = text(/*error*/ ctx[0]); attr(div0, "class", "zephr-form-error-message svelte-1ko2lqj"); attr(div0, "aria-live", "assertive"); toggle_class(div0, "zephr-payment-form-error-message", !/*isPaymentForm*/ ctx[1]); attr(div1, "class", "zephr-form-error-message-min-height svelte-1ko2lqj"); toggle_class(div1, "zephr-payment-form-error-message-min-height", !/*isPaymentForm*/ ctx[1]); }, m(target, anchor) { insert(target, div1, anchor); append(div1, div0); append(div0, t); }, p(ctx, [dirty]) { if (dirty & /*error*/ 1) set_data(t, /*error*/ ctx[0]); if (dirty & /*isPaymentForm*/ 2) { toggle_class(div0, "zephr-payment-form-error-message", !/*isPaymentForm*/ ctx[1]); } if (dirty & /*isPaymentForm*/ 2) { toggle_class(div1, "zephr-payment-form-error-message-min-height", !/*isPaymentForm*/ ctx[1]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div1); } } }; } function instance$19($$self, $$props, $$invalidate) { let { error } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('error' in $$props) $$invalidate(0, error = $$props.error); if ('isPaymentForm' in $$props) $$invalidate(1, isPaymentForm = $$props.isPaymentForm); }; return [error, isPaymentForm]; } class ErrorMessage extends SvelteComponent { constructor(options) { super(); init(this, options, instance$19, create_fragment$1b, safe_not_equal, { error: 0, isPaymentForm: 1 }); } } /* src/components/elements/Input.svelte generated by Svelte v4.2.12 */ function create_if_block_1$y(ctx) { let button; let span; let t; let mounted; let dispose; return { c() { button = element("button"); span = element("span"); t = text(/*innerText*/ ctx[16]); attr(span, "class", "zephr-form-input-inner-text"); toggle_class(span, "zephr-payment-form-input-inner-text", /*isPaymentForm*/ ctx[7]); attr(button, "type", "button"); attr(button, "class", "zephr-form-input-inner-button"); }, m(target, anchor) { insert(target, button, anchor); append(button, span); append(span, t); /*button_binding*/ ctx[28](button); if (!mounted) { dispose = listen(button, "click", prevent_default(function () { if (is_function(/*innerTextOnClick*/ ctx[17])) /*innerTextOnClick*/ ctx[17].apply(this, arguments); })); mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*innerText*/ 65536) set_data(t, /*innerText*/ ctx[16]); if (dirty & /*isPaymentForm*/ 128) { toggle_class(span, "zephr-payment-form-input-inner-text", /*isPaymentForm*/ ctx[7]); } }, d(detaching) { if (detaching) { detach(button); } /*button_binding*/ ctx[28](null); mounted = false; dispose(); } }; } // (89:0) {#if errorMessage} function create_if_block$L(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*errorMessage*/ ctx[6], isPaymentForm: /*isPaymentForm*/ ctx[7] } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, dirty) { const errormessage_changes = {}; if (dirty & /*errorMessage*/ 64) errormessage_changes.error = /*errorMessage*/ ctx[6]; if (dirty & /*isPaymentForm*/ 128) errormessage_changes.isPaymentForm = /*isPaymentForm*/ ctx[7]; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function create_fragment$1a(ctx) { let div; let input; let input_value_value; let input_autocomplete_value; let input_checked_value; let input_placeholder_value; let input_pattern_value; let input_min_value; let input_max_value; let input_step_value; let input_class_value; let t0; let t1; let t2; let if_block1_anchor; let current; let mounted; let dispose; let if_block0 = /*innerText*/ ctx[16] && create_if_block_1$y(ctx); const default_slot_template = /*#slots*/ ctx[26].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], null); let if_block1 = /*errorMessage*/ ctx[6] && create_if_block$L(ctx); return { c() { div = element("div"); input = element("input"); t0 = space(); if (if_block0) if_block0.c(); t1 = space(); if (default_slot) default_slot.c(); t2 = space(); if (if_block1) if_block1.c(); if_block1_anchor = empty(); attr(input, "id", /*id*/ ctx[0]); attr(input, "name", /*name*/ ctx[1]); input.required = /*required*/ ctx[3]; input.disabled = /*disabled*/ ctx[4]; attr(input, "type", /*type*/ ctx[2]); input.value = input_value_value = /*value*/ ctx[8] || null; attr(input, "autocomplete", input_autocomplete_value = /*autocomplete*/ ctx[19] || null); input.checked = input_checked_value = /*checked*/ ctx[10] || null; attr(input, "placeholder", input_placeholder_value = /*placeholder*/ ctx[9] || null); attr(input, "pattern", input_pattern_value = /*pattern*/ ctx[11] || null); attr(input, "min", input_min_value = /*min*/ ctx[12] || null); attr(input, "max", input_max_value = /*max*/ ctx[13] || null); attr(input, "maxlength", /*maxlength*/ ctx[15]); attr(input, "step", input_step_value = /*step*/ ctx[14] || null); attr(input, "class", input_class_value = "" + (null_to_empty(`zephr-form-input ${/*type*/ ctx[2] && `zephr-form-input-${/*type*/ ctx[2]}`} ${/*isPaymentForm*/ ctx[7] && /*type*/ ctx[2] && `zephr-payment-form-input-${/*type*/ ctx[2]}`}`) + " svelte-88cmol")); toggle_class(input, "disabled", /*disabled*/ ctx[4]); toggle_class(input, "error", /*hasError*/ ctx[5] || /*errorMessage*/ ctx[6]); toggle_class(input, "zephr-form-input-full-width", /*fill*/ ctx[18]); toggle_class(input, "zephr-payment-form-input", /*isPaymentForm*/ ctx[7]); toggle_class(input, "zephr-payment-form-input-full-width", /*isPaymentForm*/ ctx[7] && /*fill*/ ctx[18]); attr(div, "class", "zephr-form-input-inner-container svelte-88cmol"); toggle_class(div, "zephr-payment-form-input-inner-container", /*isPaymentForm*/ ctx[7]); }, m(target, anchor) { insert(target, div, anchor); append(div, input); /*input_binding*/ ctx[27](input); append(div, t0); if (if_block0) if_block0.m(div, null); insert(target, t1, anchor); if (default_slot) { default_slot.m(target, anchor); } insert(target, t2, anchor); if (if_block1) if_block1.m(target, anchor); insert(target, if_block1_anchor, anchor); current = true; if (!mounted) { dispose = [ listen(input, "focus", function () { if (is_function(/*onFocus*/ ctx[20])) /*onFocus*/ ctx[20].apply(this, arguments); }), listen(input, "blur", function () { if (is_function(/*onBlur*/ ctx[21])) /*onBlur*/ ctx[21].apply(this, arguments); }), listen(input, "input", /*handleInputChange*/ ctx[24]), listen(input, "paste", /*handleInputChange*/ ctx[24]) ]; mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if (!current || dirty & /*id*/ 1) { attr(input, "id", /*id*/ ctx[0]); } if (!current || dirty & /*name*/ 2) { attr(input, "name", /*name*/ ctx[1]); } if (!current || dirty & /*required*/ 8) { input.required = /*required*/ ctx[3]; } if (!current || dirty & /*disabled*/ 16) { input.disabled = /*disabled*/ ctx[4]; } if (!current || dirty & /*type*/ 4) { attr(input, "type", /*type*/ ctx[2]); } if (!current || dirty & /*value*/ 256 && input_value_value !== (input_value_value = /*value*/ ctx[8] || null) && input.value !== input_value_value) { input.value = input_value_value; } if (!current || dirty & /*autocomplete*/ 524288 && input_autocomplete_value !== (input_autocomplete_value = /*autocomplete*/ ctx[19] || null)) { attr(input, "autocomplete", input_autocomplete_value); } if (!current || dirty & /*checked*/ 1024 && input_checked_value !== (input_checked_value = /*checked*/ ctx[10] || null)) { input.checked = input_checked_value; } if (!current || dirty & /*placeholder*/ 512 && input_placeholder_value !== (input_placeholder_value = /*placeholder*/ ctx[9] || null)) { attr(input, "placeholder", input_placeholder_value); } if (!current || dirty & /*pattern*/ 2048 && input_pattern_value !== (input_pattern_value = /*pattern*/ ctx[11] || null)) { attr(input, "pattern", input_pattern_value); } if (!current || dirty & /*min*/ 4096 && input_min_value !== (input_min_value = /*min*/ ctx[12] || null)) { attr(input, "min", input_min_value); } if (!current || dirty & /*max*/ 8192 && input_max_value !== (input_max_value = /*max*/ ctx[13] || null)) { attr(input, "max", input_max_value); } if (!current || dirty & /*maxlength*/ 32768) { attr(input, "maxlength", /*maxlength*/ ctx[15]); } if (!current || dirty & /*step*/ 16384 && input_step_value !== (input_step_value = /*step*/ ctx[14] || null)) { attr(input, "step", input_step_value); } if (!current || dirty & /*type, isPaymentForm*/ 132 && input_class_value !== (input_class_value = "" + (null_to_empty(`zephr-form-input ${/*type*/ ctx[2] && `zephr-form-input-${/*type*/ ctx[2]}`} ${/*isPaymentForm*/ ctx[7] && /*type*/ ctx[2] && `zephr-payment-form-input-${/*type*/ ctx[2]}`}`) + " svelte-88cmol"))) { attr(input, "class", input_class_value); } if (!current || dirty & /*type, isPaymentForm, disabled*/ 148) { toggle_class(input, "disabled", /*disabled*/ ctx[4]); } if (!current || dirty & /*type, isPaymentForm, hasError, errorMessage*/ 228) { toggle_class(input, "error", /*hasError*/ ctx[5] || /*errorMessage*/ ctx[6]); } if (!current || dirty & /*type, isPaymentForm, fill*/ 262276) { toggle_class(input, "zephr-form-input-full-width", /*fill*/ ctx[18]); } if (!current || dirty & /*type, isPaymentForm, isPaymentForm*/ 132) { toggle_class(input, "zephr-payment-form-input", /*isPaymentForm*/ ctx[7]); } if (!current || dirty & /*type, isPaymentForm, isPaymentForm, fill*/ 262276) { toggle_class(input, "zephr-payment-form-input-full-width", /*isPaymentForm*/ ctx[7] && /*fill*/ ctx[18]); } if (/*innerText*/ ctx[16]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$y(ctx); if_block0.c(); if_block0.m(div, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (!current || dirty & /*isPaymentForm*/ 128) { toggle_class(div, "zephr-payment-form-input-inner-container", /*isPaymentForm*/ ctx[7]); } if (default_slot) { if (default_slot.p && (!current || dirty & /*$$scope*/ 33554432)) { update_slot_base( default_slot, default_slot_template, ctx, /*$$scope*/ ctx[25], !current ? get_all_dirty_from_scope(/*$$scope*/ ctx[25]) : get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, null), null ); } } if (/*errorMessage*/ ctx[6]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*errorMessage*/ 64) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$L(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(default_slot, local); transition_in(if_block1); current = true; }, o(local) { transition_out(default_slot, local); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div); detach(t1); detach(t2); detach(if_block1_anchor); } /*input_binding*/ ctx[27](null); if (if_block0) if_block0.d(); if (default_slot) default_slot.d(detaching); if (if_block1) if_block1.d(detaching); mounted = false; run_all(dispose); } }; } function instance$18($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; const dispatch = createEventDispatcher(); let { id } = $$props; let { name = id } = $$props; let { type = "text" } = $$props; let { required = true } = $$props; let { disabled = false } = $$props; let { hasError = false } = $$props; let { errorMessage = null } = $$props; let { isPaymentForm = false } = $$props; let { value = "" } = $$props; let { placeholder = "" } = $$props; let { checked = false } = $$props; let { pattern = "" } = $$props; let { min = 0 } = $$props; let { max = 0 } = $$props; let { step = 0 } = $$props; let { maxlength = null } = $$props; let { innerText = null } = $$props; let { innerTextOnClick = null } = $$props; let { fill = false } = $$props; let { autocomplete = "" } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; let inputElement; let buttonElement; const handleInputChange = e => { dispatch("change", type !== "checkbox" ? e.target.value : e.target.checked); }; afterUpdate(() => { if (innerText && buttonElement && inputElement) { $$invalidate(22, inputElement.style.paddingRight = `${buttonElement.offsetWidth + 8}px`, inputElement); } }); function input_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { inputElement = $$value; $$invalidate(22, inputElement); }); } function button_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { buttonElement = $$value; $$invalidate(23, buttonElement); }); } $$self.$$set = $$props => { if ('id' in $$props) $$invalidate(0, id = $$props.id); if ('name' in $$props) $$invalidate(1, name = $$props.name); if ('type' in $$props) $$invalidate(2, type = $$props.type); if ('required' in $$props) $$invalidate(3, required = $$props.required); if ('disabled' in $$props) $$invalidate(4, disabled = $$props.disabled); if ('hasError' in $$props) $$invalidate(5, hasError = $$props.hasError); if ('errorMessage' in $$props) $$invalidate(6, errorMessage = $$props.errorMessage); if ('isPaymentForm' in $$props) $$invalidate(7, isPaymentForm = $$props.isPaymentForm); if ('value' in $$props) $$invalidate(8, value = $$props.value); if ('placeholder' in $$props) $$invalidate(9, placeholder = $$props.placeholder); if ('checked' in $$props) $$invalidate(10, checked = $$props.checked); if ('pattern' in $$props) $$invalidate(11, pattern = $$props.pattern); if ('min' in $$props) $$invalidate(12, min = $$props.min); if ('max' in $$props) $$invalidate(13, max = $$props.max); if ('step' in $$props) $$invalidate(14, step = $$props.step); if ('maxlength' in $$props) $$invalidate(15, maxlength = $$props.maxlength); if ('innerText' in $$props) $$invalidate(16, innerText = $$props.innerText); if ('innerTextOnClick' in $$props) $$invalidate(17, innerTextOnClick = $$props.innerTextOnClick); if ('fill' in $$props) $$invalidate(18, fill = $$props.fill); if ('autocomplete' in $$props) $$invalidate(19, autocomplete = $$props.autocomplete); if ('onFocus' in $$props) $$invalidate(20, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(21, onBlur = $$props.onBlur); if ('$$scope' in $$props) $$invalidate(25, $$scope = $$props.$$scope); }; return [ id, name, type, required, disabled, hasError, errorMessage, isPaymentForm, value, placeholder, checked, pattern, min, max, step, maxlength, innerText, innerTextOnClick, fill, autocomplete, onFocus, onBlur, inputElement, buttonElement, handleInputChange, $$scope, slots, input_binding, button_binding ]; } class Input extends SvelteComponent { constructor(options) { super(); init(this, options, instance$18, create_fragment$1a, safe_not_equal, { id: 0, name: 1, type: 2, required: 3, disabled: 4, hasError: 5, errorMessage: 6, isPaymentForm: 7, value: 8, placeholder: 9, checked: 10, pattern: 11, min: 12, max: 13, step: 14, maxlength: 15, innerText: 16, innerTextOnClick: 17, fill: 18, autocomplete: 19, onFocus: 20, onBlur: 21 }); } } /* src/components/elements/Label.svelte generated by Svelte v4.2.12 */ function create_if_block$K(ctx) { let span; let t; return { c() { span = element("span"); t = text(/*sublabel*/ ctx[1]); attr(span, "class", "svelte-yaw4yg"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty & /*sublabel*/ 2) set_data(t, /*sublabel*/ ctx[1]); }, d(detaching) { if (detaching) { detach(span); } } }; } function create_fragment$19(ctx) { let label_1; let span; let t0; let t1; let t2; let current; let if_block = /*sublabel*/ ctx[1] && create_if_block$K(ctx); const default_slot_template = /*#slots*/ ctx[6].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[5], null); return { c() { label_1 = element("label"); span = element("span"); t0 = text(/*label*/ ctx[2]); t1 = space(); if (if_block) if_block.c(); t2 = space(); if (default_slot) default_slot.c(); attr(span, "class", "svelte-yaw4yg"); attr(label_1, "class", "zephr-form-input-label svelte-yaw4yg"); attr(label_1, "for", /*forInput*/ ctx[0]); attr(label_1, "style", /*style*/ ctx[3]); toggle_class(label_1, "zephr-payment-form-input-label", /*isPaymentForm*/ ctx[4]); }, m(target, anchor) { insert(target, label_1, anchor); append(label_1, span); append(span, t0); append(label_1, t1); if (if_block) if_block.m(label_1, null); append(label_1, t2); if (default_slot) { default_slot.m(label_1, null); } current = true; }, p(ctx, [dirty]) { if (!current || dirty & /*label*/ 4) set_data(t0, /*label*/ ctx[2]); if (/*sublabel*/ ctx[1]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$K(ctx); if_block.c(); if_block.m(label_1, t2); } } else if (if_block) { if_block.d(1); if_block = null; } if (default_slot) { if (default_slot.p && (!current || dirty & /*$$scope*/ 32)) { update_slot_base( default_slot, default_slot_template, ctx, /*$$scope*/ ctx[5], !current ? get_all_dirty_from_scope(/*$$scope*/ ctx[5]) : get_slot_changes(default_slot_template, /*$$scope*/ ctx[5], dirty, null), null ); } } if (!current || dirty & /*forInput*/ 1) { attr(label_1, "for", /*forInput*/ ctx[0]); } if (!current || dirty & /*style*/ 8) { attr(label_1, "style", /*style*/ ctx[3]); } if (!current || dirty & /*isPaymentForm*/ 16) { toggle_class(label_1, "zephr-payment-form-input-label", /*isPaymentForm*/ ctx[4]); } }, i(local) { if (current) return; transition_in(default_slot, local); current = true; }, o(local) { transition_out(default_slot, local); current = false; }, d(detaching) { if (detaching) { detach(label_1); } if (if_block) if_block.d(); if (default_slot) default_slot.d(detaching); } }; } function instance$17($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; let { forInput } = $$props; let { sublabel = "" } = $$props; let { label = "" } = $$props; let { style = "" } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('forInput' in $$props) $$invalidate(0, forInput = $$props.forInput); if ('sublabel' in $$props) $$invalidate(1, sublabel = $$props.sublabel); if ('label' in $$props) $$invalidate(2, label = $$props.label); if ('style' in $$props) $$invalidate(3, style = $$props.style); if ('isPaymentForm' in $$props) $$invalidate(4, isPaymentForm = $$props.isPaymentForm); if ('$$scope' in $$props) $$invalidate(5, $$scope = $$props.$$scope); }; return [forInput, sublabel, label, style, isPaymentForm, $$scope, slots]; } class Label extends SvelteComponent { constructor(options) { super(); init(this, options, instance$17, create_fragment$19, safe_not_equal, { forInput: 0, sublabel: 1, label: 2, style: 3, isPaymentForm: 4 }); } } /* src/components/elements/password/PasswordInput.svelte generated by Svelte v4.2.12 */ function create_fragment$18(ctx) { let label_1; let t; let div; let input; let current; label_1 = new Label({ props: { forInput: /*inputId*/ ctx[13], label: /*label*/ ctx[1], isPaymentForm: /*isPaymentForm*/ ctx[8] } }); input = new Input({ props: { disabled: /*disabled*/ ctx[0], required: true, id: /*inputId*/ ctx[13], type: /*passwordInputType*/ ctx[14], value: /*password*/ ctx[11], placeholder: /*placeholder*/ ctx[2], errorMessage: /*error*/ ctx[5], autocomplete: /*autocomplete*/ ctx[7], isPaymentForm: /*isPaymentForm*/ ctx[8], innerTextOnClick: /*func*/ ctx[16], innerText: /*showPassword*/ ctx[12] ? /*hideLabel*/ ctx[4] : /*showLabel*/ ctx[3], onFocus: /*onFocus*/ ctx[9], onBlur: /*onBlur*/ ctx[10] } }); input.$on("change", /*change_handler*/ ctx[17]); return { c() { create_component(label_1.$$.fragment); t = space(); div = element("div"); create_component(input.$$.fragment); attr(div, "class", "zephr-form-relative-container"); toggle_class(div, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[8]); }, m(target, anchor) { mount_component(label_1, target, anchor); insert(target, t, anchor); insert(target, div, anchor); mount_component(input, div, null); current = true; }, p(ctx, [dirty]) { const label_1_changes = {}; if (dirty & /*inputId*/ 8192) label_1_changes.forInput = /*inputId*/ ctx[13]; if (dirty & /*label*/ 2) label_1_changes.label = /*label*/ ctx[1]; if (dirty & /*isPaymentForm*/ 256) label_1_changes.isPaymentForm = /*isPaymentForm*/ ctx[8]; label_1.$set(label_1_changes); const input_changes = {}; if (dirty & /*disabled*/ 1) input_changes.disabled = /*disabled*/ ctx[0]; if (dirty & /*inputId*/ 8192) input_changes.id = /*inputId*/ ctx[13]; if (dirty & /*passwordInputType*/ 16384) input_changes.type = /*passwordInputType*/ ctx[14]; if (dirty & /*password*/ 2048) input_changes.value = /*password*/ ctx[11]; if (dirty & /*placeholder*/ 4) input_changes.placeholder = /*placeholder*/ ctx[2]; if (dirty & /*error*/ 32) input_changes.errorMessage = /*error*/ ctx[5]; if (dirty & /*autocomplete*/ 128) input_changes.autocomplete = /*autocomplete*/ ctx[7]; if (dirty & /*isPaymentForm*/ 256) input_changes.isPaymentForm = /*isPaymentForm*/ ctx[8]; if (dirty & /*showPassword*/ 4096) input_changes.innerTextOnClick = /*func*/ ctx[16]; if (dirty & /*showPassword, hideLabel, showLabel*/ 4120) input_changes.innerText = /*showPassword*/ ctx[12] ? /*hideLabel*/ ctx[4] : /*showLabel*/ ctx[3]; if (dirty & /*onFocus*/ 512) input_changes.onFocus = /*onFocus*/ ctx[9]; if (dirty & /*onBlur*/ 1024) input_changes.onBlur = /*onBlur*/ ctx[10]; input.$set(input_changes); if (!current || dirty & /*isPaymentForm*/ 256) { toggle_class(div, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[8]); } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(input.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t); detach(div); } destroy_component(label_1, detaching); destroy_component(input); } }; } function instance$16($$self, $$props, $$invalidate) { let passwordInputType; let inputId; let { disabled } = $$props; let { label } = $$props; let { placeholder } = $$props; let { isMainPassword } = $$props; let { showLabel } = $$props; let { hideLabel } = $$props; let { error = null } = $$props; let { onChange } = $$props; let { autocomplete } = $$props; let { isPaymentForm = false } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; let { password } = $$props; let showPassword = false; const func = () => $$invalidate(12, showPassword = !showPassword); const change_handler = ({ detail }) => onChange(detail); $$self.$$set = $$props => { if ('disabled' in $$props) $$invalidate(0, disabled = $$props.disabled); if ('label' in $$props) $$invalidate(1, label = $$props.label); if ('placeholder' in $$props) $$invalidate(2, placeholder = $$props.placeholder); if ('isMainPassword' in $$props) $$invalidate(15, isMainPassword = $$props.isMainPassword); if ('showLabel' in $$props) $$invalidate(3, showLabel = $$props.showLabel); if ('hideLabel' in $$props) $$invalidate(4, hideLabel = $$props.hideLabel); if ('error' in $$props) $$invalidate(5, error = $$props.error); if ('onChange' in $$props) $$invalidate(6, onChange = $$props.onChange); if ('autocomplete' in $$props) $$invalidate(7, autocomplete = $$props.autocomplete); if ('isPaymentForm' in $$props) $$invalidate(8, isPaymentForm = $$props.isPaymentForm); if ('onFocus' in $$props) $$invalidate(9, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(10, onBlur = $$props.onBlur); if ('password' in $$props) $$invalidate(11, password = $$props.password); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*showPassword*/ 4096) { $$invalidate(14, passwordInputType = showPassword ? "text" : "password"); } if ($$self.$$.dirty & /*isMainPassword*/ 32768) { $$invalidate(13, inputId = `zephr-form-${isMainPassword ? 'password' : 'confirm-password'}`); } }; return [ disabled, label, placeholder, showLabel, hideLabel, error, onChange, autocomplete, isPaymentForm, onFocus, onBlur, password, showPassword, inputId, passwordInputType, isMainPassword, func, change_handler ]; } class PasswordInput extends SvelteComponent { constructor(options) { super(); init(this, options, instance$16, create_fragment$18, safe_not_equal, { disabled: 0, label: 1, placeholder: 2, isMainPassword: 15, showLabel: 3, hideLabel: 4, error: 5, onChange: 6, autocomplete: 7, isPaymentForm: 8, onFocus: 9, onBlur: 10, password: 11 }); } } function setCustomFontSize(element, size) { if (size && size !== "lg" && size !== "sm" && size !== "xs") { element.style.fontSize = size.replace("x", "em"); } else { element.style.fontSize = ""; } } function getTransform(scale, translateX, translateY, rotate, flip, translateTimes = 1, translateUnit = "", rotateUnit = "") { let flipX = 1; let flipY = 1; if (flip) { if (flip == "horizontal") { flipX = -1; } else if (flip == "vertical") { flipY = -1; } else { flipX = flipY = -1; } } if (typeof scale === "string") { scale = parseFloat(scale); } if (typeof translateX === "string") { translateX = parseFloat(translateX); } if (typeof translateY === "string") { translateY = parseFloat(translateY); } const x = `${translateX * translateTimes}${translateUnit}`; const y = `${translateY * translateTimes}${translateUnit}`; let output = `translate(${x},${y}) scale(${flipX * scale},${flipY * scale})`; if (rotate) { output += ` rotate(${rotate}${rotateUnit})`; } return output; } /* node_modules/svelte-fa/dist/fa.svelte generated by Svelte v4.2.12 */ function create_if_block$J(ctx) { let svg; let g1; let g0; let g1_transform_value; let g1_transform_origin_value; let svg_class_value; let svg_viewBox_value; function select_block_type(ctx, dirty) { if (typeof /*i*/ ctx[16][4] == "string") return create_if_block_1$x; return create_else_block$a; } let current_block_type = select_block_type(ctx); let if_block = current_block_type(ctx); return { c() { svg = svg_element("svg"); g1 = svg_element("g"); g0 = svg_element("g"); if_block.c(); attr(g0, "transform", /*transform*/ ctx[15]); attr(g1, "transform", g1_transform_value = "translate(" + /*i*/ ctx[16][0] / 2 + " " + /*i*/ ctx[16][1] / 2 + ")"); attr(g1, "transform-origin", g1_transform_origin_value = "" + (/*i*/ ctx[16][0] / 4 + " 0")); attr(svg, "id", /*id*/ ctx[1]); attr(svg, "class", svg_class_value = "svelte-fa svelte-fa-base " + /*clazz*/ ctx[0] + " svelte-f5ydbn"); attr(svg, "style", /*style*/ ctx[2]); attr(svg, "viewBox", svg_viewBox_value = "0 0 " + /*i*/ ctx[16][0] + " " + /*i*/ ctx[16][1]); attr(svg, "aria-hidden", "true"); attr(svg, "role", "img"); attr(svg, "xmlns", "http://www.w3.org/2000/svg"); toggle_class(svg, "pulse", /*pulse*/ ctx[8]); toggle_class(svg, "svelte-fa-size-lg", /*size*/ ctx[3] === "lg"); toggle_class(svg, "svelte-fa-size-sm", /*size*/ ctx[3] === "sm"); toggle_class(svg, "svelte-fa-size-xs", /*size*/ ctx[3] === "xs"); toggle_class(svg, "svelte-fa-fw", /*fw*/ ctx[5]); toggle_class(svg, "svelte-fa-pull-left", /*pull*/ ctx[6] === "left"); toggle_class(svg, "svelte-fa-pull-right", /*pull*/ ctx[6] === "right"); toggle_class(svg, "spin", /*spin*/ ctx[7]); }, m(target, anchor) { insert(target, svg, anchor); append(svg, g1); append(g1, g0); if_block.m(g0, null); /*svg_binding*/ ctx[23](svg); }, p(ctx, dirty) { if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) { if_block.p(ctx, dirty); } else { if_block.d(1); if_block = current_block_type(ctx); if (if_block) { if_block.c(); if_block.m(g0, null); } } if (dirty & /*transform*/ 32768) { attr(g0, "transform", /*transform*/ ctx[15]); } if (dirty & /*i*/ 65536 && g1_transform_value !== (g1_transform_value = "translate(" + /*i*/ ctx[16][0] / 2 + " " + /*i*/ ctx[16][1] / 2 + ")")) { attr(g1, "transform", g1_transform_value); } if (dirty & /*i*/ 65536 && g1_transform_origin_value !== (g1_transform_origin_value = "" + (/*i*/ ctx[16][0] / 4 + " 0"))) { attr(g1, "transform-origin", g1_transform_origin_value); } if (dirty & /*id*/ 2) { attr(svg, "id", /*id*/ ctx[1]); } if (dirty & /*clazz*/ 1 && svg_class_value !== (svg_class_value = "svelte-fa svelte-fa-base " + /*clazz*/ ctx[0] + " svelte-f5ydbn")) { attr(svg, "class", svg_class_value); } if (dirty & /*style*/ 4) { attr(svg, "style", /*style*/ ctx[2]); } if (dirty & /*i*/ 65536 && svg_viewBox_value !== (svg_viewBox_value = "0 0 " + /*i*/ ctx[16][0] + " " + /*i*/ ctx[16][1])) { attr(svg, "viewBox", svg_viewBox_value); } if (dirty & /*clazz, pulse*/ 257) { toggle_class(svg, "pulse", /*pulse*/ ctx[8]); } if (dirty & /*clazz, size*/ 9) { toggle_class(svg, "svelte-fa-size-lg", /*size*/ ctx[3] === "lg"); } if (dirty & /*clazz, size*/ 9) { toggle_class(svg, "svelte-fa-size-sm", /*size*/ ctx[3] === "sm"); } if (dirty & /*clazz, size*/ 9) { toggle_class(svg, "svelte-fa-size-xs", /*size*/ ctx[3] === "xs"); } if (dirty & /*clazz, fw*/ 33) { toggle_class(svg, "svelte-fa-fw", /*fw*/ ctx[5]); } if (dirty & /*clazz, pull*/ 65) { toggle_class(svg, "svelte-fa-pull-left", /*pull*/ ctx[6] === "left"); } if (dirty & /*clazz, pull*/ 65) { toggle_class(svg, "svelte-fa-pull-right", /*pull*/ ctx[6] === "right"); } if (dirty & /*clazz, spin*/ 129) { toggle_class(svg, "spin", /*spin*/ ctx[7]); } }, d(detaching) { if (detaching) { detach(svg); } if_block.d(); /*svg_binding*/ ctx[23](null); } }; } // (61:8) {:else} function create_else_block$a(ctx) { let path0; let path0_d_value; let path0_fill_value; let path0_fill_opacity_value; let path0_transform_value; let path1; let path1_d_value; let path1_fill_value; let path1_fill_opacity_value; let path1_transform_value; return { c() { path0 = svg_element("path"); path1 = svg_element("path"); attr(path0, "d", path0_d_value = /*i*/ ctx[16][4][0]); attr(path0, "fill", path0_fill_value = /*secondaryColor*/ ctx[10] || /*color*/ ctx[4] || "currentColor"); attr(path0, "fill-opacity", path0_fill_opacity_value = /*swapOpacity*/ ctx[13] != false ? /*primaryOpacity*/ ctx[11] : /*secondaryOpacity*/ ctx[12]); attr(path0, "transform", path0_transform_value = "translate(" + /*i*/ ctx[16][0] / -2 + " " + /*i*/ ctx[16][1] / -2 + ")"); attr(path1, "d", path1_d_value = /*i*/ ctx[16][4][1]); attr(path1, "fill", path1_fill_value = /*primaryColor*/ ctx[9] || /*color*/ ctx[4] || "currentColor"); attr(path1, "fill-opacity", path1_fill_opacity_value = /*swapOpacity*/ ctx[13] != false ? /*secondaryOpacity*/ ctx[12] : /*primaryOpacity*/ ctx[11]); attr(path1, "transform", path1_transform_value = "translate(" + /*i*/ ctx[16][0] / -2 + " " + /*i*/ ctx[16][1] / -2 + ")"); }, m(target, anchor) { insert(target, path0, anchor); insert(target, path1, anchor); }, p(ctx, dirty) { if (dirty & /*i*/ 65536 && path0_d_value !== (path0_d_value = /*i*/ ctx[16][4][0])) { attr(path0, "d", path0_d_value); } if (dirty & /*secondaryColor, color*/ 1040 && path0_fill_value !== (path0_fill_value = /*secondaryColor*/ ctx[10] || /*color*/ ctx[4] || "currentColor")) { attr(path0, "fill", path0_fill_value); } if (dirty & /*swapOpacity, primaryOpacity, secondaryOpacity*/ 14336 && path0_fill_opacity_value !== (path0_fill_opacity_value = /*swapOpacity*/ ctx[13] != false ? /*primaryOpacity*/ ctx[11] : /*secondaryOpacity*/ ctx[12])) { attr(path0, "fill-opacity", path0_fill_opacity_value); } if (dirty & /*i*/ 65536 && path0_transform_value !== (path0_transform_value = "translate(" + /*i*/ ctx[16][0] / -2 + " " + /*i*/ ctx[16][1] / -2 + ")")) { attr(path0, "transform", path0_transform_value); } if (dirty & /*i*/ 65536 && path1_d_value !== (path1_d_value = /*i*/ ctx[16][4][1])) { attr(path1, "d", path1_d_value); } if (dirty & /*primaryColor, color*/ 528 && path1_fill_value !== (path1_fill_value = /*primaryColor*/ ctx[9] || /*color*/ ctx[4] || "currentColor")) { attr(path1, "fill", path1_fill_value); } if (dirty & /*swapOpacity, secondaryOpacity, primaryOpacity*/ 14336 && path1_fill_opacity_value !== (path1_fill_opacity_value = /*swapOpacity*/ ctx[13] != false ? /*secondaryOpacity*/ ctx[12] : /*primaryOpacity*/ ctx[11])) { attr(path1, "fill-opacity", path1_fill_opacity_value); } if (dirty & /*i*/ 65536 && path1_transform_value !== (path1_transform_value = "translate(" + /*i*/ ctx[16][0] / -2 + " " + /*i*/ ctx[16][1] / -2 + ")")) { attr(path1, "transform", path1_transform_value); } }, d(detaching) { if (detaching) { detach(path0); detach(path1); } } }; } // (55:8) {#if typeof i[4] == "string"} function create_if_block_1$x(ctx) { let path; let path_d_value; let path_fill_value; let path_transform_value; return { c() { path = svg_element("path"); attr(path, "d", path_d_value = /*i*/ ctx[16][4]); attr(path, "fill", path_fill_value = /*color*/ ctx[4] || /*primaryColor*/ ctx[9] || "currentColor"); attr(path, "transform", path_transform_value = "translate(" + /*i*/ ctx[16][0] / -2 + " " + /*i*/ ctx[16][1] / -2 + ")"); }, m(target, anchor) { insert(target, path, anchor); }, p(ctx, dirty) { if (dirty & /*i*/ 65536 && path_d_value !== (path_d_value = /*i*/ ctx[16][4])) { attr(path, "d", path_d_value); } if (dirty & /*color, primaryColor*/ 528 && path_fill_value !== (path_fill_value = /*color*/ ctx[4] || /*primaryColor*/ ctx[9] || "currentColor")) { attr(path, "fill", path_fill_value); } if (dirty & /*i*/ 65536 && path_transform_value !== (path_transform_value = "translate(" + /*i*/ ctx[16][0] / -2 + " " + /*i*/ ctx[16][1] / -2 + ")")) { attr(path, "transform", path_transform_value); } }, d(detaching) { if (detaching) { detach(path); } } }; } function create_fragment$17(ctx) { let if_block_anchor; let if_block = /*i*/ ctx[16][4] && create_if_block$J(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, [dirty]) { if (/*i*/ ctx[16][4]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$J(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$15($$self, $$props, $$invalidate) { let i; let transform; let { class: clazz = void 0 } = $$props; let { id = void 0 } = $$props; let { style = void 0 } = $$props; let { icon } = $$props; let { size = void 0 } = $$props; let { color = void 0 } = $$props; let { fw = false } = $$props; let { pull = void 0 } = $$props; let { scale = 1 } = $$props; let { translateX = 0 } = $$props; let { translateY = 0 } = $$props; let { rotate = void 0 } = $$props; let { flip = void 0 } = $$props; let { spin = false } = $$props; let { pulse = false } = $$props; let { primaryColor = "" } = $$props; let { secondaryColor = "" } = $$props; let { primaryOpacity = 1 } = $$props; let { secondaryOpacity = 0.4 } = $$props; let { swapOpacity = false } = $$props; let svgElement; function svg_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { svgElement = $$value; $$invalidate(14, svgElement); }); } $$self.$$set = $$props => { if ('class' in $$props) $$invalidate(0, clazz = $$props.class); if ('id' in $$props) $$invalidate(1, id = $$props.id); if ('style' in $$props) $$invalidate(2, style = $$props.style); if ('icon' in $$props) $$invalidate(17, icon = $$props.icon); if ('size' in $$props) $$invalidate(3, size = $$props.size); if ('color' in $$props) $$invalidate(4, color = $$props.color); if ('fw' in $$props) $$invalidate(5, fw = $$props.fw); if ('pull' in $$props) $$invalidate(6, pull = $$props.pull); if ('scale' in $$props) $$invalidate(18, scale = $$props.scale); if ('translateX' in $$props) $$invalidate(19, translateX = $$props.translateX); if ('translateY' in $$props) $$invalidate(20, translateY = $$props.translateY); if ('rotate' in $$props) $$invalidate(21, rotate = $$props.rotate); if ('flip' in $$props) $$invalidate(22, flip = $$props.flip); if ('spin' in $$props) $$invalidate(7, spin = $$props.spin); if ('pulse' in $$props) $$invalidate(8, pulse = $$props.pulse); if ('primaryColor' in $$props) $$invalidate(9, primaryColor = $$props.primaryColor); if ('secondaryColor' in $$props) $$invalidate(10, secondaryColor = $$props.secondaryColor); if ('primaryOpacity' in $$props) $$invalidate(11, primaryOpacity = $$props.primaryOpacity); if ('secondaryOpacity' in $$props) $$invalidate(12, secondaryOpacity = $$props.secondaryOpacity); if ('swapOpacity' in $$props) $$invalidate(13, swapOpacity = $$props.swapOpacity); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*svgElement, size*/ 16392) { svgElement && size && setCustomFontSize(svgElement, size); } if ($$self.$$.dirty & /*icon*/ 131072) { $$invalidate(16, i = icon && icon.icon || [0, 0, "", [], ""]); } if ($$self.$$.dirty & /*scale, translateX, translateY, rotate, flip*/ 8126464) { $$invalidate(15, transform = getTransform(scale, translateX, translateY, rotate, flip, 512)); } }; return [ clazz, id, style, size, color, fw, pull, spin, pulse, primaryColor, secondaryColor, primaryOpacity, secondaryOpacity, swapOpacity, svgElement, transform, i, icon, scale, translateX, translateY, rotate, flip, svg_binding ]; } class Fa extends SvelteComponent { constructor(options) { super(); init(this, options, instance$15, create_fragment$17, safe_not_equal, { class: 0, id: 1, style: 2, icon: 17, size: 3, color: 4, fw: 5, pull: 6, scale: 18, translateX: 19, translateY: 20, rotate: 21, flip: 22, spin: 7, pulse: 8, primaryColor: 9, secondaryColor: 10, primaryOpacity: 11, secondaryOpacity: 12, swapOpacity: 13 }); } } var faCircleCheck = { prefix: 'fas', iconName: 'circle-check', icon: [512, 512, [61533, "check-circle"], "f058", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"] }; var faCheckCircle = faCircleCheck; var faSpinner = { prefix: 'fas', iconName: 'spinner', icon: [512, 512, [], "f110", "M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z"] }; var faCheck = { prefix: 'fas', iconName: 'check', icon: [448, 512, [10003, 10004], "f00c", "M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"] }; var faCircleXmark = { prefix: 'fas', iconName: 'circle-xmark', icon: [512, 512, [61532, "times-circle", "xmark-circle"], "f057", "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"] }; var faTimesCircle = faCircleXmark; /* src/components/elements/password/PasswordMatchIndicator.svelte generated by Svelte v4.2.12 */ function create_fragment$16(ctx) { let div1; let ul; let li; let div0; let fa; let t0; let t1; let current; fa = new Fa({ props: { icon: faCheckCircle, color: /*password*/ ctx[0] && /*password*/ ctx[0] === /*confirmPassword*/ ctx[1] ? validColor$1 : invalidColor$1 } }); return { c() { div1 = element("div"); ul = element("ul"); li = element("li"); div0 = element("div"); create_component(fa.$$.fragment); t0 = space(); t1 = text(/*passwordsMatchText*/ ctx[2]); attr(div0, "class", "zephr-form-password-requirement-icon svelte-tsrdk3"); toggle_class(div0, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[3]); attr(li, "class", "zephr-form-password-requirement svelte-tsrdk3"); toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[3]); attr(ul, "class", "svelte-tsrdk3"); attr(div1, "class", "zephr-form-flex-container zephr-form-password-match svelte-tsrdk3"); toggle_class(div1, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[3]); toggle_class(div1, "zephr-payment-form-password-match", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div1, anchor); append(div1, ul); append(ul, li); append(li, div0); mount_component(fa, div0, null); append(li, t0); append(li, t1); current = true; }, p(ctx, [dirty]) { const fa_changes = {}; if (dirty & /*password, confirmPassword*/ 3) fa_changes.color = /*password*/ ctx[0] && /*password*/ ctx[0] === /*confirmPassword*/ ctx[1] ? validColor$1 : invalidColor$1; fa.$set(fa_changes); if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(div0, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[3]); } if (!current || dirty & /*passwordsMatchText*/ 4) set_data(t1, /*passwordsMatchText*/ ctx[2]); if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[3]); } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(div1, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[3]); } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(div1, "zephr-payment-form-password-match", /*isPaymentForm*/ ctx[3]); } }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div1); } destroy_component(fa); } }; } const validColor$1 = "var(--zf-password-valid-color)"; const invalidColor$1 = "var(--zf-password-invalid-color)"; function instance$14($$self, $$props, $$invalidate) { let { password } = $$props; let { confirmPassword } = $$props; let { passwordsMatchText } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('password' in $$props) $$invalidate(0, password = $$props.password); if ('confirmPassword' in $$props) $$invalidate(1, confirmPassword = $$props.confirmPassword); if ('passwordsMatchText' in $$props) $$invalidate(2, passwordsMatchText = $$props.passwordsMatchText); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); }; return [password, confirmPassword, passwordsMatchText, isPaymentForm]; } class PasswordMatchIndicator extends SvelteComponent { constructor(options) { super(); init(this, options, instance$14, create_fragment$16, safe_not_equal, { password: 0, confirmPassword: 1, passwordsMatchText: 2, isPaymentForm: 3 }); } } /* src/components/elements/password/PasswordValidator.svelte generated by Svelte v4.2.12 */ function get_each_context$h(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[12] = list[i]; child_ctx[14] = i; return child_ctx; } // (43:2) {#each Array(maxScore) as _, i} function create_each_block$h(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "zephr-form-password-bar svelte-1bpbne4"); set_style(div, "background-color", /*score*/ ctx[3] > /*i*/ ctx[14] ? validColor : invalidColor); toggle_class(div, "zephr-payment-form-password-bar", /*isPaymentForm*/ ctx[2]); }, m(target, anchor) { insert(target, div, anchor); }, p(ctx, dirty) { if (dirty & /*score*/ 8) { set_style(div, "background-color", /*score*/ ctx[3] > /*i*/ ctx[14] ? validColor : invalidColor); } if (dirty & /*isPaymentForm*/ 4) { toggle_class(div, "zephr-payment-form-password-bar", /*isPaymentForm*/ ctx[2]); } }, d(detaching) { if (detaching) { detach(div); } } }; } // (57:4) {#if passwordRequirements.minLength} function create_if_block_3$e(ctx) { let li; let div; let fa; let t0; let t1_value = /*passwordValidationTexts*/ ctx[1].minLengthValidationText + ""; let t1; let current; fa = new Fa({ props: { icon: faCheckCircle, color: /*isLong*/ ctx[4] ? validColor : invalidColor } }); return { c() { li = element("li"); div = element("div"); create_component(fa.$$.fragment); t0 = space(); t1 = text(t1_value); attr(div, "class", "zephr-form-password-requirement-icon svelte-1bpbne4"); toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); attr(li, "class", "zephr-form-password-requirement svelte-1bpbne4"); toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); }, m(target, anchor) { insert(target, li, anchor); append(li, div); mount_component(fa, div, null); append(li, t0); append(li, t1); current = true; }, p(ctx, dirty) { const fa_changes = {}; if (dirty & /*isLong*/ 16) fa_changes.color = /*isLong*/ ctx[4] ? validColor : invalidColor; fa.$set(fa_changes); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); } if ((!current || dirty & /*passwordValidationTexts*/ 2) && t1_value !== (t1_value = /*passwordValidationTexts*/ ctx[1].minLengthValidationText + "")) set_data(t1, t1_value); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); } }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(li); } destroy_component(fa); } }; } // (75:4) {#if passwordRequirements.requireUppercase} function create_if_block_2$k(ctx) { let li; let div; let fa; let t0; let t1_value = /*passwordValidationTexts*/ ctx[1].uppercaseValidationText + ""; let t1; let current; fa = new Fa({ props: { icon: faCheckCircle, color: /*hasUppercaseLetter*/ ctx[7] ? validColor : invalidColor } }); return { c() { li = element("li"); div = element("div"); create_component(fa.$$.fragment); t0 = space(); t1 = text(t1_value); attr(div, "class", "zephr-form-password-requirement-icon svelte-1bpbne4"); toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); attr(li, "class", "zephr-form-password-requirement svelte-1bpbne4"); toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); }, m(target, anchor) { insert(target, li, anchor); append(li, div); mount_component(fa, div, null); append(li, t0); append(li, t1); current = true; }, p(ctx, dirty) { const fa_changes = {}; if (dirty & /*hasUppercaseLetter*/ 128) fa_changes.color = /*hasUppercaseLetter*/ ctx[7] ? validColor : invalidColor; fa.$set(fa_changes); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); } if ((!current || dirty & /*passwordValidationTexts*/ 2) && t1_value !== (t1_value = /*passwordValidationTexts*/ ctx[1].uppercaseValidationText + "")) set_data(t1, t1_value); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); } }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(li); } destroy_component(fa); } }; } // (93:4) {#if passwordRequirements.requireNumbers} function create_if_block_1$w(ctx) { let li; let div; let fa; let t0; let t1_value = /*passwordValidationTexts*/ ctx[1].numberValidationText + ""; let t1; let current; fa = new Fa({ props: { icon: faCheckCircle, color: /*hasNumber*/ ctx[6] ? validColor : invalidColor } }); return { c() { li = element("li"); div = element("div"); create_component(fa.$$.fragment); t0 = space(); t1 = text(t1_value); attr(div, "class", "zephr-form-password-requirement-icon svelte-1bpbne4"); toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); attr(li, "class", "zephr-form-password-requirement svelte-1bpbne4"); toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); }, m(target, anchor) { insert(target, li, anchor); append(li, div); mount_component(fa, div, null); append(li, t0); append(li, t1); current = true; }, p(ctx, dirty) { const fa_changes = {}; if (dirty & /*hasNumber*/ 64) fa_changes.color = /*hasNumber*/ ctx[6] ? validColor : invalidColor; fa.$set(fa_changes); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); } if ((!current || dirty & /*passwordValidationTexts*/ 2) && t1_value !== (t1_value = /*passwordValidationTexts*/ ctx[1].numberValidationText + "")) set_data(t1, t1_value); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); } }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(li); } destroy_component(fa); } }; } // (111:4) {#if passwordRequirements.requireSpecialCharacters} function create_if_block$I(ctx) { let li; let div; let fa; let t0; let t1_value = /*passwordValidationTexts*/ ctx[1].symbolValidationText + ""; let t1; let current; fa = new Fa({ props: { icon: faCheckCircle, color: /*hasSpecialCharacter*/ ctx[5] ? validColor : invalidColor } }); return { c() { li = element("li"); div = element("div"); create_component(fa.$$.fragment); t0 = space(); t1 = text(t1_value); attr(div, "class", "zephr-form-password-requirement-icon svelte-1bpbne4"); toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); attr(li, "class", "zephr-form-password-requirement svelte-1bpbne4"); toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); }, m(target, anchor) { insert(target, li, anchor); append(li, div); mount_component(fa, div, null); append(li, t0); append(li, t1); current = true; }, p(ctx, dirty) { const fa_changes = {}; if (dirty & /*hasSpecialCharacter*/ 32) fa_changes.color = /*hasSpecialCharacter*/ ctx[5] ? validColor : invalidColor; fa.$set(fa_changes); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(div, "zephr-payment-form-password-requirement-icon", /*isPaymentForm*/ ctx[2]); } if ((!current || dirty & /*passwordValidationTexts*/ 2) && t1_value !== (t1_value = /*passwordValidationTexts*/ ctx[1].symbolValidationText + "")) set_data(t1, t1_value); if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(li, "zephr-payment-form-password-requirement", /*isPaymentForm*/ ctx[2]); } }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(li); } destroy_component(fa); } }; } function create_fragment$15(ctx) { let div0; let t0; let div1; let ul; let t1; let t2; let t3; let current; let each_value = ensure_array_like(Array(/*maxScore*/ ctx[8])); let each_blocks = []; for (let i = 0; i { if_block0 = null; }); check_outros(); } if (/*passwordRequirements*/ ctx[0].requireUppercase) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*passwordRequirements*/ 1) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_2$k(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(ul, t2); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*passwordRequirements*/ ctx[0].requireNumbers) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty & /*passwordRequirements*/ 1) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_1$w(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(ul, t3); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } if (/*passwordRequirements*/ ctx[0].requireSpecialCharacters) { if (if_block3) { if_block3.p(ctx, dirty); if (dirty & /*passwordRequirements*/ 1) { transition_in(if_block3, 1); } } else { if_block3 = create_if_block$I(ctx); if_block3.c(); transition_in(if_block3, 1); if_block3.m(ul, null); } } else if (if_block3) { group_outros(); transition_out(if_block3, 1, 1, () => { if_block3 = null; }); check_outros(); } if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(div1, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[2]); } if (!current || dirty & /*isPaymentForm*/ 4) { toggle_class(div1, "zephr-payment-form-password-requirements", /*isPaymentForm*/ ctx[2]); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); transition_in(if_block2); transition_in(if_block3); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); transition_out(if_block2); transition_out(if_block3); current = false; }, d(detaching) { if (detaching) { detach(div0); detach(t0); detach(div1); } destroy_each(each_blocks, detaching); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); if (if_block3) if_block3.d(); } }; } const validColor = "var(--zf-password-valid-color)"; const invalidColor = "var(--zf-password-invalid-color)"; function instance$13($$self, $$props, $$invalidate) { let hasUppercaseLetter; let hasNumber; let hasSpecialCharacter; let isLong; let { passwordRequirements } = $$props; let { passwordValidationTexts } = $$props; let { isPaymentForm = false } = $$props; let { onChange } = $$props; let { password } = $$props; let { passwordIsValid } = $$props; let score = 0; let maxScore = Object.values(passwordRequirements).reduce( (acc, curr) => { return acc += curr ? 1 : 0; }, 0 ); $$self.$$set = $$props => { if ('passwordRequirements' in $$props) $$invalidate(0, passwordRequirements = $$props.passwordRequirements); if ('passwordValidationTexts' in $$props) $$invalidate(1, passwordValidationTexts = $$props.passwordValidationTexts); if ('isPaymentForm' in $$props) $$invalidate(2, isPaymentForm = $$props.isPaymentForm); if ('onChange' in $$props) $$invalidate(9, onChange = $$props.onChange); if ('password' in $$props) $$invalidate(10, password = $$props.password); if ('passwordIsValid' in $$props) $$invalidate(11, passwordIsValid = $$props.passwordIsValid); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*password*/ 1024) { $$invalidate(7, hasUppercaseLetter = (/[A-Z]+/).test(password)); } if ($$self.$$.dirty & /*password*/ 1024) { $$invalidate(6, hasNumber = (/[0-9]+/).test(password)); } if ($$self.$$.dirty & /*password*/ 1024) { $$invalidate(5, hasSpecialCharacter = (/[^a-z0-9A-Z]+/).test(password)); } if ($$self.$$.dirty & /*password, passwordRequirements*/ 1025) { $$invalidate(4, isLong = password?.length >= passwordRequirements.minLength); } if ($$self.$$.dirty & /*password, passwordRequirements, score, passwordIsValid, onChange*/ 3593) { { $$invalidate(3, score = 0); if ((/[A-Z]+/).test(password) && passwordRequirements.requireUppercase) { $$invalidate(3, score += 1); } if ((/[0-9]+/).test(password) && passwordRequirements.requireNumbers) { $$invalidate(3, score += 1); } if ((/[^a-z0-9A-Z]+/).test(password) && passwordRequirements.requireSpecialCharacters) { $$invalidate(3, score += 1); } if (password?.length >= passwordRequirements.minLength && passwordRequirements.minLength) { $$invalidate(3, score += 1); } score >= maxScore !== passwordIsValid && onChange(score >= maxScore); } } }; return [ passwordRequirements, passwordValidationTexts, isPaymentForm, score, isLong, hasSpecialCharacter, hasNumber, hasUppercaseLetter, maxScore, onChange, password, passwordIsValid ]; } class PasswordValidator extends SvelteComponent { constructor(options) { super(); init(this, options, instance$13, create_fragment$15, safe_not_equal, { passwordRequirements: 0, passwordValidationTexts: 1, isPaymentForm: 2, onChange: 9, password: 10, passwordIsValid: 11 }); } } /* src/components/elements/password/CreatePassword.svelte generated by Svelte v4.2.12 */ function create_if_block_3$d(ctx) { let passwordvalidator; let current; passwordvalidator = new PasswordValidator({ props: { password: /*password*/ ctx[12], passwordIsValid: /*passwordIsValid*/ ctx[14], passwordRequirements: /*passwordRequirements*/ ctx[1], passwordValidationTexts: /*passwordValidationTexts*/ ctx[16], isPaymentForm: /*isPaymentForm*/ ctx[3], onChange: /*onPasswordIsValidChange*/ ctx[10] } }); return { c() { create_component(passwordvalidator.$$.fragment); }, m(target, anchor) { mount_component(passwordvalidator, target, anchor); current = true; }, p(ctx, dirty) { const passwordvalidator_changes = {}; if (dirty & /*password*/ 4096) passwordvalidator_changes.password = /*password*/ ctx[12]; if (dirty & /*passwordIsValid*/ 16384) passwordvalidator_changes.passwordIsValid = /*passwordIsValid*/ ctx[14]; if (dirty & /*passwordRequirements*/ 2) passwordvalidator_changes.passwordRequirements = /*passwordRequirements*/ ctx[1]; if (dirty & /*isPaymentForm*/ 8) passwordvalidator_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*onPasswordIsValidChange*/ 1024) passwordvalidator_changes.onChange = /*onPasswordIsValidChange*/ ctx[10]; passwordvalidator.$set(passwordvalidator_changes); }, i(local) { if (current) return; transition_in(passwordvalidator.$$.fragment, local); current = true; }, o(local) { transition_out(passwordvalidator.$$.fragment, local); current = false; }, d(detaching) { destroy_component(passwordvalidator, detaching); } }; } // (58:0) {#if !hideConfirmPassword} function create_if_block_2$j(ctx) { let passwordinput; let current; passwordinput = new PasswordInput({ props: { disabled: /*disabled*/ ctx[11], password: /*confirmPassword*/ ctx[13], isMainPassword: false, label: /*config*/ ctx[0].confirm, hideLabel: /*config*/ ctx[0].hide, showLabel: /*config*/ ctx[0].show, placeholder: /*config*/ ctx[0].confirmPlaceholder, isPaymentForm: /*isPaymentForm*/ ctx[3], autocomplete: "new-password", onChange: /*onConfirmPasswordChange*/ ctx[7], onFocus: /*onConfirmPasswordFocus*/ ctx[8], onBlur: /*onConfirmPasswordBlur*/ ctx[9] } }); return { c() { create_component(passwordinput.$$.fragment); }, m(target, anchor) { mount_component(passwordinput, target, anchor); current = true; }, p(ctx, dirty) { const passwordinput_changes = {}; if (dirty & /*disabled*/ 2048) passwordinput_changes.disabled = /*disabled*/ ctx[11]; if (dirty & /*confirmPassword*/ 8192) passwordinput_changes.password = /*confirmPassword*/ ctx[13]; if (dirty & /*config*/ 1) passwordinput_changes.label = /*config*/ ctx[0].confirm; if (dirty & /*config*/ 1) passwordinput_changes.hideLabel = /*config*/ ctx[0].hide; if (dirty & /*config*/ 1) passwordinput_changes.showLabel = /*config*/ ctx[0].show; if (dirty & /*config*/ 1) passwordinput_changes.placeholder = /*config*/ ctx[0].confirmPlaceholder; if (dirty & /*isPaymentForm*/ 8) passwordinput_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*onConfirmPasswordChange*/ 128) passwordinput_changes.onChange = /*onConfirmPasswordChange*/ ctx[7]; if (dirty & /*onConfirmPasswordFocus*/ 256) passwordinput_changes.onFocus = /*onConfirmPasswordFocus*/ ctx[8]; if (dirty & /*onConfirmPasswordBlur*/ 512) passwordinput_changes.onBlur = /*onConfirmPasswordBlur*/ ctx[9]; passwordinput.$set(passwordinput_changes); }, i(local) { if (current) return; transition_in(passwordinput.$$.fragment, local); current = true; }, o(local) { transition_out(passwordinput.$$.fragment, local); current = false; }, d(detaching) { destroy_component(passwordinput, detaching); } }; } // (75:0) {#if config.passwordsMatchIndicatorEnabled} function create_if_block_1$v(ctx) { let passwordmatchindicator; let current; passwordmatchindicator = new PasswordMatchIndicator({ props: { password: /*password*/ ctx[12], confirmPassword: /*confirmPassword*/ ctx[13], passwordsMatchText: /*passwordValidationTexts*/ ctx[16].passwordsMatchText, isPaymentForm: /*isPaymentForm*/ ctx[3] } }); return { c() { create_component(passwordmatchindicator.$$.fragment); }, m(target, anchor) { mount_component(passwordmatchindicator, target, anchor); current = true; }, p(ctx, dirty) { const passwordmatchindicator_changes = {}; if (dirty & /*password*/ 4096) passwordmatchindicator_changes.password = /*password*/ ctx[12]; if (dirty & /*confirmPassword*/ 8192) passwordmatchindicator_changes.confirmPassword = /*confirmPassword*/ ctx[13]; if (dirty & /*isPaymentForm*/ 8) passwordmatchindicator_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; passwordmatchindicator.$set(passwordmatchindicator_changes); }, i(local) { if (current) return; transition_in(passwordmatchindicator.$$.fragment, local); current = true; }, o(local) { transition_out(passwordmatchindicator.$$.fragment, local); current = false; }, d(detaching) { destroy_component(passwordmatchindicator, detaching); } }; } // (84:0) {#if error} function create_if_block$H(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*error*/ ctx[15] ?? "", isPaymentForm: /*isPaymentForm*/ ctx[3] } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, dirty) { const errormessage_changes = {}; if (dirty & /*error*/ 32768) errormessage_changes.error = /*error*/ ctx[15] ?? ""; if (dirty & /*isPaymentForm*/ 8) errormessage_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function create_fragment$14(ctx) { let passwordinput; let t0; let t1; let t2; let t3; let if_block3_anchor; let current; passwordinput = new PasswordInput({ props: { disabled: /*disabled*/ ctx[11], password: /*password*/ ctx[12], isMainPassword: true, label: /*config*/ ctx[0].password, hideLabel: /*config*/ ctx[0].hide, showLabel: /*config*/ ctx[0].show, placeholder: /*config*/ ctx[0].placeholder, isPaymentForm: /*isPaymentForm*/ ctx[3], autocomplete: /*hideConfirmPassword*/ ctx[2] ? "current-password" : "new-password", onChange: /*onPasswordChange*/ ctx[4], onFocus: /*onPasswordFocus*/ ctx[5], onBlur: /*onPasswordBlur*/ ctx[6] } }); let if_block0 = /*config*/ ctx[0].passValidatorEnabled && create_if_block_3$d(ctx); let if_block1 = !/*hideConfirmPassword*/ ctx[2] && create_if_block_2$j(ctx); let if_block2 = /*config*/ ctx[0].passwordsMatchIndicatorEnabled && create_if_block_1$v(ctx); let if_block3 = /*error*/ ctx[15] && create_if_block$H(ctx); return { c() { create_component(passwordinput.$$.fragment); t0 = space(); if (if_block0) if_block0.c(); t1 = space(); if (if_block1) if_block1.c(); t2 = space(); if (if_block2) if_block2.c(); t3 = space(); if (if_block3) if_block3.c(); if_block3_anchor = empty(); }, m(target, anchor) { mount_component(passwordinput, target, anchor); insert(target, t0, anchor); if (if_block0) if_block0.m(target, anchor); insert(target, t1, anchor); if (if_block1) if_block1.m(target, anchor); insert(target, t2, anchor); if (if_block2) if_block2.m(target, anchor); insert(target, t3, anchor); if (if_block3) if_block3.m(target, anchor); insert(target, if_block3_anchor, anchor); current = true; }, p(ctx, [dirty]) { const passwordinput_changes = {}; if (dirty & /*disabled*/ 2048) passwordinput_changes.disabled = /*disabled*/ ctx[11]; if (dirty & /*password*/ 4096) passwordinput_changes.password = /*password*/ ctx[12]; if (dirty & /*config*/ 1) passwordinput_changes.label = /*config*/ ctx[0].password; if (dirty & /*config*/ 1) passwordinput_changes.hideLabel = /*config*/ ctx[0].hide; if (dirty & /*config*/ 1) passwordinput_changes.showLabel = /*config*/ ctx[0].show; if (dirty & /*config*/ 1) passwordinput_changes.placeholder = /*config*/ ctx[0].placeholder; if (dirty & /*isPaymentForm*/ 8) passwordinput_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*hideConfirmPassword*/ 4) passwordinput_changes.autocomplete = /*hideConfirmPassword*/ ctx[2] ? "current-password" : "new-password"; if (dirty & /*onPasswordChange*/ 16) passwordinput_changes.onChange = /*onPasswordChange*/ ctx[4]; if (dirty & /*onPasswordFocus*/ 32) passwordinput_changes.onFocus = /*onPasswordFocus*/ ctx[5]; if (dirty & /*onPasswordBlur*/ 64) passwordinput_changes.onBlur = /*onPasswordBlur*/ ctx[6]; passwordinput.$set(passwordinput_changes); if (/*config*/ ctx[0].passValidatorEnabled) { if (if_block0) { if_block0.p(ctx, dirty); if (dirty & /*config*/ 1) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_3$d(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(t1.parentNode, t1); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (!/*hideConfirmPassword*/ ctx[2]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*hideConfirmPassword*/ 4) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_2$j(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(t2.parentNode, t2); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*config*/ ctx[0].passwordsMatchIndicatorEnabled) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty & /*config*/ 1) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_1$v(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(t3.parentNode, t3); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } if (/*error*/ ctx[15]) { if (if_block3) { if_block3.p(ctx, dirty); if (dirty & /*error*/ 32768) { transition_in(if_block3, 1); } } else { if_block3 = create_if_block$H(ctx); if_block3.c(); transition_in(if_block3, 1); if_block3.m(if_block3_anchor.parentNode, if_block3_anchor); } } else if (if_block3) { group_outros(); transition_out(if_block3, 1, 1, () => { if_block3 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(passwordinput.$$.fragment, local); transition_in(if_block0); transition_in(if_block1); transition_in(if_block2); transition_in(if_block3); current = true; }, o(local) { transition_out(passwordinput.$$.fragment, local); transition_out(if_block0); transition_out(if_block1); transition_out(if_block2); transition_out(if_block3); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(t1); detach(t2); detach(t3); detach(if_block3_anchor); } destroy_component(passwordinput, detaching); if (if_block0) if_block0.d(detaching); if (if_block1) if_block1.d(detaching); if (if_block2) if_block2.d(detaching); if (if_block3) if_block3.d(detaching); } }; } function instance$12($$self, $$props, $$invalidate) { let { config } = $$props; let { passwordRequirements } = $$props; let { hideConfirmPassword } = $$props; let { isPaymentForm = false } = $$props; let { onPasswordChange } = $$props; let { onPasswordFocus } = $$props; let { onPasswordBlur } = $$props; let { onConfirmPasswordChange } = $$props; let { onConfirmPasswordFocus } = $$props; let { onConfirmPasswordBlur } = $$props; let { onPasswordIsValidChange } = $$props; let { disabled } = $$props; let { password } = $$props; let { confirmPassword } = $$props; let { passwordIsValid } = $$props; let { error = null } = $$props; let passwordValidationTexts = { minLengthValidationText: config.minLengthValidation || `Must include at least ${passwordRequirements.minLength} characters`, uppercaseValidationText: config.uppercaseValidation || 'Must include an uppercase letter', numberValidationText: config.numberValidation || 'Must include a number character', symbolValidationText: config.symbolValidation || 'Must include a supported symbol', passwordsMatchText: config.passwordsMatchText || 'Passwords match' }; $$self.$$set = $$props => { if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('passwordRequirements' in $$props) $$invalidate(1, passwordRequirements = $$props.passwordRequirements); if ('hideConfirmPassword' in $$props) $$invalidate(2, hideConfirmPassword = $$props.hideConfirmPassword); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); if ('onPasswordChange' in $$props) $$invalidate(4, onPasswordChange = $$props.onPasswordChange); if ('onPasswordFocus' in $$props) $$invalidate(5, onPasswordFocus = $$props.onPasswordFocus); if ('onPasswordBlur' in $$props) $$invalidate(6, onPasswordBlur = $$props.onPasswordBlur); if ('onConfirmPasswordChange' in $$props) $$invalidate(7, onConfirmPasswordChange = $$props.onConfirmPasswordChange); if ('onConfirmPasswordFocus' in $$props) $$invalidate(8, onConfirmPasswordFocus = $$props.onConfirmPasswordFocus); if ('onConfirmPasswordBlur' in $$props) $$invalidate(9, onConfirmPasswordBlur = $$props.onConfirmPasswordBlur); if ('onPasswordIsValidChange' in $$props) $$invalidate(10, onPasswordIsValidChange = $$props.onPasswordIsValidChange); if ('disabled' in $$props) $$invalidate(11, disabled = $$props.disabled); if ('password' in $$props) $$invalidate(12, password = $$props.password); if ('confirmPassword' in $$props) $$invalidate(13, confirmPassword = $$props.confirmPassword); if ('passwordIsValid' in $$props) $$invalidate(14, passwordIsValid = $$props.passwordIsValid); if ('error' in $$props) $$invalidate(15, error = $$props.error); }; return [ config, passwordRequirements, hideConfirmPassword, isPaymentForm, onPasswordChange, onPasswordFocus, onPasswordBlur, onConfirmPasswordChange, onConfirmPasswordFocus, onConfirmPasswordBlur, onPasswordIsValidChange, disabled, password, confirmPassword, passwordIsValid, error, passwordValidationTexts ]; } class CreatePassword extends SvelteComponent { constructor(options) { super(); init(this, options, instance$12, create_fragment$14, safe_not_equal, { config: 0, passwordRequirements: 1, hideConfirmPassword: 2, isPaymentForm: 3, onPasswordChange: 4, onPasswordFocus: 5, onPasswordBlur: 6, onConfirmPasswordChange: 7, onConfirmPasswordFocus: 8, onConfirmPasswordBlur: 9, onPasswordIsValidChange: 10, disabled: 11, password: 12, confirmPassword: 13, passwordIsValid: 14, error: 15 }); } } const factory$u = { matches: (sectionElement) => sectionElement.type === elementTypes.PASSWORD && sectionElement.config?.confirm != null, create: (form, formState, formActions, elementConfig) => ({ component: CreatePassword, props: { disabled: formState.isBusy, config: elementConfig, passwordRequirements: form.organisationConfiguration.passwordStrengthRequirements, hideConfirmPassword: form.organisationConfiguration.hideConfirmPasswordOnRegForm, isPaymentForm: form.formType === FormType.PAYMENT, onPasswordChange: (value) => { formActions.updateFormState({ createPassword: value }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: 'zephr-form-password', sectionId: formState.currentSection.type, field: 'create-password' }); }, onPasswordFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: 'zephr-form-password', sectionId: formState.currentSection.type, field: 'create-password' }), onPasswordBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: 'zephr-form-password', sectionId: formState.currentSection.type, field: 'create-password' }), onConfirmPasswordChange: (value) => { formActions.updateFormState({ confirmCreatePassword: value }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: 'zephr-form-confirm-password', sectionId: formState.currentSection.type, field: 'confirm-password' }); }, onConfirmPasswordFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: 'zephr-form-confirm-password', sectionId: formState.currentSection.type, field: 'confirm-password' }), onConfirmPasswordBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: 'zephr-form-confirm-password', sectionId: formState.currentSection.type, field: 'confirm-password' }), onPasswordIsValidChange: (value) => formActions.updateFormState({ passwordIsValid: value }), password: formState.createPassword, confirmPassword: formState.confirmCreatePassword, passwordIsValid: formState.passwordIsValid }, isValid: formState.password != null && (!elementConfig.passValidatorEnabled || formState.passwordIsValid) && (form.organisationConfiguration.hideConfirmPasswordOnRegForm || formState.createPassword === formState.confirmCreatePassword), }) }; // TODO const isValid = (password) => password != null && password.length > 2; const factory$t = { matches: (sectionElement) => sectionElement.type === elementTypes.PASSWORD && sectionElement.config?.confirm == null, create: (form, formState, formActions, elementConfig) => { const stateKey = elementConfig.isUpdatePasswordCurrentPassword ? 'currentPassword' : 'password'; return { component: PasswordInput, props: { disabled: formState.isBusy, label: elementConfig.password, placeholder: elementConfig.placeholder, isMainPassword: true, showLabel: elementConfig.showLabel, hideLabel: elementConfig.hideLabel, password: formState[stateKey], autocomplete: 'password', onChange: (value) => { formActions.updateFormState({ [stateKey]: value }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: 'zephr-form-password', sectionId: formState.currentSection.type, field: 'password' }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: 'zephr-form-password', sectionId: formState.currentSection.type, field: 'password' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: 'zephr-form-password', sectionId: formState.currentSection.type, field: 'password' }), }, isValid: isValid(formState[stateKey]) }; } }; /* src/components/elements/payment/braintree/BraintreeMobilePayment.svelte generated by Svelte v4.2.12 */ function create_fragment$13(ctx) { let script0; let script0_src_value; let script1; let script1_src_value; let script2; let script2_src_value; let script3; let script3_src_value; let t0; let div0; let t1; let div1; return { c() { script0 = element("script"); script0.innerHTML = ``; script1 = element("script"); script1.innerHTML = ``; script2 = element("script"); script2.innerHTML = ``; script3 = element("script"); script3.innerHTML = ``; t0 = space(); div0 = element("div"); t1 = space(); div1 = element("div"); div1.innerHTML = ``; if (!src_url_equal(script0.src, script0_src_value = "https://js.braintreegateway.com/web/3.85.3/js/google-payment.min.js")) attr(script0, "src", script0_src_value); if (!src_url_equal(script1.src, script1_src_value = "https://pay.google.com/gp/p/js/pay.js")) attr(script1, "src", script1_src_value); attr(script1, "onload", "window.googlePayLoadBraintreeCallback()"); if (!src_url_equal(script2.src, script2_src_value = "https://js.braintreegateway.com/web/3.85.3/js/client.min.js")) attr(script2, "src", script2_src_value); attr(script2, "onload", "window.braintreeLoadCallback()"); if (!src_url_equal(script3.src, script3_src_value = "https://js.braintreegateway.com/web/3.85.3/js/apple-pay.min.js")) attr(script3, "src", script3_src_value); attr(script3, "onload", "window.applePayLoadBraintreeCallback()"); attr(div0, "id", "google-pay-button"); attr(div0, "class", "svelte-1drqjgk"); toggle_class(div0, "zephr-form-disabled-div", /*isDisabled*/ ctx[0]); toggle_class(div0, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[0]); attr(div1, "id", "apple_pay_button"); }, m(target, anchor) { append(document.head, script0); append(document.head, script1); append(document.head, script2); append(document.head, script3); insert(target, t0, anchor); insert(target, div0, anchor); insert(target, t1, anchor); insert(target, div1, anchor); }, p(ctx, [dirty]) { if (dirty & /*isDisabled*/ 1) { toggle_class(div0, "zephr-form-disabled-div", /*isDisabled*/ ctx[0]); } if (dirty & /*isDisabled*/ 1) { toggle_class(div0, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[0]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(t0); detach(div0); detach(t1); detach(div1); } detach(script0); detach(script1); detach(script2); detach(script3); } }; } function instance$11($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; let { isDisabled } = $$props; let { disableCoreDependencyHeader } = $$props; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(1, onMountCallback = $$props.onMountCallback); if ('isDisabled' in $$props) $$invalidate(0, isDisabled = $$props.isDisabled); if ('disableCoreDependencyHeader' in $$props) $$invalidate(2, disableCoreDependencyHeader = $$props.disableCoreDependencyHeader); }; return [isDisabled, onMountCallback, disableCoreDependencyHeader]; } class BraintreeMobilePayment extends SvelteComponent { constructor(options) { super(); init(this, options, instance$11, create_fragment$13, safe_not_equal, { onMountCallback: 1, isDisabled: 0, disableCoreDependencyHeader: 2 }); } } /* src/components/elements/payment/braintree/BraintreePayment.svelte generated by Svelte v4.2.12 */ function create_fragment$12(ctx) { let script; let script_src_value; let t0; let div; let t1; let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*providerError*/ ctx[0]?.message ?? /*error*/ ctx[2] ?? "", isPaymentForm: true } }); return { c() { script = element("script"); script.innerHTML = ``; t0 = space(); div = element("div"); t1 = space(); create_component(errormessage.$$.fragment); if (!src_url_equal(script.src, script_src_value = "https://js.braintreegateway.com/web/dropin/1.33.2/js/dropin.min.js")) attr(script, "src", script_src_value); attr(script, "onload", "window.braintreeLoadCallback()"); attr(div, "id", "braintree-dropin-container"); attr(div, "class", "svelte-w52z2j"); toggle_class(div, "zephr-form-disabled-div", /*isDisabled*/ ctx[1]); toggle_class(div, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[1]); }, m(target, anchor) { append(document.head, script); insert(target, t0, anchor); insert(target, div, anchor); insert(target, t1, anchor); mount_component(errormessage, target, anchor); current = true; }, p(ctx, [dirty]) { if (!current || dirty & /*isDisabled*/ 2) { toggle_class(div, "zephr-form-disabled-div", /*isDisabled*/ ctx[1]); } if (!current || dirty & /*isDisabled*/ 2) { toggle_class(div, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[1]); } const errormessage_changes = {}; if (dirty & /*providerError, error*/ 5) errormessage_changes.error = /*providerError*/ ctx[0]?.message ?? /*error*/ ctx[2] ?? ""; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(div); detach(t1); } detach(script); destroy_component(errormessage, detaching); } }; } function instance$10($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; let { providerError } = $$props; let { isDisabled } = $$props; let { isLoaded } = $$props; let { error = null } = $$props; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(3, onMountCallback = $$props.onMountCallback); if ('providerError' in $$props) $$invalidate(0, providerError = $$props.providerError); if ('isDisabled' in $$props) $$invalidate(1, isDisabled = $$props.isDisabled); if ('isLoaded' in $$props) $$invalidate(4, isLoaded = $$props.isLoaded); if ('error' in $$props) $$invalidate(2, error = $$props.error); }; return [providerError, isDisabled, error, onMountCallback, isLoaded]; } class BraintreePayment extends SvelteComponent { constructor(options) { super(); init(this, options, instance$10, create_fragment$12, safe_not_equal, { onMountCallback: 3, providerError: 0, isDisabled: 1, isLoaded: 4, error: 2 }); } } /* src/components/elements/payment/stripe/StripePayment.svelte generated by Svelte v4.2.12 */ function create_fragment$11(ctx) { let script; let script_src_value; let t0; let div; let t1; let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*providerError*/ ctx[0]?.message ?? (/*isComplete*/ ctx[2] ? /*error*/ ctx[3] : "") ?? "", isPaymentForm: true } }); return { c() { script = element("script"); script.innerHTML = ``; t0 = space(); div = element("div"); t1 = space(); create_component(errormessage.$$.fragment); if (!src_url_equal(script.src, script_src_value = "https://js.stripe.com/v3/")) attr(script, "src", script_src_value); attr(script, "onload", "window.stripeLoadCallback()"); attr(div, "id", /*id*/ ctx[4]); attr(div, "class", "stripe-element svelte-1bi6tmz"); toggle_class(div, "zephr-form-disabled-div", /*isDisabled*/ ctx[1]); toggle_class(div, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[1]); }, m(target, anchor) { append(document.head, script); insert(target, t0, anchor); insert(target, div, anchor); insert(target, t1, anchor); mount_component(errormessage, target, anchor); current = true; }, p(ctx, [dirty]) { if (!current || dirty & /*isDisabled*/ 2) { toggle_class(div, "zephr-form-disabled-div", /*isDisabled*/ ctx[1]); } if (!current || dirty & /*isDisabled*/ 2) { toggle_class(div, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[1]); } const errormessage_changes = {}; if (dirty & /*providerError, isComplete, error*/ 13) errormessage_changes.error = /*providerError*/ ctx[0]?.message ?? (/*isComplete*/ ctx[2] ? /*error*/ ctx[3] : "") ?? ""; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(div); detach(t1); } detach(script); destroy_component(errormessage, detaching); } }; } function instance$$($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; let { providerError } = $$props; let { isDisabled } = $$props; let { isComplete } = $$props; let { isLoaded } = $$props; let { error = null } = $$props; let { formKey } = $$props; const id = `stripe-element-${formKey}`; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(5, onMountCallback = $$props.onMountCallback); if ('providerError' in $$props) $$invalidate(0, providerError = $$props.providerError); if ('isDisabled' in $$props) $$invalidate(1, isDisabled = $$props.isDisabled); if ('isComplete' in $$props) $$invalidate(2, isComplete = $$props.isComplete); if ('isLoaded' in $$props) $$invalidate(6, isLoaded = $$props.isLoaded); if ('error' in $$props) $$invalidate(3, error = $$props.error); if ('formKey' in $$props) $$invalidate(7, formKey = $$props.formKey); }; return [ providerError, isDisabled, isComplete, error, id, onMountCallback, isLoaded, formKey ]; } class StripePayment extends SvelteComponent { constructor(options) { super(); init(this, options, instance$$, create_fragment$11, safe_not_equal, { onMountCallback: 5, providerError: 0, isDisabled: 1, isComplete: 2, isLoaded: 6, error: 3, formKey: 7 }); } } /* src/components/elements/payment/stripe/StripeMobilePayment.svelte generated by Svelte v4.2.12 */ function create_if_block$G(ctx) { let script; let script_src_value; return { c() { script = element("script"); script.innerHTML = ``; if (!src_url_equal(script.src, script_src_value = "https://js.stripe.com/v3/")) attr(script, "src", script_src_value); attr(script, "onload", "window.stripeLoadCallback()"); }, m(target, anchor) { insert(target, script, anchor); }, d(detaching) { if (detaching) { detach(script); } } }; } function create_fragment$10(ctx) { let script; let script_src_value; let if_block_anchor; let t; let div; let if_block = !/*disableCoreDependencyHeader*/ ctx[1] && create_if_block$G(); return { c() { script = element("script"); script.innerHTML = ``; if (if_block) if_block.c(); if_block_anchor = empty(); t = space(); div = element("div"); if (!src_url_equal(script.src, script_src_value = "https://pay.google.com/gp/p/js/pay.js")) attr(script, "src", script_src_value); attr(script, "onload", "window.googlePayLoadStripeCallback()"); attr(div, "id", "stripe-mobile-pay-button"); attr(div, "class", "svelte-12ehv8b"); toggle_class(div, "zephr-form-disabled-div", /*isDisabled*/ ctx[0]); toggle_class(div, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[0]); }, m(target, anchor) { append(document.head, script); if (if_block) if_block.m(document.head, null); append(document.head, if_block_anchor); insert(target, t, anchor); insert(target, div, anchor); }, p(ctx, [dirty]) { if (!/*disableCoreDependencyHeader*/ ctx[1]) { if (if_block) ; else { if_block = create_if_block$G(); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } if (dirty & /*isDisabled*/ 1) { toggle_class(div, "zephr-form-disabled-div", /*isDisabled*/ ctx[0]); } if (dirty & /*isDisabled*/ 1) { toggle_class(div, "zephr-payment-form-disabled-div", /*isDisabled*/ ctx[0]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(t); detach(div); } detach(script); if (if_block) if_block.d(detaching); detach(if_block_anchor); } }; } function instance$_($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; let { isDisabled } = $$props; let { disableCoreDependencyHeader } = $$props; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(2, onMountCallback = $$props.onMountCallback); if ('isDisabled' in $$props) $$invalidate(0, isDisabled = $$props.isDisabled); if ('disableCoreDependencyHeader' in $$props) $$invalidate(1, disableCoreDependencyHeader = $$props.disableCoreDependencyHeader); }; return [isDisabled, disableCoreDependencyHeader, onMountCallback]; } class StripeMobilePayment extends SvelteComponent { constructor(options) { super(); init(this, options, instance$_, create_fragment$10, safe_not_equal, { onMountCallback: 2, isDisabled: 0, disableCoreDependencyHeader: 1 }); } } /* src/components/elements/Spinner.svelte generated by Svelte v4.2.12 */ function create_fragment$$(ctx) { let div; let fa; let current; fa = new Fa({ props: { size: "2x", icon: faSpinner, spin: true } }); return { c() { div = element("div"); create_component(fa.$$.fragment); attr(div, "class", "spinner-container svelte-1c5ov4v"); }, m(target, anchor) { insert(target, div, anchor); mount_component(fa, div, null); current = true; }, p: noop, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(fa); } }; } class Spinner extends SvelteComponent { constructor(options) { super(); init(this, options, null, create_fragment$$, safe_not_equal, {}); } } /* src/components/elements/payment/zuora/ZuoraPayment.svelte generated by Svelte v4.2.12 */ function create_if_block_1$u(ctx) { let spinner; let current; spinner = new Spinner({}); return { c() { create_component(spinner.$$.fragment); }, m(target, anchor) { mount_component(spinner, target, anchor); current = true; }, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { destroy_component(spinner, detaching); } }; } // (19:4) {#if isBusy} function create_if_block$F(ctx) { let div; let spinner; let current; spinner = new Spinner({}); return { c() { div = element("div"); create_component(spinner.$$.fragment); attr(div, "class", "spinner-overlay svelte-1vnsk3p"); }, m(target, anchor) { insert(target, div, anchor); mount_component(spinner, div, null); current = true; }, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(spinner); } }; } function create_fragment$_(ctx) { let t0; let div1; let t1; let div0; let div0_class_value; let div1_class_value; let t2; let div2; let t3; let errormessage; let current; let if_block0 = !/*isLoaded*/ ctx[2] && create_if_block_1$u(); let if_block1 = /*isBusy*/ ctx[3] && create_if_block$F(); errormessage = new ErrorMessage({ props: { error: /*providerError*/ ctx[1]?.message ?? /*error*/ ctx[4] ?? "", isPaymentForm: true } }); return { c() { if (if_block0) if_block0.c(); t0 = space(); div1 = element("div"); if (if_block1) if_block1.c(); t1 = space(); div0 = element("div"); t2 = space(); div2 = element("div"); t3 = space(); create_component(errormessage.$$.fragment); attr(div0, "id", "zuora_payment"); attr(div0, "class", div0_class_value = "" + (null_to_empty(/*isDisabled*/ ctx[0] ? "zuora-disabled-iframe-container zuora-dynamic-form-disabled" : "") + " svelte-1vnsk3p")); attr(div1, "class", div1_class_value = "" + (null_to_empty(/*isBusy*/ ctx[3] ? "zuora-dynamic-form-disabled form-wrapper" : "form-wrapper") + " svelte-1vnsk3p")); attr(div2, "id", "core-style"); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert(target, t0, anchor); insert(target, div1, anchor); if (if_block1) if_block1.m(div1, null); append(div1, t1); append(div1, div0); insert(target, t2, anchor); insert(target, div2, anchor); insert(target, t3, anchor); mount_component(errormessage, target, anchor); current = true; }, p(ctx, [dirty]) { if (!/*isLoaded*/ ctx[2]) { if (if_block0) { if (dirty & /*isLoaded*/ 4) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_1$u(); if_block0.c(); transition_in(if_block0, 1); if_block0.m(t0.parentNode, t0); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (/*isBusy*/ ctx[3]) { if (if_block1) { if (dirty & /*isBusy*/ 8) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$F(); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div1, t1); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (!current || dirty & /*isDisabled*/ 1 && div0_class_value !== (div0_class_value = "" + (null_to_empty(/*isDisabled*/ ctx[0] ? "zuora-disabled-iframe-container zuora-dynamic-form-disabled" : "") + " svelte-1vnsk3p"))) { attr(div0, "class", div0_class_value); } if (!current || dirty & /*isBusy*/ 8 && div1_class_value !== (div1_class_value = "" + (null_to_empty(/*isBusy*/ ctx[3] ? "zuora-dynamic-form-disabled form-wrapper" : "form-wrapper") + " svelte-1vnsk3p"))) { attr(div1, "class", div1_class_value); } const errormessage_changes = {}; if (dirty & /*providerError, error*/ 18) errormessage_changes.error = /*providerError*/ ctx[1]?.message ?? /*error*/ ctx[4] ?? ""; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(div1); detach(t2); detach(div2); detach(t3); } if (if_block0) if_block0.d(detaching); if (if_block1) if_block1.d(); destroy_component(errormessage, detaching); } }; } function instance$Z($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; let { isDisabled } = $$props; let { providerError } = $$props; let { isLoaded } = $$props; let { isBusy } = $$props; let { error = null } = $$props; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(5, onMountCallback = $$props.onMountCallback); if ('isDisabled' in $$props) $$invalidate(0, isDisabled = $$props.isDisabled); if ('providerError' in $$props) $$invalidate(1, providerError = $$props.providerError); if ('isLoaded' in $$props) $$invalidate(2, isLoaded = $$props.isLoaded); if ('isBusy' in $$props) $$invalidate(3, isBusy = $$props.isBusy); if ('error' in $$props) $$invalidate(4, error = $$props.error); }; return [isDisabled, providerError, isLoaded, isBusy, error, onMountCallback]; } class ZuoraPayment extends SvelteComponent { constructor(options) { super(); init(this, options, instance$Z, create_fragment$_, safe_not_equal, { onMountCallback: 5, isDisabled: 0, providerError: 1, isLoaded: 2, isBusy: 3, error: 4 }); } } /* src/components/elements/payment/zuora/ZuoraPreLoader.svelte generated by Svelte v4.2.12 */ function create_fragment$Z(ctx) { let script; let script_src_value; return { c() { script = element("script"); script.innerHTML = ``; attr(script, "type", "text/javascript"); if (!src_url_equal(script.src, script_src_value = "https://static.zuora.com/Resources/libs/hosted/1.3.1/zuora-min.js")) attr(script, "src", script_src_value); attr(script, "onload", "window.zuoraLoadCallback()"); }, m(target, anchor) { append(document.head, script); }, p: noop, i: noop, o: noop, d(detaching) { detach(script); } }; } function instance$Y($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(0, onMountCallback = $$props.onMountCallback); }; return [onMountCallback]; } class ZuoraPreLoader extends SvelteComponent { constructor(options) { super(); init(this, options, instance$Y, create_fragment$Z, safe_not_equal, { onMountCallback: 0 }); } } const paymentProviders = { BRAINTREE: 'braintree', STRIPE: 'stripe', ZUORA: 'zuora-billing', }; const defaultHeaders = new Headers(); defaultHeaders.append("Content-Type", "application/json"); defaultHeaders.append("Accept", "application/json"); const request = async (url, options, formActions, busyKey = null, clearFormErrors = false) => { if (!clearFormErrors) { formActions.updateFormState({ serverErrors: [] }); } formActions.incrementRequestCount(busyKey); try { return await fetch(`${formActions.apiUrlBase}/${url}`, { method: options.method, body: options.bodyObject == null ? undefined : JSON.stringify(options.bodyObject), headers: defaultHeaders, credentials: "include" }); } finally { formActions.decrementRequestCount(busyKey); } }; const isOneOffPurchase = (paymentOption) => paymentOption.type === 'ONE_OFF'; const getChangeSubscriptionPaymentConfiguration = (form, formState) => { const paymentConfig = formConfigAs(form); const environmentKey = formState.paymentOption?.virtualEnvironment || 'live'; if (formState.requiresPaymentMethodSetup && paymentConfig.paymentMethodSetupFormConfig) { const setupConfig = paymentConfig.paymentMethodSetupFormConfig[environmentKey]; if (setupConfig) { return setupConfig; } } // Virtual environments for change subscription if (paymentConfig.virtualEnvironmentsPaymentProviderFormConfig && formState.paymentOption?.virtualEnvironment) { const envConfig = paymentConfig.virtualEnvironmentsPaymentProviderFormConfig[environmentKey]; if (envConfig) { return envConfig; } } // 3. Fallback to regular config return paymentConfig.paymentProviderFormConfig; }; const mapToPayRequest = (form, formState, paymentProvider, vendorFields) => { if (formState.paymentOption.pricePointId) { return { url: `blaize/payment/${paymentProvider}/buy`, body: { product_id: formState.paymentOption.productId, price_point_id: formState.paymentOption.slug, discount_code: formState.promoCodeValid ? formState.promoCode : undefined, ...vendorFields } }; } let endpoint; let method; let changeSubscriptionBodyParams = {}; if (formConfigAs(form).changeSubscriptionMode || formState.convertCancelSubscriptionToAcceptOffer) { let subscriptionExternalId; if (formState.convertCancelSubscriptionToAcceptOffer) { // For cancel save offers, use the selected subscription subscriptionExternalId = formState.selectedSubscription.externalId; } else { // For regular change subscription, find from validChangeFromPlans const changingFromSubscription = formState .validChangeFromPlans .find(plan => formState.paymentOption.slug === plan.planSlug && formState.paymentOption.productId === plan.productId) .changesFromSubscription; subscriptionExternalId = changingFromSubscription.externalId; } endpoint = `subscriptions/${subscriptionExternalId}`; method = 'PATCH'; changeSubscriptionBodyParams = { navigated_from: `ChangeForm ${window.location.href}` }; } else if (isOneOffPurchase(formState.paymentOption)) { endpoint = 'payment/buy'; method = 'POST'; } else { endpoint = 'subscribe'; method = 'POST'; } return { url: `zephr/${endpoint}`, method, body: { product_id: formState.paymentOption.productId, plan_id: formState.paymentOption.slug, discount_code: formState.promoCodeValid ? formState.promoCode : undefined, ...changeSubscriptionBodyParams, vendor_fields: vendorFields ?? {} } }; }; const tokenPath = 'blaize/payment/braintree/token'; let braintreeInstance; const loadBraintree = new Promise(function (resolve) { window.braintreeLoadCallback = resolve; }); // https://braintree.github.io/braintree-web-drop-in/docs/current/module-braintree-web-drop-in.html#~paypalCreateOptions const paypalConfiguration = (formState) => ({ flow: formState.paymentOption.type === 'ONE_OFF' ? 'checkout' : 'vault', singleUse: true, buttonStyle: { shape: 'rect', size: 'medium' }, // Show 'continue' button rather than 'pay now' on the PayPal modal commit: false, currency: formState.paymentOption.currencyCode.toLowerCase(), amount: formState.paymentOptionPrices.totalPrice, }); const getBraintreeToken = (formState, formActions) => request(tokenPath, { method: "GET" }, formActions, null, true) .then(response => response.json()) .then(json => json.token); const loadBraintreeUi = (form, formState, formActions) => { const paypalEnabled = formConfigAs(form).paymentProviderFormConfig?.enablePaypal; formActions.incrementRequestCount(); void loadBraintree .then(() => getBraintreeToken(formState, formActions)) .then((braintreeToken) => { window.braintree.dropin.create({ authorization: braintreeToken, container: '#braintree-dropin-container', ...(paypalEnabled ? { paypal: paypalConfiguration(formState) } : {}) }, (createErr, instance) => { formActions.decrementRequestCount(); braintreeInstance = instance; formActions.updateFormState({ paymentProviderFormLoaded: true, }); if (createErr) { throw createErr; } // If this is an existing user, they may already have a payment option and paymentMethodRequestable won't be fired if (braintreeInstance.isPaymentMethodRequestable()) { formActions.updateFormState({ paymentFormComplete: true }); } braintreeInstance.on('paymentMethodRequestable', () => { formActions.updateFormState({ paymentFormComplete: true }); }); braintreeInstance.on('noPaymentMethodRequestable', () => { formActions.updateFormState({ paymentFormComplete: false }); }); }); }).catch(err => { console.error(err); formActions.decrementRequestCount(); }); }; const braintreePay = async (form, formState, formActions) => { formActions.incrementRequestCount(); let resolveHandle, rejectHandle; const promise = new Promise((resolve, reject) => { resolveHandle = resolve, rejectHandle = reject; }); const success = () => { formActions.decrementRequestCount(); resolveHandle(); }; const errored = (err) => { console.error(err); formActions.decrementRequestCount(); rejectHandle(); }; braintreeInstance.requestPaymentMethod((err, payload) => { if (err || !payload) { errored(`Error requesting payment method ${JSON.stringify(err)}`); } const { url, body, method } = mapToPayRequest(form, formState, paymentProviders.BRAINTREE, { payment_nonce: payload.nonce, ...(payload.type === 'PayPalAccount' ? { paypal: true } : {}) }); return request(url, { method, bodyObject: body }, formActions) .then(response => { if (response?.ok) { success(); return; } errored(response); }).catch((err) => { errored(err); }); }); return promise; }; const braintreeChangePayment = async (form, formState, formActions) => { let resolveHandle, rejectHandle; const promise = new Promise((resolve, reject) => { resolveHandle = resolve, rejectHandle = reject; }); braintreeInstance.requestPaymentMethod((err, payload) => { if (err || !payload) { console.error(`Error requesting payment method ${JSON.stringify(err)}`); } return request(`blaize/payment/braintree/subscriptions/${formState.selectedSubscription?.externalId}`, { method: 'PATCH', bodyObject: { payment_method_nonce: payload?.nonce, } }, formActions) .then(response => { console.log(response); if (response?.ok) { resolveHandle(); return; } rejectHandle(response); }).catch((err) => { rejectHandle(err); }); }); return promise; }; /** * Mobile (Social) payment services * * note: Using a string-backed enum here for better debug logging. */ var MobilePaymentService; (function (MobilePaymentService) { MobilePaymentService["GOOGLE_PAY"] = "GOOGLE_PAY"; MobilePaymentService["APPLE_PAY"] = "APPLE_PAY"; })(MobilePaymentService || (MobilePaymentService = {})); const loadGooglePay$1 = new Promise(function (resolve) { window.googlePayLoadBraintreeCallback = resolve; }); const loadBraintreeApplePay = new Promise(function (resolve) { window.applePayLoadBraintreeCallback = resolve; }); const braintreePayWithMobile = (form, formState, formActions) => { const { url, body, method } = mapToPayRequest(form, formState, paymentProviders.BRAINTREE, { payment_nonce: formState.mobilePaymentMethodId, vault_payment_method: true }); return request(url, { method, bodyObject: body }, formActions) .then(response => { if (!response?.ok) { throw JSON.stringify(response); } }); }; const configureBraintreeMobilePayments = async (form, formState, formActions) => { await configureBraintreeGooglePay(form, formState, formActions); await configureBraintreeApplePay(form, formState, formActions); }; const configureBraintreeGooglePay = (form, formState, formActions) => { const braintreeMobilePaymentConfig = JSON.parse(form.organisationConfiguration?.braintreeMobilePaymentConfig ?? "{}"); let googlePaymentsClient; return loadGooglePay$1 .then(() => { const container = document.getElementById('google-pay-button'); // Empty the container while (container.firstChild) { container.removeChild(container.lastChild); } // No need to show the user any errors here just hide the button if (!braintreeMobilePaymentConfig?.google) { container.style.display = 'none'; console.error("Braintree Mobile payments are not configured in the console"); return; } formState = formActions.getFormState(); googlePaymentsClient = new window.google.payments.api.PaymentsClient({ environment: form.organisationConfiguration.braintreeSandboxEnv ? 'TEST' : 'PRODUCTION' }); void loadBraintree .then(() => getBraintreeToken(formState, formActions)) .then((braintreeToken) => { window.braintree.client.create({ authorization: braintreeToken }, (createErr, clientInstance) => { // Empty the container while (container.firstChild) { container.removeChild(container.lastChild); } if (createErr) { // No need to show the user any errors here just hide the button console.error("Error creating braintree client", createErr); container.style.display = 'none'; return; } window.braintree.googlePayment.create({ client: clientInstance, googlePayVersion: 2, googleMerchantId: braintreeMobilePaymentConfig.google.googleMerchantId }, (googlePaymentErr, googlePaymentInstance) => { if (googlePaymentErr) { // No need to show the user any errors here just hide the button console.error("Error creating braintree client", googlePaymentErr); container.style.display = 'none'; return; } googlePaymentsClient.isReadyToPay({ apiVersion: 2, apiVersionMinor: 0, allowedPaymentMethods: googlePaymentInstance.createPaymentDataRequest().allowedPaymentMethods, existingPaymentMethodRequired: true, }).then((response) => { if (!response.result || !response.paymentMethodPresent) { container.style.display = 'none'; console.error(response.paymentMethodPresent ? "Google Pay support not found" : "No payment method"); formActions.updateFormState({ serverErrors: [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); } container.appendChild(googlePaymentsClient.createButton({ buttonColor: 'default', buttonType: 'plain', buttonSizeMode: 'fill', onClick: () => { onClickPaymentButton$1(form, formState, formActions, googlePaymentInstance, googlePaymentsClient); }, })); }); }); }); }); }); }; const onClickPaymentButton$1 = (form, formState, formActions, googlePaymentInstance, googlePaymentsClient) => { formActions.updateFormState({ mobilePaymentService: MobilePaymentService.GOOGLE_PAY, serverErrors: [], }); const paymentDataRequest = googlePaymentInstance.createPaymentDataRequest({ transactionInfo: { currencyCode: formState.paymentOption.currencyCode, totalPriceStatus: 'FINAL', totalPrice: formState.paymentOptionPrices.totalPrice.toFixed(2) }, emailRequired: false, shippingAddressRequired: false }); googlePaymentsClient.loadPaymentData(paymentDataRequest).then(function (paymentData) { googlePaymentInstance.parseResponse(paymentData, (err, result) => { if (err || !result.nonce) { formActions.updateFormState({ serverErrors: [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], mobilePaymentService: null, }); console.error('Error requesting payment data', err, result); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); return; } formActions.updateFormState({ mobilePaymentMethodId: result.nonce }); formActions.completeSection(); }); }).catch(function (err) { // If we get heree, the user may have just closed the modal without paying. // Not sure if we should be showing an error in that case, but we cant distinguish // it from other failure cases https://developers.google.com/pay/api/web/reference/client#errors_1 console.warn('Error requesting payment data', err); formActions.updateFormState({ mobilePaymentService: null, serverErrors: [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); }); }; const configureBraintreeApplePay = (form, formState, formActions) => { const apple_container = document.getElementById('apple_pay_button'); while (apple_container.firstChild) { apple_container.removeChild(apple_container.lastChild); } return loadBraintreeApplePay .then(() => { if (!(window.ApplePaySession && window.ApplePaySession.supportsVersion(3) && window.ApplePaySession.canMakePayments())) { apple_container.style.display = 'none'; console.log('Cannot make payments with Apple Pay'); return; } return loadBraintree .then(() => getBraintreeToken(formState, formActions)) .then((braintreeToken) => { window.braintree.client.create({ authorization: braintreeToken }, (clientErr, clientInstance) => { if (clientErr) { apple_container.style.display = 'none'; console.error('Error creating braintree client:', clientErr); return; } window.braintree.applePay.create({ client: clientInstance }, function (applePayErr, applePayInstance) { while (apple_container.firstChild) { apple_container.removeChild(apple_container.lastChild); } if (applePayErr) { apple_container.style.display = 'none'; console.error('Error creating applePayInstance:', applePayErr); return; } const paymentRequest = applePayInstance.createPaymentRequest({ total: { label: formState.paymentOption.label, amount: formState.paymentOptionPrices.totalPrice.toFixed(2) } }); const applePayDiv = document.createElement("div"); applePayDiv.classList.add("apple-pay-button"); applePayDiv.classList.add("apple-pay-button-black"); apple_container.appendChild(applePayDiv); applePayDiv.addEventListener('click', function () { onClickApplePayment(form, formState, formActions, paymentRequest, applePayInstance); }); }); }); }); }); }; const onClickApplePayment = (form, formState, formActions, paymentRequest, applePayInstance) => { formActions.updateFormState({ mobilePaymentService: MobilePaymentService.APPLE_PAY, serverErrors: [], }); const session = new ApplePaySession(3, paymentRequest); session.onvalidatemerchant = function (event) { applePayInstance.performValidation({ validationURL: event.validationURL, displayName: formState.paymentOption.label }, function (err, merchantSession) { if (err) { formActions.updateFormState({ serverErrors: [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], mobilePaymentService: null, }); console.log('err in onvalidatemerchant in apple pay configuration: ', err); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); return; } session.completeMerchantValidation(merchantSession); }); }; session.onpaymentauthorized = function (event) { applePayInstance.tokenize({ token: event.payment.token }, function (tokenizeErr, payload) { if (tokenizeErr) { formActions.updateFormState({ serverErrors: [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], mobilePaymentService: null, }); console.error('Error tokenizing Apple Pay:', tokenizeErr); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); session.completePayment(ApplePaySession.STATUS_FAILURE); return; } formActions.updateFormState({ mobilePaymentMethodId: payload.nonce }); formActions.completeSection(); session.completePayment(ApplePaySession.STATUS_SUCCESS); }); }; session.begin(); }; const invalidCurrencySymbol = '¤'; const roundingErrorSmallNumber = 0.00001; const formatFromCurrencyCode = (price, currencyCode) => new Intl.NumberFormat(undefined, { style: 'currency', currency: currencyCode, minimumFractionDigits: Math.abs(price) % 1 currencySymbol?.length === 1 ? `${currencySymbol}${price}` : `${price} ${currencySymbol}`.trim(); /** * currency might either be a symbol ($,£,etc) or a code (GBP,EUR) */ const formatCurrency = (price, currency) => { try { if (currency?.length === 3) { const formatted = formatFromCurrencyCode(price, currency); if (!formatted.includes(invalidCurrencySymbol)) { return formatted; } } } catch (e) { console.warn(`Error formatting currency for symbol ${currency}`, e); } return formatFromCurrencySymbol(price, currency); }; const getProductAddons = async (form, formState, formActions, skipMobileReload = false) => { const providerConfig = paymentProviderFor(form.organisationConfiguration.paymentProvider); if (!providerConfig.hasProductAddons || !(formState.loginRegistrationComplete || formState.userSession)) { return Promise.resolve(formState); } return request(providerConfig.productAddonPath, { method: 'POST', bodyObject: { promoCode: formState.promoCodeValid ? formState.promoCode : null, paymentOptions: formConfigAs(form).paymentOptions } }, formActions, null, true) .then(async (response) => { if (!response.ok) { console.log("error loading product addons", response); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); return formActions.updateFormState({ addons: [], serverErrors: [ServerError.UNKNOWN] }); } const json = await response.json(); try { const addons = json.map(addon => ({ id: addon.id, label: addon.label, planPrices: addon.paymentOptions.map(planAddon => ({ planSlug: planAddon.slug, productId: planAddon.productId, addonPrice: planAddon.addonPrice })) })); return formActions.updateFormState({ addons }); } catch (err) { console.error("Error parsing product addons response", err, json); return formState; } }).then(async (updatedFormState) => { if (!skipMobileReload) { await afterProductAddonChange(form, updatedFormState, formActions); } return updatedFormState; }); }; /* If we're using mobile payment and we're on the payment screen, we'll need to reload the mobile payment button so it has the discounted amount and make sure they can't press the button while the button is updating */ const afterProductAddonChange = async (form, formState, formActions) => { if (formState.currentSection.elements.some(element => element.type === elementTypes.MOBILE_PAYMENT && element.config?.enabled !== false)) { formActions.incrementRequestCount(); try { // Only reload mobile payment service if the provider actually supports mobile payments if (supportsMobilePayments(form.organisationConfiguration.paymentProvider)) { await mobilePaymentServiceFor(form.organisationConfiguration.paymentProvider).loader(form, formState, formActions); } } finally { formActions.decrementRequestCount(); } } }; const addonsForPlan = (formState) => formState.addons.map(addon => { const plan = addon.planPrices .find(plan => plan.planSlug === formState.paymentOption.slug && plan.productId === formState.paymentOption.productId); return plan && { label: addon.label, addonPrice: plan.addonPrice, addonPriceFormattedString: formatCurrency(plan.addonPrice, formState.paymentOption.currencyCode) }; }).filter(o => o); /** * Calculate the actual prices for a payment option, considering: * - The payment option * - Discount code * * Try not to run the calculation if the inputs have not changed from the previous calculation. */ const calculatePrices = async (form, formState, formActions) => { if (formState.paymentOptionPrices != null && formState.paymentOptionPrices.productId === formState.paymentOption.productId && formState.paymentOptionPrices.slug === formState.paymentOption.slug && formState.paymentOptionPrices.promoCode === formState.promoCode && formState.paymentOptionPrices.addonPrices == addonsForPlan(formState) && formState.paymentOptionPrices.billingAddress.country === formState.billingAddress.country && formState.paymentOptionPrices.billingAddress.postalCode === formState.billingAddress.postalCode // // This is a bit of a fudge but we know that there are only addons for braintree where the price calculation is non-io && formState.paymentOptionPrices.addonPrices.length == 0 && addonsForPlan(formState).length == 0) { return formState; } formActions.updateFormState({ paymentOptionPrices: null }); const paymentOptionPrices = await paymentProviderFor(form.organisationConfiguration.paymentProvider).priceCalculator(form, formState, formActions); return formActions.updateFormState({ paymentOptionPrices }); }; // See https://stripe.com/docs/currencies const currencies = [ "BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW", "MGA", "PYG", "RWF", "UGX", "VND", "VUV", "XAF", "XOF", "XPF", ]; const isZeroDecimalCurrency = currencyCode => currencies.includes(currencyCode); const stripePaymentElementAppearance = (siteStyles) => { const stylesObj = JSON.parse(siteStyles ?? "{}"); return { variables: { color: stylesObj?.color?.text?.main ?? '#32325d', fontFamily: `${stylesObj?.typography?.body?.font}, ${stylesObj?.typography?.body?.fallbackFont}, "Helvetica Neue", Helvetica, sans-serif`, fontSmooth: 'always', fontSizeBase: '16px', colorWarningText: stylesObj?.color?.warning?.main ?? '#fa755a', colorIconCardError: stylesObj?.color?.warning?.main ?? '#fa755a', borderRadius: `${(stylesObj?.input?.borderRadius ?? '4')}px` }, rules: { '.Input::placeholder': { color: '#aab7c4' }, } }; }; const stripeCardElementStyle = { base: { color: '#32325d', fontFamily: '"Helvetica Neue", Helvetica, sans-serif', fontSmoothing: 'antialiased', fontSize: '16px', '::placeholder': { color: '#aab7c4' } }, invalid: { color: '#fa755a', iconColor: '#fa755a' } }; const createStripePaymentElement = (stripe, form, formActions) => { const formState = formActions.getFormState(); const currencyMultiplier = isZeroDecimalCurrency(formState.paymentOption.currencyCode.toUpperCase()) ? 1 : 100; const elements = stripe.elements({ mode: 'payment', currency: formState.paymentOption.currencyCode.toLowerCase(), amount: parseFloat((formState.paymentOptionPrices.totalPrice * currencyMultiplier).toFixed(2)), setup_future_usage: 'off_session', appearance: stripePaymentElementAppearance(form.organisationConfiguration.siteStyles), paymentMethodTypes: ['card'] }); return elements.create('payment', { terms: { card: 'never' }, wallets: { applePay: 'never', googlePay: 'never' } }); }; const createStripeCardElement = (stripe) => { return stripe.elements().create('card', { style: stripeCardElementStyle }); }; const createStripeElement = (stripe, form, formActions) => { if (form.organisationConfiguration.stripeAutomaticTaxEnabled && form.formType !== FormType.LIST_SUBSCRIPTIONS || formConfigAs(form).paymentProviderFormConfig?.usePaymentElement) { return createStripePaymentElement(stripe, form, formActions); } else { return createStripeCardElement(stripe); } }; /*! * mustache.js - Logic-less {{mustache}} templates with JavaScript * http://github.com/janl/mustache.js */ var objectToString = Object.prototype.toString; var isArray = Array.isArray || function isArrayPolyfill (object) { return objectToString.call(object) === '[object Array]'; }; function isFunction (object) { return typeof object === 'function'; } /** * More correct typeof string handling array * which normally returns typeof 'object' */ function typeStr (obj) { return isArray(obj) ? 'array' : typeof obj; } function escapeRegExp (string) { return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&'); } /** * Null safe way of checking whether or not an object, * including its prototype, has a given property */ function hasProperty (obj, propName) { return obj != null && typeof obj === 'object' && (propName in obj); } /** * Safe way of detecting whether or not the given thing is a primitive and * whether it has the given property */ function primitiveHasOwnProperty (primitive, propName) { return ( primitive != null && typeof primitive !== 'object' && primitive.hasOwnProperty && primitive.hasOwnProperty(propName) ); } // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577 // See https://github.com/janl/mustache.js/issues/189 var regExpTest = RegExp.prototype.test; function testRegExp (re, string) { return regExpTest.call(re, string); } var nonSpaceRe = /\S/; function isWhitespace (string) { return !testRegExp(nonSpaceRe, string); } var entityMap = { '&': ' ', ' ': ' ', '"': ' ', "'": ''', '/': '/', '`': '`', '=': '=' }; function escapeHtml (string) { return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { return entityMap[s]; }); } var whiteRe = /\s*/; var spaceRe = /\s+/; var equalsRe = /\s*=/; var curlyRe = /\s*\}/; var tagRe = /#|\^|\/|>|\{|&|=|!/; /** * Breaks up the given `template` string into a tree of tokens. If the `tags` * argument is given here it must be an array with two string values: the * opening and closing tags used in the template (e.g. [ " " ]). Of * course, the default is to use mustaches (i.e. mustache.tags). * * A token is an array with at least 4 elements. The first element is the * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag * did not contain a symbol (i.e. {{myValue}}) this element is "name". For * all text that appears outside a symbol this element is "text". * * The second element of a token is its "value". For mustache tags this is * whatever else was inside the tag besides the opening symbol. For text tokens * this is the text itself. * * The third and fourth elements of the token are the start and end indices, * respectively, of the token in the original template. * * Tokens that are the root node of a subtree contain two more elements: 1) an * array of tokens in the subtree and 2) the index in the original template at * which the closing tag for that section begins. * * Tokens for partials also contain two more elements: 1) a string value of * indendation prior to that tag and 2) the index of that tag on that line - * eg a value of 2 indicates the partial is the third tag on this line. */ function parseTemplate (template, tags) { if (!template) return []; var lineHasNonSpace = false; var sections = []; // Stack to hold section tokens var tokens = []; // Buffer to hold the tokens var spaces = []; // Indices of whitespace tokens on the current line var hasTag = false; // Is there a {{tag}} on the current line? var nonSpace = false; // Is there a non-space char on the current line? var indentation = ''; // Tracks indentation for tags that use it var tagIndex = 0; // Stores a count of number of tags encountered on a line // Strips all whitespace tokens array for the current line // if there was a {{#tag}} on it and otherwise only space. function stripSpace () { if (hasTag && !nonSpace) { while (spaces.length) delete tokens[spaces.pop()]; } else { spaces = []; } hasTag = false; nonSpace = false; } var openingTagRe, closingTagRe, closingCurlyRe; function compileTags (tagsToCompile) { if (typeof tagsToCompile === 'string') tagsToCompile = tagsToCompile.split(spaceRe, 2); if (!isArray(tagsToCompile) || tagsToCompile.length !== 2) throw new Error('Invalid tags: ' + tagsToCompile); openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*'); closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1])); closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1])); } compileTags(tags || mustache.tags); var scanner = new Scanner(template); var start, type, value, chr, token, openSection; while (!scanner.eos()) { start = scanner.pos; // Match any text between tags. value = scanner.scanUntil(openingTagRe); if (value) { for (var i = 0, valueLength = value.length; i ') { token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ]; } else { token = [ type, value, start, scanner.pos ]; } tagIndex++; tokens.push(token); if (type === '#' || type === '^') { sections.push(token); } else if (type === '/') { // Check section nesting. openSection = sections.pop(); if (!openSection) throw new Error('Unopened section "' + value + '" at ' + start); if (openSection[1] !== value) throw new Error('Unclosed section "' + openSection[1] + '" at ' + start); } else if (type === 'name' || type === '{' || type === '&') { nonSpace = true; } else if (type === '=') { // Set the tags for the next time around. compileTags(value); } } stripSpace(); // Make sure there are no open sections when we're done. openSection = sections.pop(); if (openSection) throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos); return nestTokens(squashTokens(tokens)); } /** * Combines the values of consecutive text tokens in the given `tokens` array * to a single token. */ function squashTokens (tokens) { var squashedTokens = []; var token, lastToken; for (var i = 0, numTokens = tokens.length; i 0 ? sections[sections.length - 1][4] : nestedTokens; break; default: collector.push(token); } } return nestedTokens; } /** * A simple string scanner that is used by the template parser to find * tokens in template strings. */ function Scanner (string) { this.string = string; this.tail = string; this.pos = 0; } /** * Returns `true` if the tail is empty (end of string). */ Scanner.prototype.eos = function eos () { return this.tail === ''; }; /** * Tries to match the given regular expression at the current position. * Returns the matched text if it can match, the empty string otherwise. */ Scanner.prototype.scan = function scan (re) { var match = this.tail.match(re); if (!match || match.index !== 0) return ''; var string = match[0]; this.tail = this.tail.substring(string.length); this.pos += string.length; return string; }; /** * Skips all text until the given regular expression can be matched. Returns * the skipped string, which is the entire tail if no match can be made. */ Scanner.prototype.scanUntil = function scanUntil (re) { var index = this.tail.search(re), match; switch (index) { case -1: match = this.tail; this.tail = ''; break; case 0: match = ''; break; default: match = this.tail.substring(0, index); this.tail = this.tail.substring(index); } this.pos += match.length; return match; }; /** * Represents a rendering context by wrapping a view object and * maintaining a reference to the parent context. */ function Context (view, parentContext) { this.view = view; this.cache = { '.': this.view }; this.parent = parentContext; } /** * Creates a new context using the given view with this context * as the parent. */ Context.prototype.push = function push (view) { return new Context(view, this); }; /** * Returns the value of the given name in this context, traversing * up the context hierarchy if the value is absent in this context's view. */ Context.prototype.lookup = function lookup (name) { var cache = this.cache; var value; if (cache.hasOwnProperty(name)) { value = cache[name]; } else { var context = this, intermediateValue, names, index, lookupHit = false; while (context) { if (name.indexOf('.') > 0) { intermediateValue = context.view; names = name.split('.'); index = 0; /** * Using the dot notion path in `name`, we descend through the * nested objects. * * To be certain that the lookup has been successful, we have to * check if the last object in the path actually has the property * we are looking for. We store the result in `lookupHit`. * * This is specially necessary for when the value has been set to * `undefined` and we want to avoid looking up parent contexts. * * In the case where dot notation is used, we consider the lookup * to be successful even if the last "object" in the path is * not actually an object but a primitive (e.g., a string, or an * integer), because it is sometimes useful to access a property * of an autoboxed primitive, such as the length of a string. **/ while (intermediateValue != null && index " ]). The default is to mustache.tags. * * The `escape` attribute of a `config` object must be a function which * accepts a string as input and outputs a safely escaped string. * If an `escape` function is not provided, then an HTML-safe string * escaping function is used as the default. */ Writer.prototype.render = function render (template, view, partials, config) { var tags = this.getConfigTags(config); var tokens = this.parse(template, tags); var context = (view instanceof Context) ? view : new Context(view, undefined); return this.renderTokens(tokens, context, partials, template, config); }; /** * Low-level method that renders the given array of `tokens` using * the given `context` and `partials`. * * Note: The `originalTemplate` is only ever used to extract the portion * of the original template that was contained in a higher-order section. * If the template doesn't use higher-order sections, this argument may * be omitted. */ Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) { var buffer = ''; var token, symbol, value; for (var i = 0, numTokens = tokens.length; i ') value = this.renderPartial(token, context, partials, config); else if (symbol === '&') value = this.unescapedValue(token, context); else if (symbol === 'name') value = this.escapedValue(token, context, config); else if (symbol === 'text') value = this.rawValue(token); if (value !== undefined) buffer += value; } return buffer; }; Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) { var self = this; var buffer = ''; var value = context.lookup(token[1]); // This function is used to render an arbitrary template // in the current context by higher-order sections. function subRender (template) { return self.render(template, context, partials, config); } if (!value) return; if (isArray(value)) { for (var j = 0, valueLength = value.length; j 0 || !lineHasNonSpace)) { partialByNl[i] = filteredIndentation + partialByNl[i]; } } return partialByNl.join('\n'); }; Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) { if (!partials) return; var tags = this.getConfigTags(config); var value = isFunction(partials) ? partials(token[1]) : partials[token[1]]; if (value != null) { var lineHasNonSpace = token[6]; var tagIndex = token[5]; var indentation = token[4]; var indentedValue = value; if (tagIndex == 0 && indentation) { indentedValue = this.indentPartial(value, indentation, lineHasNonSpace); } var tokens = this.parse(indentedValue, tags); return this.renderTokens(tokens, context, partials, indentedValue, config); } }; Writer.prototype.unescapedValue = function unescapedValue (token, context) { var value = context.lookup(token[1]); if (value != null) return value; }; Writer.prototype.escapedValue = function escapedValue (token, context, config) { var escape = this.getConfigEscape(config) || mustache.escape; var value = context.lookup(token[1]); if (value != null) return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value); }; Writer.prototype.rawValue = function rawValue (token) { return token[1]; }; Writer.prototype.getConfigTags = function getConfigTags (config) { if (isArray(config)) { return config; } else if (config && typeof config === 'object') { return config.tags; } else { return undefined; } }; Writer.prototype.getConfigEscape = function getConfigEscape (config) { if (config && typeof config === 'object' && !isArray(config)) { return config.escape; } else { return undefined; } }; var mustache = { name: 'mustache.js', version: '4.2.0', tags: [ '{{', '}}' ], clearCache: undefined, escape: undefined, parse: undefined, render: undefined, Scanner: undefined, Context: undefined, Writer: undefined, /** * Allows a user to override the default caching strategy, by providing an * object with set, get and clear methods. This can also be used to disable * the cache by setting it to the literal `undefined`. */ set templateCache (cache) { defaultWriter.templateCache = cache; }, /** * Gets the default or overridden caching object from the default writer. */ get templateCache () { return defaultWriter.templateCache; } }; // All high-level mustache.* functions use this writer. var defaultWriter = new Writer(); /** * Clears all cached templates in the default writer. */ mustache.clearCache = function clearCache () { return defaultWriter.clearCache(); }; /** * Parses and caches the given template in the default writer and returns the * array of tokens it contains. Doing this ahead of time avoids the need to * parse templates on the fly as they are rendered. */ mustache.parse = function parse (template, tags) { return defaultWriter.parse(template, tags); }; /** * Renders the `template` with the given `view`, `partials`, and `config` * using the default writer. */ mustache.render = function render (template, view, partials, config) { if (typeof template !== 'string') { throw new TypeError('Invalid template! Template should be a "string" ' + 'but "' + typeStr(template) + '" was given as the first ' + 'argument for mustache#render(template, view, partials)'); } return defaultWriter.render(template, view, partials, config); }; // Export the escaping function so that the user may override it. // See https://github.com/janl/mustache.js/issues/244 mustache.escape = escapeHtml; // Export these mainly for testing, but also for advanced usage. mustache.Scanner = Scanner; mustache.Context = Context; mustache.Writer = Writer; const processMustacheTemplate = (template, scope) => { return mustache.render(template, scope); }; const getUserAttributes = async (formActions) => { try { return await request('blaize/profile', { method: "GET" }, formActions).then(response => response.json()); } catch (error) { console.error('Failed to fetch user attributes:', error); return {}; } }; const getSessions = async (formActions) => { try { const response = await request('zephr/public/sessions/v1/sessions', { method: "GET" }, formActions, null, true); return await response.json(); } catch (error) { console.error('Failed to fetch sessions:', error); return []; } }; const getUtmParameters = () => { const params = new URLSearchParams(window.location.search); return { source: params.get('utm_source'), medium: params.get('utm_medium'), campaign: params.get('utm_campaign'), term: params.get('utm_term'), content: params.get('utm_content') }; }; const initializeSubscriptionScope = async (form, formActions) => { try { const [sessions, attributes] = await Promise.all([ getSessions(formActions), getUserAttributes(formActions) ]); const deviceSession = sessions.find(session => session.requestingSession) || null; return { page: { url: window.location.href, path: window.location.pathname, searchParameters: Object.fromEntries(new URLSearchParams(window.location.search)), utmParameters: getUtmParameters(), referrer: document.referrer || null }, user: { attributes: attributes, session: deviceSession ? { id: deviceSession.id, tenantId: deviceSession.tenantId, userId: deviceSession.userId, deviceName: deviceSession.deviceName, browser: deviceSession.browser, startDate: deviceSession.startDate, ipAddress: deviceSession.ipAddress ?? null, requestingSession: deviceSession.requestingSession } : null, geoLocation: { city: deviceSession?.city ?? "unknown", country: deviceSession?.country ?? "unknown", state: deviceSession?.geoState ?? "unknown", ipAddress: deviceSession?.ipAddress ?? null } }, form: { id: form.id, outcomeId: form.outcomeId, ruleId: form.ruleId } }; } catch (error) { console.error('Failed to initialize subscription scope:', error); throw error; } }; const publicKeyPath = 'blaize/payment/stripe/publicKey'; const getStripePublicKey = (formActions) => request(publicKeyPath, { method: "GET" }, formActions, null, true) .then(response => response.text()); let loadStripePromise, stripe, stripeElement; const loadStripe = (formActions) => { if (loadStripePromise) { return loadStripePromise; } return loadStripePromise = new Promise(function (resolve) { window.stripeLoadCallback = resolve; }).then(() => getStripePublicKey(formActions)) .then(publicKey => { stripe = window.Stripe(publicKey); return stripe; }); }; const handleStripeFormChecktax = (event, form, formActions) => { // only check tax if the form is complete if (!event.complete) { return; } formActions.incrementRequestCount(); stripe .createPaymentMethod('card', stripeElement, {}) .then(({ error, paymentMethod }) => { if (error || !paymentMethod) { console.error(`Error requesting payment method ${JSON.stringify(error)}`); return null; } formActions.updateFormState({ paymentMethodId: paymentMethod.id }); return paymentMethod?.billing_details?.address; }) .catch((error) => { console.error(`Error requesting payment method ${JSON.stringify(error)}`); return null; }).then((billingAddress) => calculatePrices(form, formActions.updateFormState({ billingAddress: { country: billingAddress?.country, postalCode: billingAddress?.postal_code, } }), formActions)) .catch((error) => { console.error(`Error requesting payment method ${JSON.stringify(error)}`); }).finally(() => { formActions.decrementRequestCount(); }); }; const loadStripeUi = (form, formState, formActions) => { formActions.incrementRequestCount(); void loadStripe(formActions).then(() => { stripeElement = createStripeElement(stripe, form, formActions); const id = '#stripe-element-' + form.uniqueKey; stripeElement.mount(id); stripeElement.addEventListener('change', (event) => { formActions.updateFormState({ paymentProviderError: event.error, paymentFormComplete: event.complete, serverErrors: [] }); if (form.organisationConfiguration.stripeAutomaticTaxEnabled && form.formType !== FormType.LIST_SUBSCRIPTIONS) { handleStripeFormChecktax(event, form, formActions); } }); stripeElement.addEventListener('ready', () => { formActions.updateFormState({ paymentProviderFormLoaded: true, }); }); formActions.decrementRequestCount(); }).catch(err => { console.error(err); formActions.decrementRequestCount(); }); }; const stripePay = (form, formState, formActions) => { const paymentMethodId = formState.paymentMethodId; formActions.incrementRequestCount(); if (paymentMethodId) { return performPay(form, formState, formActions, paymentMethodId); } else { return stripe.createPaymentMethod('card', stripeElement, {}) .then(async ({ error, paymentMethod }) => { if (error || !paymentMethod) { formActions.decrementRequestCount(); throw `Error requesting payment method ${JSON.stringify(error)}`; } await performPay(form, formState, formActions, paymentMethod.id); }); } }; const stripeChangePayment = (form, formState, formActions) => { const paymentMethodId = formState.paymentMethodId; formActions.incrementRequestCount(); if (paymentMethodId) { return performChangePayment(form, formState, formActions, paymentMethodId); } else { return stripe.createPaymentMethod('card', stripeElement, {}) .then(async ({ error, paymentMethod }) => { if (error || !paymentMethod) { formActions.decrementRequestCount(); throw `Error requesting payment method ${JSON.stringify(error)}`; } await request('zephr/payment/stripe/setupIntentSecret', { method: 'POST', }, formActions) .then(async (resp) => { const json = await resp.json(); const token = json.clientSecret; return stripe.confirmCardSetup(token, { payment_method: { card: stripeElement, }, }); }).then(async (resp) => { return performChangePayment(form, formState, formActions, resp.setupIntent.payment_method); }); }); } }; const performChangePayment = (form, formState, formActions, paymentMethod) => { return request('zephr/payment/stripe/updateSubscription', { method: 'POST', bodyObject: { payment_method_id: paymentMethod, subscription_id: formState.selectedSubscription.externalId, }, }, formActions); }; const performPay = async (form, formState, formActions, paymentMethod) => { const subscriptionMetadataRaw = (formConfigAs(form).paymentProviderFormConfig?.subscriptionMetadata || {}); const subscriptionMetadata = {}; if (subscriptionMetadataRaw) { const subscriptionFormScope = await initializeSubscriptionScope(form, formActions); for (const [key, value] of Object.entries(subscriptionMetadataRaw)) { subscriptionMetadata[key] = processMustacheTemplate(value, subscriptionFormScope) || ''; } } const hasSubscriptionMetadata = !!Object.keys(subscriptionMetadata).length; const { url, body, method } = mapToPayRequest(form, formState, paymentProviders.STRIPE, { payment_method: paymentMethod, billing_address_provided: !!formState.billingAddress.country, ...(hasSubscriptionMetadata ? { subscription_metadata: JSON.stringify(subscriptionMetadata) } : {}), }); return request(url, { method, bodyObject: body }, formActions) .then(async (response) => { if (!response?.ok) { throw JSON.stringify(response); } return response.json(); }).then(responseJson => { if (responseJson.grant_id) { return; } if (responseJson.paymentIntentStatus === 'requires_action') { return stripe.confirmCardPayment(responseJson.clientSecret ?? responseJson.client_secret) .then(afterConfirmResponse => { if (afterConfirmResponse.error || !afterConfirmResponse.paymentIntent) { throw `Error requesting payment method ${JSON.stringify(afterConfirmResponse)}`; } if (isOneOffPurchase(formState.paymentOption) && responseJson.payment_intent_id) { const { url, body, method } = mapToPayRequest(form, formState, paymentProviders.STRIPE, { payment_method: paymentMethod, billing_address_provided: !!formState.billingAddress.country, payment_intent_id: responseJson.payment_intent_id, ...(hasSubscriptionMetadata ? { subscription_metadata: JSON.stringify(subscriptionMetadata) } : {}), }); return request(url, { method, bodyObject: body }, formActions).then(response => { if (response?.ok) { return; } throw response; }); } else { return request('blaize/payment/stripe/subscription/confirmation', { method: 'POST', bodyObject: { subscriptionId: responseJson.subscriptionId } }, formActions) .then(response => { if (response?.ok) { return; } throw response; }); } }); } throw JSON.stringify(responseJson); }).catch((err) => { console.error(err); // TODO throw err; }).finally(() => { formActions.decrementRequestCount(); }); }; /** * See https://stripe.com/docs/stripe-js/elements/payment-request-button */ const loadGooglePay = new Promise(function (resolve) { window.googlePayLoadStripeCallback = resolve; }); const configureStripeMobilePay = async (form, formState, formActions) => { const stripeMobilePaymentConfig = JSON.parse(form.organisationConfiguration?.stripeMobilePaymentConfig ?? "{}"); const container = document.getElementById('stripe-mobile-pay-button'); // No need to show the user any errors here just hide the button if (!stripeMobilePaymentConfig?.google && !stripeMobilePaymentConfig?.apple) { container.style.display = 'none'; console.error("Stripe Mobile payments are not configured in the console"); return; } return loadGooglePay .then(async () => await loadStripe(formActions)) .then(stripe => { formState = formActions.getFormState(); const currencyMultiplier = isZeroDecimalCurrency(formState.paymentOption.currencyCode.toUpperCase()) ? 1 : 100; const paymentLabels = { country: stripeMobilePaymentConfig.google?.countryCode ?? stripeMobilePaymentConfig.apple?.countryCode, currency: formState.paymentOption.currencyCode.toLowerCase(), total: { label: formState.paymentOption.label, amount: parseFloat((formState.paymentOptionPrices.totalPrice * currencyMultiplier).toFixed(2)), }, requestPayerName: true }; const paymentRequest = stripe.paymentRequest(paymentLabels); const elements = stripe.elements(); const paymentButton = elements.create('paymentRequestButton', { paymentRequest: paymentRequest, }); paymentRequest.canMakePayment().then(result => { if (!result || (!result.googlePay && !result.applePay)) { // Not an error - Google Pay or Apple Pay are not supported here console.warn("Cannot make mobile payments on this browser", result); container.style.display = 'none'; return; } paymentButton.mount('#stripe-mobile-pay-button'); paymentRequest.on('paymentmethod', (ev) => { void onClickPaymentButton(formState, formActions, stripe, ev, result, form); }); }); }).catch(err => { console.error(err); formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); }); }; const onClickPaymentButton = async (formState, formActions, stripe, ev, mobilePaymentType, form) => { if (mobilePaymentType.googlePay) { formActions.updateFormState({ mobilePaymentService: MobilePaymentService.GOOGLE_PAY, serverErrors: [], }); } else if (mobilePaymentType.applePay) { formActions.updateFormState({ mobilePaymentService: MobilePaymentService.APPLE_PAY, serverErrors: [], }); } if (!ev) { ev.complete('fail'); formActions.updateFormState({ serverErrors: [ServerError.MOBILE_PAYMENT_PROCESSING_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); return; } const billingAddress = ev.paymentMethod.billing_details.address; if (form.organisationConfiguration.stripeAutomaticTaxEnabled) { formState = await (calculatePrices(form, formActions.updateFormState({ billingAddress: { country: billingAddress.country, postalCode: billingAddress.postal_code, } }), formActions)); } formState = formActions.updateFormState({ paymentMethodId: ev.paymentMethod.id }); ev.complete('success'); if (formState.paymentOptionPrices.taxPrice || !formState.canAttemptSectionCompletion) { const elementId = formState.elementValidity.find((e) => !e.isValid && e.elementType != 'payment')?.elementId; const element = elementId ? document.getElementById(`zephr-form-${elementId}`) : document.getElementsByClassName('zephr-form-button')[0]; element?.scrollIntoView({ block: "center", }); } else { formActions.completeSection(); } }; const calculateBraintreeStripePrice = (form, formState, _) => { const addons = addonsForPlan(formState); const paymentOption = formConfigAs(form).paymentOptions.find(opt => opt.productId == formState.paymentOption.productId && opt.slug == formState.paymentOption.slug); const planPrice = paymentOption.price; const priceAfterPromoCode = formState.discountedPlanPrices.find(discount => discount.planSlug === formState.paymentOption.slug && discount.productId === formState.paymentOption.productId) ?.discountPrice; let finalPrice = priceAfterPromoCode ?? planPrice; let discountTotal = planPrice - finalPrice; // For Braintree only, we apply discounts on top of any promo code discounts if (form.organisationConfiguration.paymentProvider === 'braintree' && paymentOption.discounts && paymentOption.discounts.length > 0) { const totalBuiltInDiscount = paymentOption.discounts.reduce((sum, discount) => { return sum + (discount.amount || 0); }, 0); finalPrice = Math.max(0, finalPrice - totalBuiltInDiscount); discountTotal = planPrice - finalPrice; } const total = addons.reduce((total, addon) => total + addon.addonPrice, finalPrice); return Promise.resolve({ slug: formState.paymentOption.slug, productId: formState.paymentOption.productId, promoCode: formState.promoCode, addonPrices: addons, billingAddress: formState.billingAddress, totalPrice: total, totalPriceFormattedString: formatCurrency(total, formState.paymentOption.currencyCode), netPrice: planPrice, netPriceFormattedString: formatCurrency(planPrice, formState.paymentOption.currencyCode), discountPrice: discountTotal, discountPriceFormattedPrice: formatCurrency(discountTotal, formState.paymentOption.currencyCode), chargeItems: [] }); }; const getRelevantCurrency = (form, formState) => { const formConfig = formConfigAs(form); if (formConfig.dynamicOffer?.id) { return formState.paymentOption?.currencyCode; } return formConfigAs(form).formCurrency ?? formState.paymentOption?.currencyCode; }; const userAttributesValuesForPart = (partType, form, formState) => form.parts.find(p => p.type === partType) .sections.flatMap(s => s.elements) .filter(e => e.type === elementTypes.USER_ATTRIBUTE) .map(e => e.config) .reduce((current, elementConfig) => { if (formState.userAttributes) { return ({ ...current, [elementConfig.slug]: formState.userAttributes[elementConfig.slug] }); } else { return ({ ...current }); } }, {}); /** * Submit user attributes in sections that are not part of registration. */ const submitUserAttributesForPart = async (partType, form, formState, formActions) => { const attributes = userAttributesValuesForPart(partType, form, formState); if (Object.keys(attributes).length === 0) { return Promise.resolve(); } const response = await request('blaize/profile', { method: "PATCH", bodyObject: attributes }, formActions); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.INVALID_USER_ATTRIBUTES] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.INVALID_USER_ATTRIBUTES], }); throw `Error submitting user attributes ${JSON.stringify(response)}`; } return Promise.resolve(); }; const getPaymentFormNumber = (form, formState) => { const paymentConfig = formConfigAs(form); if (paymentConfig.changeSubscriptionMode) { return getChangeSubscriptionPaymentConfiguration(form, formState).paymentFormNumber; } return paymentConfig.paymentProviderFormConfig?.paymentFormNumber ?? undefined; }; const loadZuoraDynamicFormKey = async (_, formActions) => { const response = await request("zephr/public/payment/v1/billing/publishable-key", { method: "GET", }, formActions); return (await response.json())?.message; }; // Helper to cast custom field values to appropriate types const castCustomFieldValue$1 = (value, type) => { const trimmedValue = value.trim(); try { switch (type.toUpperCase()) { case 'INTEGER': { const intVal = parseInt(trimmedValue, 10); if (isNaN(intVal)) throw new Error(); return intVal; } case 'NUMBER': { const floatVal = parseFloat(trimmedValue); if (isNaN(floatVal)) throw new Error(); return floatVal; } case 'BOOLEAN': return trimmedValue.toLowerCase() === 'true'; case 'TEXT': case 'LONGTEXT': case 'PICKLIST': default: return trimmedValue.toString(); } } catch (e) { console.warn(`Error casting custom field value "${trimmedValue}" to type ${type}`); return null; } }; const createPaymentSession = async (form, formActions, context, operation) => { if (formActions.getFormState().isBusy) { console.warn('Form is busy - ignoring payment request'); return; } formActions.updateFormState({ serverErrors: [], paymentProviderFormBusy: true }); formActions.incrementRequestCount(); try { const formConfig = formConfigAs(form); const formState = formActions.getFormState(); await submitUserAttributesForPart(partTypes.PAYMENT.type, form, formState, formActions); formActions.updateFormState({ paymentAttributesSubmitted: true }); const response = await request('zephr/public/payment/v1/billing/payment-sessions', { method: "POST", bodyObject: { currency: getRelevantCurrency(form, formState) || formState.existingSubscriptions?.[0]?.currency, amount: formState.paymentOptionPrices?.totalPrice || 0.00, paymentMethodType: context?.paymentMethodType, // Only include country if it's configured and has a value ...(formConfig.countryLabel && formState.billingCountry && { country: formState.billingCountry }), // Only include state if it's configured, has a value, and country is US/CA ...(formConfig.stateLabel && formState.billingState && (formState.billingCountry === "US" || formState.billingCountry === "CA") && { state: formState.billingState }), operation: operation, ...(formState.pfToken && { pfToken: formState.pfToken }) } }, formActions); if (response.ok) { return (await response.json())?.token; } else { console.error("Error occurred while creating payment session.", response); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR], paymentProviderFormBusy: false }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); } } catch (error) { console.error("Error occurred while creating payment session.", error); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR], paymentProviderFormBusy: false }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); } }; const onComplete = async (form, formActions, result) => { const isPaymentValid = result?.paymentMethodId || result?.paymentId; if (!result?.success || !isPaymentValid) { formActions.decrementRequestCount(); console.warn('Non-success payment result', result); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR], paymentProviderFormBusy: false }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); return; } const currentFormState = formActions.getFormState(); const isPaymentMethodSetupMode = formConfigAs(form).changeSubscriptionMode && currentFormState.requiresPaymentMethodSetup === true; if (isPaymentMethodSetupMode) { formActions.updateFormState({ paymentMethodSetupComplete: true, requiresPaymentMethodSetup: false, }); } if (form.formType === FormType.LIST_SUBSCRIPTIONS || form.formType === FormType.LIST_GIFT_SUBSCRIPTIONS_SENT) { formActions.updateFormState({ paymentFormComplete: true, paymentProviderVendorFields: { detail: JSON.stringify({ creditCardCountry: result.creditCardCountry, creditCardState: result.creditCardState, refId: result.paymentMethodId, email: currentFormState.emailAddress, paymentId: result?.paymentId, paymentMethodId: result?.paymentMethodId, }), } }); } else { // Get the autoRenew value based on payment option configuration const autoRenewConfig = currentFormState.paymentOption.autoRenewConfig; let autoRenewValue; if (autoRenewConfig === 'auto_renew') { autoRenewValue = true; } else if (autoRenewConfig === 'no_auto_renew') { autoRenewValue = false; } else if (autoRenewConfig === 'custom_toggle') { // Use user's choice from the toggle const paymentOptionKey = `${currentFormState.paymentOption.productId}-${currentFormState.paymentOption.slug}`; autoRenewValue = currentFormState.paymentOptionAutoRenew?.[paymentOptionKey] ?? false; } else { // Default behavior for legacy payment options without configuration autoRenewValue = true; } // Process subscription custom fields if any const rawCustomFields = formConfigAs(form).paymentProviderFormConfig?.subscriptionCustomFields || []; const subscriptionCustomFields = {}; if (rawCustomFields?.length) { const subscriptionFormScope = await initializeSubscriptionScope(form, formActions); for (const field of rawCustomFields) { const processedTemplate = processMustacheTemplate(field.value, subscriptionFormScope) || ''; subscriptionCustomFields[field.name] = castCustomFieldValue$1(processedTemplate, field.type); } } const hasCustomFields = !!Object.keys(subscriptionCustomFields).length; formActions.updateFormState({ paymentFormComplete: true, paymentProviderVendorFields: { currency: getRelevantCurrency(form, currentFormState), detail: JSON.stringify({ creditCardCountry: result.creditCardCountry, creditCardState: result.creditCardState, refId: result.paymentMethodId, email: currentFormState.emailAddress, paymentId: result?.paymentId, paymentMethodId: result?.paymentMethodId, }), ...(currentFormState.dynamicOfferResult ? { dynamicOfferResult: JSON.stringify(currentFormState.dynamicOfferResult) } : {}), ...(currentFormState.paymentOption?.terms ? { terms: JSON.stringify({ ...currentFormState.paymentOption.terms, autoRenew: autoRenewValue }) } : {}), ...(currentFormState.paymentOption?.termsAndConditions ? { termsAndConditions: JSON.stringify({ ...currentFormState.paymentOption.termsAndConditions, autoRenew: autoRenewValue }) } : {}), ...(currentFormState.paymentOption?.triggerOffsets ? { triggerOffsets: JSON.stringify(currentFormState.paymentOption.triggerOffsets) } : {}), ...(currentFormState.paymentOption?.changeSubscriptionTriggerOffsets ? { changeSubscriptionTriggerOffsets: JSON.stringify(currentFormState.paymentOption.changeSubscriptionTriggerOffsets) } : {}), ...(hasCustomFields ? { subscriptionCustomFields: JSON.stringify(subscriptionCustomFields) } : {}) } }); } formActions.decrementRequestCount(); formActions.completeSection(); }; const loadZuoraDynamicFormUi = async (form, formState, formActions, publishableKey, operation) => { const state = formState.paymentOption && await calculatePrices(form, formState, formActions); const [locale, region] = (navigator.language ?? '').split('-'); const paymentConfig = formConfigAs(form); const requestCountry = paymentConfig?.requestCountry; const isValidCountry = requestCountry && requestCountry.toLowerCase() !== 'unknown'; const configuration = { locale: locale || "en", region: (isValidCountry ? requestCountry : region) || 'US', currency: getRelevantCurrency(form, formState) || formState.existingSubscriptions?.[0]?.currency, amount: `${state?.paymentOptionPrices?.totalPrice ?? '0.00'}`, profile: getPaymentFormNumber(form, formState), /* these flags are required for PayPal payments to work. It doesn't affect any other payment method type.*/ storePaymentMethod: false, doPayment: true, createPaymentSession: (context) => createPaymentSession(form, formActions, context, operation), onComplete: (result) => onComplete(form, formActions, result), }; // Render form const zuora = window.Zuora(publishableKey); const paymentForm = await zuora.createPaymentForm(configuration); paymentForm.mount("#zuora_payment"); formActions.updateFormState({ paymentProviderFormLoaded: true, }); }; let zuoraLoadPromise; const loadZuora = () => { if (zuoraLoadPromise != null) { return zuoraLoadPromise; } return zuoraLoadPromise = new Promise(function (resolve) { window.zuoraLoadCallback = resolve; }); }; const isDynamicForm = (form, formState) => { const paymentConfig = formConfigAs(form); if (paymentConfig.changeSubscriptionMode && formState) { return getChangeSubscriptionPaymentConfiguration(form, formState).useDynamicForm; } return paymentConfig.paymentProviderFormConfig?.useDynamicForm; }; /** * Determines the autoRenew value based on payment option configuration */ const getAutoRenewValue = (formState) => { const autoRenewConfig = formState.paymentOption.autoRenewConfig; if (autoRenewConfig === 'auto_renew') { return true; } else if (autoRenewConfig === 'no_auto_renew') { return false; } else if (autoRenewConfig === 'custom_toggle') { // Use user's choice from the toggle const paymentOptionKey = `${formState.paymentOption.productId}-${formState.paymentOption.slug}`; return formState.paymentOptionAutoRenew?.[paymentOptionKey] ?? false; } else { // Default behavior for legacy payment options without configuration return true; } }; const loadZuoraFormConfiguration = (form, formActions) => { const formState = formActions.getFormState(); if (isDynamicForm(form, formState)) { return loadZuoraDynamicFormKey(form, formActions); } // Get configuration based on form type const paymentConfig = formConfigAs(form); let hostedPageConfig; if (paymentConfig.changeSubscriptionMode) { hostedPageConfig = getChangeSubscriptionPaymentConfiguration(form, formState); } else { // Use regular payment provider configuration hostedPageConfig = paymentConfig.paymentProviderFormConfig; } if (!hostedPageConfig) { throw new Error('No hosted page configuration found for payment provider'); } return request("plugins/public/zuora-billing/payment-form-token", { method: "POST", bodyObject: { hostedPageId: hostedPageConfig.hostedPageId, hostedPageUrl: hostedPageConfig.hostedPageUrl, } }, formActions).then((response) => response.json()); }; const loadZuoraUi = (form, formState, formActions) => { // Check if we're in payment method setup mode for Change Subscription const isPaymentMethodSetupMode = formConfigAs(form).changeSubscriptionMode && formState.requiresPaymentMethodSetup === true; // Don't show card form if changing a Zuora subscription (unless in payment method setup mode) if (formConfigAs(form).changeSubscriptionMode && !isPaymentMethodSetupMode) { formActions.updateFormState({ paymentFormComplete: true, }); return; } if (form.formType === FormType.LIST_SUBSCRIPTIONS || form.formType === FormType.LIST_GIFT_SUBSCRIPTIONS_SENT || isPaymentMethodSetupMode) { void loadZuora() .then(() => loadZuoraFormConfiguration(form, formActions)) .then(formToken => { if (isDynamicForm(form, formState)) { return loadZuoraDynamicFormUi(form, formState, formActions, formToken, 2); } const formConfiguration = { tenantId: formToken.tenantId, token: formToken.token, signature: formToken.signature, key: formToken.key, id: formToken.id, url: formToken.url, style: 'inline', submitEnabled: true, }; const prePopulatedFields = { email: formState.emailAddress, }; window.Z.setEventHandler("onloadCallback", () => { formActions.updateFormState({ paymentProviderFormLoaded: true, }); }); window.Z.render(formConfiguration, prePopulatedFields, (event) => { if (event.success !== "true") { console.error("Payment failed", event); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); return; } // Handle payment method setup completion for Change Subscription forms const isPaymentMethodSetupMode = formConfigAs(form).changeSubscriptionMode && formState.requiresPaymentMethodSetup === true; if (isPaymentMethodSetupMode) { formActions.updateFormState({ paymentFormComplete: true, paymentMethodSetupComplete: true, requiresPaymentMethodSetup: false, paymentProviderVendorFields: { detail: JSON.stringify({ creditCardCountry: event.creditCardCountry, creditCardState: event.creditCardState, refId: event.refId, email: event.email, }), } }); } else { formActions.updateFormState({ paymentFormComplete: true, paymentProviderVendorFields: { detail: JSON.stringify({ creditCardCountry: event.creditCardCountry, creditCardState: event.creditCardState, refId: event.refId, email: event.email, }), } }); } formActions.completeSection(); }); }); } else { void loadZuora() .then(() => loadZuoraFormConfiguration(form, formActions)) .then(formToken => { if (!getRelevantCurrency(form, formState)) { formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); console.error("Form currency not set"); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); return; } if (isDynamicForm(form, formState)) { return loadZuoraDynamicFormUi(form, formState, formActions, formToken, 1); } const formConfiguration = { tenantId: formToken.tenantId, token: formToken.token, signature: formToken.signature, key: formToken.key, id: formToken.id, url: formToken.url, style: 'inline', submitEnabled: true, }; const prePopulatedFields = { email: formState.emailAddress, }; window.Z.setEventHandler("onloadCallback", () => { formActions.updateFormState({ paymentProviderFormLoaded: true, }); }); window.Z.render(formConfiguration, prePopulatedFields, (event) => { if (event.success !== "true") { console.error("Payment failed", event); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); return; } const currentFormState = formActions.getFormState(); const autoRenewValue = getAutoRenewValue(currentFormState); formActions.updateFormState({ paymentFormComplete: true, paymentProviderVendorFields: { currency: getRelevantCurrency(form, currentFormState), detail: JSON.stringify({ creditCardCountry: event.creditCardCountry, creditCardState: event.creditCardState, refId: event.refId, email: event.email, }), ...(currentFormState.dynamicOfferResult ? { dynamicOfferResult: JSON.stringify(currentFormState.dynamicOfferResult) } : {}), ...(currentFormState.paymentOption?.terms ? { terms: JSON.stringify({ ...currentFormState.paymentOption.terms, autoRenew: autoRenewValue }) } : {}), ...(currentFormState.paymentOption?.termsAndConditions ? { termsAndConditions: JSON.stringify({ ...currentFormState.paymentOption.termsAndConditions, autoRenew: autoRenewValue }) } : {}), ...(currentFormState.paymentOption?.triggerOffsets ? { triggerOffsets: JSON.stringify(currentFormState.paymentOption.triggerOffsets) } : {}), ...(currentFormState.paymentOption?.changeSubscriptionTriggerOffsets ? { changeSubscriptionTriggerOffsets: JSON.stringify(currentFormState.paymentOption.changeSubscriptionTriggerOffsets) } : {}), } }); formActions.completeSection(); }); }); } }; // TODO: Remove the ability to add MULTISELECT fields in the Console (Filter it out from the listBillingCustomFields endpoint) const castCustomFieldValue = (value, type) => { const trimmedValue = value.trim(); try { switch (type.toUpperCase()) { case 'INTEGER': { const intVal = parseInt(trimmedValue, 10); if (isNaN(intVal)) throw new Error(); return intVal; } case 'NUMBER': { const floatVal = parseFloat(trimmedValue); if (isNaN(floatVal)) throw new Error(); return floatVal; } case 'BOOLEAN': return trimmedValue.toLowerCase() === 'true'; case 'TEXT': case 'LONGTEXT': case 'PICKLIST': default: return trimmedValue.toString(); } } catch (e) { console.warn(`Error casting custom field value "${trimmedValue}" to type ${type}`); return null; } }; const zuoraComplete = async (form, formState, formActions) => { const isChangeSubscriptionMode = formConfigAs(form).changeSubscriptionMode; formActions.incrementRequestCount(); try { if (!isChangeSubscriptionMode && !formState.paymentProviderVendorFields) { console.error("Flow error - no Zuora vendor fields found"); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PAYMENT_PROCESSING_ERROR], }); return Promise.resolve(); } const rawCustomFields = formConfigAs(form).paymentProviderFormConfig?.subscriptionCustomFields || []; const subscriptionCustomFields = {}; if (rawCustomFields?.length) { const subscriptionFormScope = await initializeSubscriptionScope(form, formActions); for (const field of rawCustomFields) { const processedTemplate = processMustacheTemplate(field.value, subscriptionFormScope) || ''; subscriptionCustomFields[field.name] = castCustomFieldValue(processedTemplate, field.type); } } const hasCustomFields = !!Object.keys(subscriptionCustomFields).length; // For changeSubscriptionMode, create vendor fields from termsAndConditions let vendorFields; if (isChangeSubscriptionMode && formState.paymentOption?.termsAndConditions) { const autoRenewValue = getAutoRenewValue(formState); const changingFromSubscription = formState .validChangeFromPlans .find(plan => formState.paymentOption.slug === plan.planSlug && formState.paymentOption.productId === plan.productId) ?.changesFromSubscription; vendorFields = { currency: formState.paymentOption.currencyCode, detail: JSON.stringify({ refId: changingFromSubscription?.externalId || '', email: formState.emailAddress || '' }), termsAndConditions: JSON.stringify({ ...formState.paymentOption.termsAndConditions, autoRenew: autoRenewValue }), ...(hasCustomFields ? { subscriptionCustomFields: JSON.stringify(subscriptionCustomFields) } : {}) }; } else if (formState.convertCancelSubscriptionToAcceptOffer) { const changingFromSubscription = formState .validChangeFromPlans .find(plan => formState.paymentOption.slug === plan.planSlug && formState.paymentOption.productId === plan.productId) ?.changesFromSubscription; vendorFields = { currency: formState.paymentOption.currencyCode, detail: JSON.stringify({ refId: changingFromSubscription?.externalId || '', email: formState.emailAddress || '' }), ...(hasCustomFields ? { subscriptionCustomFields: JSON.stringify(subscriptionCustomFields) } : {}) }; } else { vendorFields = { ...formState.paymentProviderVendorFields, ...(hasCustomFields ? { subscriptionCustomFields: JSON.stringify(subscriptionCustomFields) } : {}) }; } const { url, body, method } = mapToPayRequest(form, formState, paymentProviders.ZUORA, vendorFields); if (form.formType === FormType.GIFT_SUBSCRIPTION) { // Check if any recipient address fields have values const recipientAddress = formState.giftRecipient?.recipientAddress || {}; const hasAnyAddressValue = recipientAddress.addressLine1?.trim() || recipientAddress.addressLine2?.trim() || recipientAddress.city?.trim() || recipientAddress.state?.trim() || recipientAddress.country?.trim() || recipientAddress.postalCode?.trim(); const giftBody = { ...body, // Includes attributes mapped by mapToPayRequest plan_id: `zuora-billing_product_rate_plan-${body.plan_id}-unused`, discount_code: formState.promoCodeValid ? formState.promoCode : undefined, vendor_fields: { ...(body.vendor_fields || {}), // Only include giftDetails if isGiftForm is true (defaults to true if no gift toggle elements are present) ...(formState.isGiftForm ? { giftDetails: JSON.stringify({ recipient_email: formState.giftRecipient.email, firstName: formState.giftRecipient.firstName, lastName: formState.giftRecipient.lastName, message: formState.giftRecipient.customMessage, ...(hasAnyAddressValue ? { recipient_address: { addressLine1: recipientAddress.addressLine1 || '', addressLine2: recipientAddress.addressLine2 || '', city: recipientAddress.city || '', state: recipientAddress.state || '', country: recipientAddress.country || '', postalCode: recipientAddress.postalCode || '', } } : {}), ...(formState.giftRecipient.futureDeliveryEnabled && formState.giftRecipient.futureDeliveryDate ? { startDate: formState.giftRecipient.futureDeliveryDate } : {}) }) } : {}) } }; const giftResponse = await request('zephr/subscribe', { method: 'POST', bodyObject: { ...giftBody, ...(formState.pfToken ? { pf_token: formState.pfToken } : {}) } }, formActions); if (!giftResponse?.ok) { console.error("Error creating gift subscription", giftResponse); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); return Promise.reject(); } return Promise.resolve(); } else { // Regular flow for non-gift subscriptions const modifiedBody = formConfigAs(form).changeSubscriptionMode ? body : { ...body, // eslint-disable-next-line @typescript-eslint/restrict-template-expressions plan_id: `zuora-billing_product_rate_plan-${body.plan_id}-unused`, }; return await request(url, { method, bodyObject: { ...modifiedBody, ...(url === 'zephr/subscribe' && formState.pfToken ? { pf_token: formState.pfToken } : {}) } }, formActions).then(response => { if (!response?.ok) { void response.json().then(json => { console.error("Error when subscribing", json); }); return Promise.reject(); } }); } } finally { formActions.decrementRequestCount(); formActions.updateFormState({ paymentProviderFormBusy: false }); } }; const zuoraChangePayment = (form, formState, formActions) => { console.log(formState.paymentProviderVendorFields); const paymentMethodId = JSON.parse(formState.paymentProviderVendorFields?.detail).refId; return request('plugins/public/zuora-billing/update-account', { method: 'POST', bodyObject: { paymentMethodId, } }, formActions).then(response => { if (!response?.ok) { console.error("Error when changing default payment method", response); return Promise.reject(); } }); }; const getDynamicOffer = async (form, formActions) => { const dynamicOfferId = formConfigAs(form).dynamicOffer?.id; const dynamicOfferPreview = formConfigAs(form).dynamicOfferPreview; if (form.environment.previewMode) { formActions.updateFormState({ dynamicOfferResult: dynamicOfferPreview }); return; } let session; let jwt; try { session = document.cookie.match(/blaize_session=[0-9a-z-]+/)[0].substring(15); } catch { session = null; } try { jwt = document.cookie.match(/(? { const chargeOne = dynamicOfferResult?.products ? dynamicOfferResult.products[0].paymentPlans[0].charges[0] : { prices: [{ price: 25 }], chargeData: { name: 'Monthly Fee' } }; const amount = chargeOne.prices[0]?.price; const chargeName = chargeOne.chargeData?.name; return { "success": true, "contractedMrr": amount, "totalContractedValue": null, "amount": amount + 3, "amountWithoutTax": amount, "taxAmount": 3, "invoiceTargetDate": "2024-05-20", "documentDate": "2024-05-20", "invoiceItems": { "0": { "serviceStartDate": "2024-05-20", "serviceEndDate": "2024-06-19", "chargeAmount": amount, "taxAmount": 3, "chargeDescription": "", "chargeName": chargeName, "productName": "Product", "productRatePlanChargeId": "8ad097b48f533234018f57a8982a5a45", "quantity": 1, "unitOfMeasure": "" } } }; }; const filterChangeSubDynamicOfferResponse = (dynamicOfferResult, form, formState) => { if (!formConfigAs(form).changeSubscriptionMode || form.environment.previewMode) { return dynamicOfferResult; } return { ...dynamicOfferResult, products: dynamicOfferResult.products.map(product => ({ ...product, paymentPlans: product.paymentPlans.filter(plan => formState .validChangeFromPlans .some(changeFromPlan => changeFromPlan.planSlug === plan.planId && changeFromPlan.productId === product.id)) })) }; }; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r = 0) continue; target[key] = source[key]; } return target; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i = 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } var countries$1 = { AD: "Andorra", AE: "United Arab Emirates", AF: "Afghanistan", AG: "Antigua and Barbuda", AI: "Anguilla", AL: "Albania", AM: "Armenia", AO: "Angola", AQ: "Antarctica", AR: "Argentina", AS: "American Samoa", AT: "Austria", AU: "Australia", AW: "Aruba", AX: "Åland Islands", AZ: "Azerbaijan", BA: "Bosnia and Herzegovina", BB: "Barbados", BD: "Bangladesh", BE: "Belgium", BF: "Burkina Faso", BG: "Bulgaria", BH: "Bahrain", BI: "Burundi", BJ: "Benin", BL: "Saint Barthélemy", BM: "Bermuda", BN: "Brunei", BO: "Bolivia", BQ: "Caribbean Netherlands", BR: "Brazil", BS: "Bahamas", BT: "Bhutan", BW: "Botswana", BY: "Belarus", BZ: "Belize", CA: "Canada", CC: "Cocos Islands", CD: "Democratic Republic of the Congo", CF: "Central African Republic", CG: "Republic of the Congo", CH: "Switzerland", CI: "Ivory Coast", CK: "Cook Islands", CL: "Chile", CM: "Cameroon", CN: "China", CO: "Colombia", CR: "Costa Rica", CU: "Cuba", CV: "Cabo Verde", CW: "Curaçao", CX: "Christmas Island", CY: "Cyprus", CZ: "Czechia", DE: "Germany", DJ: "Djibouti", DK: "Denmark", DM: "Dominica", DO: "Dominican Republic", DZ: "Algeria", EC: "Ecuador", EE: "Estonia", EG: "Egypt", EH: "Western Sahara", ER: "Eritrea", ES: "Spain", ET: "Ethiopia", FI: "Finland", FJ: "Fiji", FK: "Falkland Islands", FM: "Micronesia", FO: "Faroe Islands", FR: "France", GA: "Gabon", GB: "United Kingdom", GD: "Grenada", GE: "Georgia", GF: "French Guiana", GG: "Guernsey", GH: "Ghana", GI: "Gibraltar", GL: "Greenland", GM: "Gambia", GN: "Guinea", GP: "Guadeloupe", GQ: "Equatorial Guinea", GR: "Greece", GS: "South Georgia and the South Sandwich Islands", GT: "Guatemala", GU: "Guam", GW: "Guinea-Bissau", GY: "Guyana", HK: "Hong Kong", HN: "Honduras", HR: "Croatia", HT: "Haiti", HU: "Hungary", ID: "Indonesia", IE: "Ireland", IL: "Israel", IM: "Isle of Man", IN: "India", IO: "British Indian Ocean Territory", IQ: "Iraq", IR: "Iran", IS: "Iceland", IT: "Italy", JE: "Jersey", JM: "Jamaica", JO: "Jordan", JP: "Japan", KE: "Kenya", KG: "Kyrgyzstan", KH: "Cambodia", KI: "Kiribati", KM: "Comoros", KN: "Saint Kitts and Nevis", KP: "North Korea", KR: "South Korea", KW: "Kuwait", KY: "Cayman Islands", KZ: "Kazakhstan", LA: "Laos", LB: "Lebanon", LC: "Saint Lucia", LI: "Liechtenstein", LK: "Sri Lanka", LR: "Liberia", LS: "Lesotho", LT: "Lithuania", LU: "Luxembourg", LV: "Latvia", LY: "Libya", MA: "Morocco", MC: "Monaco", MD: "Moldova", ME: "Montenegro", MF: "Saint Martin", MG: "Madagascar", MH: "Marshall Islands", MK: "North Macedonia", ML: "Mali", MM: "Myanmar", MN: "Mongolia", MO: "Macao", MP: "Northern Mariana Islands", MQ: "Martinique", MR: "Mauritania", MS: "Montserrat", MT: "Malta", MU: "Mauritius", MV: "Maldives", MW: "Malawi", MX: "Mexico", MY: "Malaysia", MZ: "Mozambique", NA: "Namibia", NC: "New Caledonia", NE: "Niger", NF: "Norfolk Island", NG: "Nigeria", NI: "Nicaragua", NL: "Netherlands", NO: "Norway", NP: "Nepal", NR: "Nauru", NU: "Niue", NZ: "New Zealand", OM: "Oman", PA: "Panama", PE: "Peru", PF: "French Polynesia", PG: "Papua New Guinea", PH: "Philippines", PK: "Pakistan", PL: "Poland", PM: "Saint Pierre and Miquelon", PN: "Pitcairn", PR: "Puerto Rico", PS: "Palestine", PT: "Portugal", PW: "Palau", PY: "Paraguay", QA: "Qatar", RE: "Réunion", RO: "Romania", RS: "Serbia", RU: "Russia", RW: "Rwanda", SA: "Saudi Arabia", SB: "Solomon Islands", SC: "Seychelles", SD: "Sudan", SE: "Sweden", SG: "Singapore", SH: "Saint Helena, Ascension and Tristan da Cunha", SI: "Slovenia", SJ: "Svalbard and Jan Mayen", SK: "Slovakia", SL: "Sierra Leone", SM: "San Marino", SN: "Senegal", SO: "Somalia", SR: "Suriname", SS: "South Sudan", ST: "Sao Tome and Principe", SV: "El Salvador", SX: "Sint Maarten", SY: "Syria", SZ: "Eswatini", TC: "Turks and Caicos Islands", TD: "Chad", TF: "French Southern Territories", TG: "Togo", TH: "Thailand", TJ: "Tajikistan", TK: "Tokelau", TL: "Timor-Leste", TM: "Turkmenistan", TN: "Tunisia", TO: "Tonga", TR: "Türkiye", TT: "Trinidad and Tobago", TV: "Tuvalu", TW: "Taiwan", TZ: "Tanzania", UA: "Ukraine", UG: "Uganda", UM: "United States Minor Outlying Islands", US: "United States of America", UY: "Uruguay", UZ: "Uzbekistan", VA: "Holy See", VC: "Saint Vincent and the Grenadines", VE: "Venezuela", VG: "Virgin Islands (UK)", VI: "Virgin Islands (US)", VN: "Vietnam", VU: "Vanuatu", WF: "Wallis and Futuna", WS: "Samoa", YE: "Yemen", YT: "Mayotte", ZA: "South Africa", ZM: "Zambia", ZW: "Zimbabwe" }; var timezones$1 = { "Africa/Abidjan": { u: 0, c: [ "CI", "BF", "GH", "GM", "GN", "IS", "ML", "MR", "SH", "SL", "SN", "TG" ] }, "Africa/Accra": { a: "Africa/Abidjan", c: [ "GH" ], r: 1 }, "Africa/Addis_Ababa": { a: "Africa/Nairobi", c: [ "ET" ], r: 1 }, "Africa/Algiers": { u: 60, c: [ "DZ" ] }, "Africa/Asmara": { a: "Africa/Nairobi", c: [ "ER" ], r: 1 }, "Africa/Asmera": { a: "Africa/Nairobi", c: [ "ER" ], r: 1 }, "Africa/Bamako": { a: "Africa/Abidjan", c: [ "ML" ], r: 1 }, "Africa/Bangui": { a: "Africa/Lagos", c: [ "CF" ], r: 1 }, "Africa/Banjul": { a: "Africa/Abidjan", c: [ "GM" ], r: 1 }, "Africa/Bissau": { u: 0, c: [ "GW" ] }, "Africa/Blantyre": { a: "Africa/Maputo", c: [ "MW" ], r: 1 }, "Africa/Brazzaville": { a: "Africa/Lagos", c: [ "CG" ], r: 1 }, "Africa/Bujumbura": { a: "Africa/Maputo", c: [ "BI" ], r: 1 }, "Africa/Cairo": { u: 120, d: 180, c: [ "EG" ] }, "Africa/Casablanca": { u: 60, d: 0, c: [ "MA" ] }, "Africa/Ceuta": { u: 60, d: 120, c: [ "ES" ] }, "Africa/Conakry": { a: "Africa/Abidjan", c: [ "GN" ], r: 1 }, "Africa/Dakar": { a: "Africa/Abidjan", c: [ "SN" ], r: 1 }, "Africa/Dar_es_Salaam": { a: "Africa/Nairobi", c: [ "TZ" ], r: 1 }, "Africa/Djibouti": { a: "Africa/Nairobi", c: [ "DJ" ], r: 1 }, "Africa/Douala": { a: "Africa/Lagos", c: [ "CM" ], r: 1 }, "Africa/El_Aaiun": { u: 60, d: 0, c: [ "EH" ] }, "Africa/Freetown": { a: "Africa/Abidjan", c: [ "SL" ], r: 1 }, "Africa/Gaborone": { a: "Africa/Maputo", c: [ "BW" ], r: 1 }, "Africa/Harare": { a: "Africa/Maputo", c: [ "ZW" ], r: 1 }, "Africa/Johannesburg": { u: 120, c: [ "ZA", "LS", "SZ" ] }, "Africa/Juba": { u: 120, c: [ "SS" ] }, "Africa/Kampala": { a: "Africa/Nairobi", c: [ "UG" ], r: 1 }, "Africa/Khartoum": { u: 120, c: [ "SD" ] }, "Africa/Kigali": { a: "Africa/Maputo", c: [ "RW" ], r: 1 }, "Africa/Kinshasa": { a: "Africa/Lagos", c: [ "CD" ], r: 1 }, "Africa/Lagos": { u: 60, c: [ "NG", "AO", "BJ", "CD", "CF", "CG", "CM", "GA", "GQ", "NE" ] }, "Africa/Libreville": { a: "Africa/Lagos", c: [ "GA" ], r: 1 }, "Africa/Lome": { a: "Africa/Abidjan", c: [ "TG" ], r: 1 }, "Africa/Luanda": { a: "Africa/Lagos", c: [ "AO" ], r: 1 }, "Africa/Lubumbashi": { a: "Africa/Maputo", c: [ "CD" ], r: 1 }, "Africa/Lusaka": { a: "Africa/Maputo", c: [ "ZM" ], r: 1 }, "Africa/Malabo": { a: "Africa/Lagos", c: [ "GQ" ], r: 1 }, "Africa/Maputo": { u: 120, c: [ "MZ", "BI", "BW", "CD", "MW", "RW", "ZM", "ZW" ] }, "Africa/Maseru": { a: "Africa/Johannesburg", c: [ "LS" ], r: 1 }, "Africa/Mbabane": { a: "Africa/Johannesburg", c: [ "SZ" ], r: 1 }, "Africa/Mogadishu": { a: "Africa/Nairobi", c: [ "SO" ], r: 1 }, "Africa/Monrovia": { u: 0, c: [ "LR" ] }, "Africa/Nairobi": { u: 180, c: [ "KE", "DJ", "ER", "ET", "KM", "MG", "SO", "TZ", "UG", "YT" ] }, "Africa/Ndjamena": { u: 60, c: [ "TD" ] }, "Africa/Niamey": { a: "Africa/Lagos", c: [ "NE" ], r: 1 }, "Africa/Nouakchott": { a: "Africa/Abidjan", c: [ "MR" ], r: 1 }, "Africa/Ouagadougou": { a: "Africa/Abidjan", c: [ "BF" ], r: 1 }, "Africa/Porto-Novo": { a: "Africa/Lagos", c: [ "BJ" ], r: 1 }, "Africa/Sao_Tome": { u: 0, c: [ "ST" ] }, "Africa/Timbuktu": { a: "Africa/Abidjan", c: [ "ML" ], r: 1 }, "Africa/Tripoli": { u: 120, c: [ "LY" ] }, "Africa/Tunis": { u: 60, c: [ "TN" ] }, "Africa/Windhoek": { u: 120, c: [ "NA" ] }, "America/Adak": { u: -600, d: -540, c: [ "US" ] }, "America/Anchorage": { u: -540, d: -480, c: [ "US" ] }, "America/Anguilla": { a: "America/Puerto_Rico", c: [ "AI" ], r: 1 }, "America/Antigua": { a: "America/Puerto_Rico", c: [ "AG" ], r: 1 }, "America/Araguaina": { u: -180, c: [ "BR" ] }, "America/Argentina/Buenos_Aires": { u: -180, c: [ "AR" ] }, "America/Argentina/Catamarca": { u: -180, c: [ "AR" ] }, "America/Argentina/ComodRivadavia": { a: "America/Argentina/Catamarca", r: 1 }, "America/Argentina/Cordoba": { u: -180, c: [ "AR" ] }, "America/Argentina/Jujuy": { u: -180, c: [ "AR" ] }, "America/Argentina/La_Rioja": { u: -180, c: [ "AR" ] }, "America/Argentina/Mendoza": { u: -180, c: [ "AR" ] }, "America/Argentina/Rio_Gallegos": { u: -180, c: [ "AR" ] }, "America/Argentina/Salta": { u: -180, c: [ "AR" ] }, "America/Argentina/San_Juan": { u: -180, c: [ "AR" ] }, "America/Argentina/San_Luis": { u: -180, c: [ "AR" ] }, "America/Argentina/Tucuman": { u: -180, c: [ "AR" ] }, "America/Argentina/Ushuaia": { u: -180, c: [ "AR" ] }, "America/Aruba": { a: "America/Puerto_Rico", c: [ "AW" ], r: 1 }, "America/Asuncion": { u: -240, d: -180, c: [ "PY" ] }, "America/Atikokan": { a: "America/Panama", c: [ "CA" ], r: 1 }, "America/Atka": { a: "America/Adak", r: 1 }, "America/Bahia": { u: -180, c: [ "BR" ] }, "America/Bahia_Banderas": { u: -360, c: [ "MX" ] }, "America/Barbados": { u: -240, c: [ "BB" ] }, "America/Belem": { u: -180, c: [ "BR" ] }, "America/Belize": { u: -360, c: [ "BZ" ] }, "America/Blanc-Sablon": { a: "America/Puerto_Rico", c: [ "CA" ], r: 1 }, "America/Boa_Vista": { u: -240, c: [ "BR" ] }, "America/Bogota": { u: -300, c: [ "CO" ] }, "America/Boise": { u: -420, d: -360, c: [ "US" ] }, "America/Buenos_Aires": { a: "America/Argentina/Buenos_Aires", r: 1 }, "America/Cambridge_Bay": { u: -420, d: -360, c: [ "CA" ] }, "America/Campo_Grande": { u: -240, c: [ "BR" ] }, "America/Cancun": { u: -300, c: [ "MX" ] }, "America/Caracas": { u: -240, c: [ "VE" ] }, "America/Catamarca": { a: "America/Argentina/Catamarca", r: 1 }, "America/Cayenne": { u: -180, c: [ "GF" ] }, "America/Cayman": { a: "America/Panama", c: [ "KY" ], r: 1 }, "America/Chicago": { u: -360, d: -300, c: [ "US" ] }, "America/Chihuahua": { u: -360, c: [ "MX" ] }, "America/Ciudad_Juarez": { u: -420, d: -360, c: [ "MX" ] }, "America/Coral_Harbour": { a: "America/Panama", c: [ "CA" ], r: 1 }, "America/Cordoba": { a: "America/Argentina/Cordoba", r: 1 }, "America/Costa_Rica": { u: -360, c: [ "CR" ] }, "America/Creston": { a: "America/Phoenix", c: [ "CA" ], r: 1 }, "America/Cuiaba": { u: -240, c: [ "BR" ] }, "America/Curacao": { a: "America/Puerto_Rico", c: [ "CW" ], r: 1 }, "America/Danmarkshavn": { u: 0, c: [ "GL" ] }, "America/Dawson": { u: -420, c: [ "CA" ] }, "America/Dawson_Creek": { u: -420, c: [ "CA" ] }, "America/Denver": { u: -420, d: -360, c: [ "US" ] }, "America/Detroit": { u: -300, d: -240, c: [ "US" ] }, "America/Dominica": { a: "America/Puerto_Rico", c: [ "DM" ], r: 1 }, "America/Edmonton": { u: -420, d: -360, c: [ "CA" ] }, "America/Eirunepe": { u: -300, c: [ "BR" ] }, "America/El_Salvador": { u: -360, c: [ "SV" ] }, "America/Ensenada": { a: "America/Tijuana", r: 1 }, "America/Fort_Nelson": { u: -420, c: [ "CA" ] }, "America/Fort_Wayne": { a: "America/Indiana/Indianapolis", r: 1 }, "America/Fortaleza": { u: -180, c: [ "BR" ] }, "America/Glace_Bay": { u: -240, d: -180, c: [ "CA" ] }, "America/Godthab": { a: "America/Nuuk", r: 1 }, "America/Goose_Bay": { u: -240, d: -180, c: [ "CA" ] }, "America/Grand_Turk": { u: -300, d: -240, c: [ "TC" ] }, "America/Grenada": { a: "America/Puerto_Rico", c: [ "GD" ], r: 1 }, "America/Guadeloupe": { a: "America/Puerto_Rico", c: [ "GP" ], r: 1 }, "America/Guatemala": { u: -360, c: [ "GT" ] }, "America/Guayaquil": { u: -300, c: [ "EC" ] }, "America/Guyana": { u: -240, c: [ "GY" ] }, "America/Halifax": { u: -240, d: -180, c: [ "CA" ] }, "America/Havana": { u: -300, d: -240, c: [ "CU" ] }, "America/Hermosillo": { u: -420, c: [ "MX" ] }, "America/Indiana/Indianapolis": { u: -300, d: -240, c: [ "US" ] }, "America/Indiana/Knox": { u: -360, d: -300, c: [ "US" ] }, "America/Indiana/Marengo": { u: -300, d: -240, c: [ "US" ] }, "America/Indiana/Petersburg": { u: -300, d: -240, c: [ "US" ] }, "America/Indiana/Tell_City": { u: -360, d: -300, c: [ "US" ] }, "America/Indiana/Vevay": { u: -300, d: -240, c: [ "US" ] }, "America/Indiana/Vincennes": { u: -300, d: -240, c: [ "US" ] }, "America/Indiana/Winamac": { u: -300, d: -240, c: [ "US" ] }, "America/Indianapolis": { a: "America/Indiana/Indianapolis", r: 1 }, "America/Inuvik": { u: -420, d: -360, c: [ "CA" ] }, "America/Iqaluit": { u: -300, d: -240, c: [ "CA" ] }, "America/Jamaica": { u: -300, c: [ "JM" ] }, "America/Jujuy": { a: "America/Argentina/Jujuy", r: 1 }, "America/Juneau": { u: -540, d: -480, c: [ "US" ] }, "America/Kentucky/Louisville": { u: -300, d: -240, c: [ "US" ] }, "America/Kentucky/Monticello": { u: -300, d: -240, c: [ "US" ] }, "America/Knox_IN": { a: "America/Indiana/Knox", r: 1 }, "America/Kralendijk": { a: "America/Puerto_Rico", c: [ "BQ" ], r: 1 }, "America/La_Paz": { u: -240, c: [ "BO" ] }, "America/Lima": { u: -300, c: [ "PE" ] }, "America/Los_Angeles": { u: -480, d: -420, c: [ "US" ] }, "America/Louisville": { a: "America/Kentucky/Louisville", r: 1 }, "America/Lower_Princes": { a: "America/Puerto_Rico", c: [ "SX" ], r: 1 }, "America/Maceio": { u: -180, c: [ "BR" ] }, "America/Managua": { u: -360, c: [ "NI" ] }, "America/Manaus": { u: -240, c: [ "BR" ] }, "America/Marigot": { a: "America/Puerto_Rico", c: [ "MF" ], r: 1 }, "America/Martinique": { u: -240, c: [ "MQ" ] }, "America/Matamoros": { u: -360, d: -300, c: [ "MX" ] }, "America/Mazatlan": { u: -420, c: [ "MX" ] }, "America/Mendoza": { a: "America/Argentina/Mendoza", r: 1 }, "America/Menominee": { u: -360, d: -300, c: [ "US" ] }, "America/Merida": { u: -360, c: [ "MX" ] }, "America/Metlakatla": { u: -540, d: -480, c: [ "US" ] }, "America/Mexico_City": { u: -360, c: [ "MX" ] }, "America/Miquelon": { u: -180, d: -120, c: [ "PM" ] }, "America/Moncton": { u: -240, d: -180, c: [ "CA" ] }, "America/Monterrey": { u: -360, c: [ "MX" ] }, "America/Montevideo": { u: -180, c: [ "UY" ] }, "America/Montreal": { a: "America/Toronto", c: [ "CA" ], r: 1 }, "America/Montserrat": { a: "America/Puerto_Rico", c: [ "MS" ], r: 1 }, "America/Nassau": { a: "America/Toronto", c: [ "BS" ], r: 1 }, "America/New_York": { u: -300, d: -240, c: [ "US" ] }, "America/Nipigon": { a: "America/Toronto", c: [ "CA" ], r: 1 }, "America/Nome": { u: -540, d: -480, c: [ "US" ] }, "America/Noronha": { u: -120, c: [ "BR" ] }, "America/North_Dakota/Beulah": { u: -360, d: -300, c: [ "US" ] }, "America/North_Dakota/Center": { u: -360, d: -300, c: [ "US" ] }, "America/North_Dakota/New_Salem": { u: -360, d: -300, c: [ "US" ] }, "America/Nuuk": { u: -120, d: -60, c: [ "GL" ] }, "America/Ojinaga": { u: -360, d: -300, c: [ "MX" ] }, "America/Panama": { u: -300, c: [ "PA", "CA", "KY" ] }, "America/Pangnirtung": { a: "America/Iqaluit", r: 1 }, "America/Paramaribo": { u: -180, c: [ "SR" ] }, "America/Phoenix": { u: -420, c: [ "US", "CA" ] }, "America/Port-au-Prince": { u: -300, d: -240, c: [ "HT" ] }, "America/Port_of_Spain": { a: "America/Puerto_Rico", c: [ "TT" ], r: 1 }, "America/Porto_Acre": { a: "America/Rio_Branco", r: 1 }, "America/Porto_Velho": { u: -240, c: [ "BR" ] }, "America/Puerto_Rico": { u: -240, c: [ "PR", "AG", "CA", "AI", "AW", "BL", "BQ", "CW", "DM", "GD", "GP", "KN", "LC", "MF", "MS", "SX", "TT", "VC", "VG", "VI" ] }, "America/Punta_Arenas": { u: -180, c: [ "CL" ] }, "America/Rainy_River": { a: "America/Winnipeg", r: 1 }, "America/Rankin_Inlet": { u: -360, d: -300, c: [ "CA" ] }, "America/Recife": { u: -180, c: [ "BR" ] }, "America/Regina": { u: -360, c: [ "CA" ] }, "America/Resolute": { u: -360, d: -300, c: [ "CA" ] }, "America/Rio_Branco": { u: -300, c: [ "BR" ] }, "America/Rosario": { a: "America/Argentina/Cordoba", r: 1 }, "America/Santa_Isabel": { a: "America/Tijuana", r: 1 }, "America/Santarem": { u: -180, c: [ "BR" ] }, "America/Santiago": { u: -240, d: -180, c: [ "CL" ] }, "America/Santo_Domingo": { u: -240, c: [ "DO" ] }, "America/Sao_Paulo": { u: -180, c: [ "BR" ] }, "America/Scoresbysund": { u: -60, d: 0, c: [ "GL" ] }, "America/Shiprock": { a: "America/Denver", r: 1 }, "America/Sitka": { u: -540, d: -480, c: [ "US" ] }, "America/St_Barthelemy": { a: "America/Puerto_Rico", c: [ "BL" ], r: 1 }, "America/St_Johns": { u: -210, d: -150, c: [ "CA" ] }, "America/St_Kitts": { a: "America/Puerto_Rico", c: [ "KN" ], r: 1 }, "America/St_Lucia": { a: "America/Puerto_Rico", c: [ "LC" ], r: 1 }, "America/St_Thomas": { a: "America/Puerto_Rico", c: [ "VI" ], r: 1 }, "America/St_Vincent": { a: "America/Puerto_Rico", c: [ "VC" ], r: 1 }, "America/Swift_Current": { u: -360, c: [ "CA" ] }, "America/Tegucigalpa": { u: -360, c: [ "HN" ] }, "America/Thule": { u: -240, d: -180, c: [ "GL" ] }, "America/Thunder_Bay": { a: "America/Toronto", c: [ "CA" ], r: 1 }, "America/Tijuana": { u: -480, d: -420, c: [ "MX" ] }, "America/Toronto": { u: -300, d: -240, c: [ "CA", "BS" ] }, "America/Tortola": { a: "America/Puerto_Rico", c: [ "VG" ], r: 1 }, "America/Vancouver": { u: -480, d: -420, c: [ "CA" ] }, "America/Virgin": { a: "America/Puerto_Rico", c: [ "VI" ], r: 1 }, "America/Whitehorse": { u: -420, c: [ "CA" ] }, "America/Winnipeg": { u: -360, d: -300, c: [ "CA" ] }, "America/Yakutat": { u: -540, d: -480, c: [ "US" ] }, "America/Yellowknife": { a: "America/Edmonton", r: 1 }, "Antarctica/Casey": { u: 660, c: [ "AQ" ] }, "Antarctica/Davis": { u: 420, c: [ "AQ" ] }, "Antarctica/DumontDUrville": { a: "Pacific/Port_Moresby", c: [ "AQ" ], r: 1 }, "Antarctica/Macquarie": { u: 600, d: 660, c: [ "AU" ] }, "Antarctica/Mawson": { u: 300, c: [ "AQ" ] }, "Antarctica/McMurdo": { a: "Pacific/Auckland", c: [ "AQ" ], r: 1 }, "Antarctica/Palmer": { u: -180, c: [ "AQ" ] }, "Antarctica/Rothera": { u: -180, c: [ "AQ" ] }, "Antarctica/South_Pole": { a: "Pacific/Auckland", c: [ "AQ" ], r: 1 }, "Antarctica/Syowa": { a: "Asia/Riyadh", c: [ "AQ" ], r: 1 }, "Antarctica/Troll": { u: 0, d: 120, c: [ "AQ" ] }, "Antarctica/Vostok": { a: "Asia/Urumqi", c: [ "AQ" ], r: 1 }, "Arctic/Longyearbyen": { a: "Europe/Berlin", c: [ "SJ" ], r: 1 }, "Asia/Aden": { a: "Asia/Riyadh", c: [ "YE" ], r: 1 }, "Asia/Almaty": { u: 360, c: [ "KZ" ] }, "Asia/Amman": { u: 180, c: [ "JO" ] }, "Asia/Anadyr": { u: 720, c: [ "RU" ] }, "Asia/Aqtau": { u: 300, c: [ "KZ" ] }, "Asia/Aqtobe": { u: 300, c: [ "KZ" ] }, "Asia/Ashgabat": { u: 300, c: [ "TM" ] }, "Asia/Ashkhabad": { a: "Asia/Ashgabat", r: 1 }, "Asia/Atyrau": { u: 300, c: [ "KZ" ] }, "Asia/Baghdad": { u: 180, c: [ "IQ" ] }, "Asia/Bahrain": { a: "Asia/Qatar", c: [ "BH" ], r: 1 }, "Asia/Baku": { u: 240, c: [ "AZ" ] }, "Asia/Bangkok": { u: 420, c: [ "TH", "CX", "KH", "LA", "VN" ] }, "Asia/Barnaul": { u: 420, c: [ "RU" ] }, "Asia/Beirut": { u: 120, d: 180, c: [ "LB" ] }, "Asia/Bishkek": { u: 360, c: [ "KG" ] }, "Asia/Brunei": { a: "Asia/Kuching", c: [ "BN" ], r: 1 }, "Asia/Calcutta": { a: "Asia/Kolkata", r: 1 }, "Asia/Chita": { u: 540, c: [ "RU" ] }, "Asia/Choibalsan": { u: 480, c: [ "MN" ] }, "Asia/Chongqing": { a: "Asia/Shanghai", r: 1 }, "Asia/Chungking": { a: "Asia/Shanghai", r: 1 }, "Asia/Colombo": { u: 330, c: [ "LK" ] }, "Asia/Dacca": { a: "Asia/Dhaka", r: 1 }, "Asia/Damascus": { u: 180, c: [ "SY" ] }, "Asia/Dhaka": { u: 360, c: [ "BD" ] }, "Asia/Dili": { u: 540, c: [ "TL" ] }, "Asia/Dubai": { u: 240, c: [ "AE", "OM", "RE", "SC", "TF" ] }, "Asia/Dushanbe": { u: 300, c: [ "TJ" ] }, "Asia/Famagusta": { u: 120, d: 180, c: [ "CY" ] }, "Asia/Gaza": { u: 120, d: 180, c: [ "PS" ] }, "Asia/Harbin": { a: "Asia/Shanghai", r: 1 }, "Asia/Hebron": { u: 120, d: 180, c: [ "PS" ] }, "Asia/Ho_Chi_Minh": { u: 420, c: [ "VN" ] }, "Asia/Hong_Kong": { u: 480, c: [ "HK" ] }, "Asia/Hovd": { u: 420, c: [ "MN" ] }, "Asia/Irkutsk": { u: 480, c: [ "RU" ] }, "Asia/Istanbul": { a: "Europe/Istanbul", r: 1 }, "Asia/Jakarta": { u: 420, c: [ "ID" ] }, "Asia/Jayapura": { u: 540, c: [ "ID" ] }, "Asia/Jerusalem": { u: 120, d: 180, c: [ "IL" ] }, "Asia/Kabul": { u: 270, c: [ "AF" ] }, "Asia/Kamchatka": { u: 720, c: [ "RU" ] }, "Asia/Karachi": { u: 300, c: [ "PK" ] }, "Asia/Kashgar": { a: "Asia/Urumqi", c: [ "CN" ], r: 1 }, "Asia/Kathmandu": { u: 345, c: [ "NP" ] }, "Asia/Katmandu": { a: "Asia/Kathmandu", r: 1 }, "Asia/Khandyga": { u: 540, c: [ "RU" ] }, "Asia/Kolkata": { u: 330, c: [ "IN" ] }, "Asia/Krasnoyarsk": { u: 420, c: [ "RU" ] }, "Asia/Kuala_Lumpur": { a: "Asia/Singapore", c: [ "MY" ], r: 1 }, "Asia/Kuching": { u: 480, c: [ "MY", "BN" ] }, "Asia/Kuwait": { a: "Asia/Riyadh", c: [ "KW" ], r: 1 }, "Asia/Macao": { a: "Asia/Macau", r: 1 }, "Asia/Macau": { u: 480, c: [ "MO" ] }, "Asia/Magadan": { u: 660, c: [ "RU" ] }, "Asia/Makassar": { u: 480, c: [ "ID" ] }, "Asia/Manila": { u: 480, c: [ "PH" ] }, "Asia/Muscat": { a: "Asia/Dubai", c: [ "OM" ], r: 1 }, "Asia/Nicosia": { u: 120, d: 180, c: [ "CY" ] }, "Asia/Novokuznetsk": { u: 420, c: [ "RU" ] }, "Asia/Novosibirsk": { u: 420, c: [ "RU" ] }, "Asia/Omsk": { u: 360, c: [ "RU" ] }, "Asia/Oral": { u: 300, c: [ "KZ" ] }, "Asia/Phnom_Penh": { a: "Asia/Bangkok", c: [ "KH" ], r: 1 }, "Asia/Pontianak": { u: 420, c: [ "ID" ] }, "Asia/Pyongyang": { u: 540, c: [ "KP" ] }, "Asia/Qatar": { u: 180, c: [ "QA", "BH" ] }, "Asia/Qostanay": { u: 360, c: [ "KZ" ] }, "Asia/Qyzylorda": { u: 300, c: [ "KZ" ] }, "Asia/Rangoon": { a: "Asia/Yangon", c: [ "MM" ], r: 1 }, "Asia/Riyadh": { u: 180, c: [ "SA", "AQ", "KW", "YE" ] }, "Asia/Saigon": { a: "Asia/Ho_Chi_Minh", r: 1 }, "Asia/Sakhalin": { u: 660, c: [ "RU" ] }, "Asia/Samarkand": { u: 300, c: [ "UZ" ] }, "Asia/Seoul": { u: 540, c: [ "KR" ] }, "Asia/Shanghai": { u: 480, c: [ "CN" ] }, "Asia/Singapore": { u: 480, c: [ "SG", "MY" ] }, "Asia/Srednekolymsk": { u: 660, c: [ "RU" ] }, "Asia/Taipei": { u: 480, c: [ "TW" ] }, "Asia/Tashkent": { u: 300, c: [ "UZ" ] }, "Asia/Tbilisi": { u: 240, c: [ "GE" ] }, "Asia/Tehran": { u: 210, c: [ "IR" ] }, "Asia/Tel_Aviv": { a: "Asia/Jerusalem", r: 1 }, "Asia/Thimbu": { a: "Asia/Thimphu", r: 1 }, "Asia/Thimphu": { u: 360, c: [ "BT" ] }, "Asia/Tokyo": { u: 540, c: [ "JP" ] }, "Asia/Tomsk": { u: 420, c: [ "RU" ] }, "Asia/Ujung_Pandang": { a: "Asia/Makassar", r: 1 }, "Asia/Ulaanbaatar": { u: 480, c: [ "MN" ] }, "Asia/Ulan_Bator": { a: "Asia/Ulaanbaatar", r: 1 }, "Asia/Urumqi": { u: 360, c: [ "CN", "AQ" ] }, "Asia/Ust-Nera": { u: 600, c: [ "RU" ] }, "Asia/Vientiane": { a: "Asia/Bangkok", c: [ "LA" ], r: 1 }, "Asia/Vladivostok": { u: 600, c: [ "RU" ] }, "Asia/Yakutsk": { u: 540, c: [ "RU" ] }, "Asia/Yangon": { u: 390, c: [ "MM", "CC" ] }, "Asia/Yekaterinburg": { u: 300, c: [ "RU" ] }, "Asia/Yerevan": { u: 240, c: [ "AM" ] }, "Atlantic/Azores": { u: -60, d: 0, c: [ "PT" ] }, "Atlantic/Bermuda": { u: -240, d: -180, c: [ "BM" ] }, "Atlantic/Canary": { u: 0, d: 60, c: [ "ES" ] }, "Atlantic/Cape_Verde": { u: -60, c: [ "CV" ] }, "Atlantic/Faeroe": { a: "Atlantic/Faroe", r: 1 }, "Atlantic/Faroe": { u: 0, d: 60, c: [ "FO" ] }, "Atlantic/Jan_Mayen": { a: "Europe/Berlin", c: [ "SJ" ], r: 1 }, "Atlantic/Madeira": { u: 0, d: 60, c: [ "PT" ] }, "Atlantic/Reykjavik": { a: "Africa/Abidjan", c: [ "IS" ], r: 1 }, "Atlantic/South_Georgia": { u: -120, c: [ "GS" ] }, "Atlantic/St_Helena": { a: "Africa/Abidjan", c: [ "SH" ], r: 1 }, "Atlantic/Stanley": { u: -180, c: [ "FK" ] }, "Australia/ACT": { a: "Australia/Sydney", r: 1 }, "Australia/Adelaide": { u: 570, d: 630, c: [ "AU" ] }, "Australia/Brisbane": { u: 600, c: [ "AU" ] }, "Australia/Broken_Hill": { u: 570, d: 630, c: [ "AU" ] }, "Australia/Canberra": { a: "Australia/Sydney", r: 1 }, "Australia/Currie": { a: "Australia/Hobart", r: 1 }, "Australia/Darwin": { u: 570, c: [ "AU" ] }, "Australia/Eucla": { u: 525, c: [ "AU" ] }, "Australia/Hobart": { u: 600, d: 660, c: [ "AU" ] }, "Australia/LHI": { a: "Australia/Lord_Howe", r: 1 }, "Australia/Lindeman": { u: 600, c: [ "AU" ] }, "Australia/Lord_Howe": { u: 630, d: 660, c: [ "AU" ] }, "Australia/Melbourne": { u: 600, d: 660, c: [ "AU" ] }, "Australia/NSW": { a: "Australia/Sydney", r: 1 }, "Australia/North": { a: "Australia/Darwin", r: 1 }, "Australia/Perth": { u: 480, c: [ "AU" ] }, "Australia/Queensland": { a: "Australia/Brisbane", r: 1 }, "Australia/South": { a: "Australia/Adelaide", r: 1 }, "Australia/Sydney": { u: 600, d: 660, c: [ "AU" ] }, "Australia/Tasmania": { a: "Australia/Hobart", r: 1 }, "Australia/Victoria": { a: "Australia/Melbourne", r: 1 }, "Australia/West": { a: "Australia/Perth", r: 1 }, "Australia/Yancowinna": { a: "Australia/Broken_Hill", r: 1 }, "Brazil/Acre": { a: "America/Rio_Branco", r: 1 }, "Brazil/DeNoronha": { a: "America/Noronha", r: 1 }, "Brazil/East": { a: "America/Sao_Paulo", r: 1 }, "Brazil/West": { a: "America/Manaus", r: 1 }, CET: { u: 60, d: 120 }, CST6CDT: { u: -360, d: -300 }, "Canada/Atlantic": { a: "America/Halifax", r: 1 }, "Canada/Central": { a: "America/Winnipeg", r: 1 }, "Canada/Eastern": { a: "America/Toronto", c: [ "CA" ], r: 1 }, "Canada/Mountain": { a: "America/Edmonton", r: 1 }, "Canada/Newfoundland": { a: "America/St_Johns", r: 1 }, "Canada/Pacific": { a: "America/Vancouver", r: 1 }, "Canada/Saskatchewan": { a: "America/Regina", r: 1 }, "Canada/Yukon": { a: "America/Whitehorse", r: 1 }, "Chile/Continental": { a: "America/Santiago", r: 1 }, "Chile/EasterIsland": { a: "Pacific/Easter", r: 1 }, Cuba: { a: "America/Havana", r: 1 }, EET: { u: 120, d: 180 }, EST: { u: -300 }, EST5EDT: { u: -300, d: -240 }, Egypt: { a: "Africa/Cairo", r: 1 }, Eire: { a: "Europe/Dublin", r: 1 }, "Etc/GMT": { u: 0 }, "Etc/GMT+0": { a: "Etc/GMT", r: 1 }, "Etc/GMT+1": { u: -60 }, "Etc/GMT+10": { u: -600 }, "Etc/GMT+11": { u: -660 }, "Etc/GMT+12": { u: -720 }, "Etc/GMT+2": { u: -120 }, "Etc/GMT+3": { u: -180 }, "Etc/GMT+4": { u: -240 }, "Etc/GMT+5": { u: -300 }, "Etc/GMT+6": { u: -360 }, "Etc/GMT+7": { u: -420 }, "Etc/GMT+8": { u: -480 }, "Etc/GMT+9": { u: -540 }, "Etc/GMT-0": { a: "Etc/GMT", r: 1 }, "Etc/GMT-1": { u: 60 }, "Etc/GMT-10": { u: 600 }, "Etc/GMT-11": { u: 660 }, "Etc/GMT-12": { u: 720 }, "Etc/GMT-13": { u: 780 }, "Etc/GMT-14": { u: 840 }, "Etc/GMT-2": { u: 120 }, "Etc/GMT-3": { u: 180 }, "Etc/GMT-4": { u: 240 }, "Etc/GMT-5": { u: 300 }, "Etc/GMT-6": { u: 360 }, "Etc/GMT-7": { u: 420 }, "Etc/GMT-8": { u: 480 }, "Etc/GMT-9": { u: 540 }, "Etc/GMT0": { a: "Etc/GMT", r: 1 }, "Etc/Greenwich": { a: "Etc/GMT", r: 1 }, "Etc/UCT": { a: "Etc/UTC", r: 1 }, "Etc/UTC": { u: 0 }, "Etc/Universal": { a: "Etc/UTC", r: 1 }, "Etc/Zulu": { a: "Etc/UTC", r: 1 }, "Europe/Amsterdam": { a: "Europe/Brussels", c: [ "NL" ], r: 1 }, "Europe/Andorra": { u: 60, d: 120, c: [ "AD" ] }, "Europe/Astrakhan": { u: 240, c: [ "RU" ] }, "Europe/Athens": { u: 120, d: 180, c: [ "GR" ] }, "Europe/Belfast": { a: "Europe/London", c: [ "GB" ], r: 1 }, "Europe/Belgrade": { u: 60, d: 120, c: [ "RS", "BA", "HR", "ME", "MK", "SI" ] }, "Europe/Berlin": { u: 60, d: 120, c: [ "DE", "DK", "NO", "SE", "SJ" ] }, "Europe/Bratislava": { a: "Europe/Prague", c: [ "SK" ], r: 1 }, "Europe/Brussels": { u: 60, d: 120, c: [ "BE", "LU", "NL" ] }, "Europe/Bucharest": { u: 120, d: 180, c: [ "RO" ] }, "Europe/Budapest": { u: 60, d: 120, c: [ "HU" ] }, "Europe/Busingen": { a: "Europe/Zurich", c: [ "DE" ], r: 1 }, "Europe/Chisinau": { u: 120, d: 180, c: [ "MD" ] }, "Europe/Copenhagen": { a: "Europe/Berlin", c: [ "DK" ], r: 1 }, "Europe/Dublin": { u: 60, d: 0, c: [ "IE" ] }, "Europe/Gibraltar": { u: 60, d: 120, c: [ "GI" ] }, "Europe/Guernsey": { a: "Europe/London", c: [ "GG" ], r: 1 }, "Europe/Helsinki": { u: 120, d: 180, c: [ "FI", "AX" ] }, "Europe/Isle_of_Man": { a: "Europe/London", c: [ "IM" ], r: 1 }, "Europe/Istanbul": { u: 180, c: [ "TR" ] }, "Europe/Jersey": { a: "Europe/London", c: [ "JE" ], r: 1 }, "Europe/Kaliningrad": { u: 120, c: [ "RU" ] }, "Europe/Kiev": { a: "Europe/Kyiv", r: 1 }, "Europe/Kirov": { u: 180, c: [ "RU" ] }, "Europe/Kyiv": { u: 120, d: 180, c: [ "UA" ] }, "Europe/Lisbon": { u: 0, d: 60, c: [ "PT" ] }, "Europe/Ljubljana": { a: "Europe/Belgrade", c: [ "SI" ], r: 1 }, "Europe/London": { u: 0, d: 60, c: [ "GB", "GG", "IM", "JE" ] }, "Europe/Luxembourg": { a: "Europe/Brussels", c: [ "LU" ], r: 1 }, "Europe/Madrid": { u: 60, d: 120, c: [ "ES" ] }, "Europe/Malta": { u: 60, d: 120, c: [ "MT" ] }, "Europe/Mariehamn": { a: "Europe/Helsinki", c: [ "AX" ], r: 1 }, "Europe/Minsk": { u: 180, c: [ "BY" ] }, "Europe/Monaco": { a: "Europe/Paris", c: [ "MC" ], r: 1 }, "Europe/Moscow": { u: 180, c: [ "RU" ] }, "Europe/Nicosia": { a: "Asia/Nicosia", r: 1 }, "Europe/Oslo": { a: "Europe/Berlin", c: [ "NO" ], r: 1 }, "Europe/Paris": { u: 60, d: 120, c: [ "FR", "MC" ] }, "Europe/Podgorica": { a: "Europe/Belgrade", c: [ "ME" ], r: 1 }, "Europe/Prague": { u: 60, d: 120, c: [ "CZ", "SK" ] }, "Europe/Riga": { u: 120, d: 180, c: [ "LV" ] }, "Europe/Rome": { u: 60, d: 120, c: [ "IT", "SM", "VA" ] }, "Europe/Samara": { u: 240, c: [ "RU" ] }, "Europe/San_Marino": { a: "Europe/Rome", c: [ "SM" ], r: 1 }, "Europe/Sarajevo": { a: "Europe/Belgrade", c: [ "BA" ], r: 1 }, "Europe/Saratov": { u: 240, c: [ "RU" ] }, "Europe/Simferopol": { u: 180, c: [ "RU", "UA" ] }, "Europe/Skopje": { a: "Europe/Belgrade", c: [ "MK" ], r: 1 }, "Europe/Sofia": { u: 120, d: 180, c: [ "BG" ] }, "Europe/Stockholm": { a: "Europe/Berlin", c: [ "SE" ], r: 1 }, "Europe/Tallinn": { u: 120, d: 180, c: [ "EE" ] }, "Europe/Tirane": { u: 60, d: 120, c: [ "AL" ] }, "Europe/Tiraspol": { a: "Europe/Chisinau", r: 1 }, "Europe/Ulyanovsk": { u: 240, c: [ "RU" ] }, "Europe/Uzhgorod": { a: "Europe/Kyiv", r: 1 }, "Europe/Vaduz": { a: "Europe/Zurich", c: [ "LI" ], r: 1 }, "Europe/Vatican": { a: "Europe/Rome", c: [ "VA" ], r: 1 }, "Europe/Vienna": { u: 60, d: 120, c: [ "AT" ] }, "Europe/Vilnius": { u: 120, d: 180, c: [ "LT" ] }, "Europe/Volgograd": { u: 180, c: [ "RU" ] }, "Europe/Warsaw": { u: 60, d: 120, c: [ "PL" ] }, "Europe/Zagreb": { a: "Europe/Belgrade", c: [ "HR" ], r: 1 }, "Europe/Zaporozhye": { a: "Europe/Kyiv", r: 1 }, "Europe/Zurich": { u: 60, d: 120, c: [ "CH", "DE", "LI" ] }, Factory: { u: 0 }, GB: { a: "Europe/London", c: [ "GB" ], r: 1 }, "GB-Eire": { a: "Europe/London", c: [ "GB" ], r: 1 }, GMT: { a: "Etc/GMT", r: 1 }, "GMT+0": { a: "Etc/GMT", r: 1 }, "GMT-0": { a: "Etc/GMT", r: 1 }, GMT0: { a: "Etc/GMT", r: 1 }, Greenwich: { a: "Etc/GMT", r: 1 }, HST: { u: -600 }, Hongkong: { a: "Asia/Hong_Kong", r: 1 }, Iceland: { a: "Africa/Abidjan", c: [ "IS" ], r: 1 }, "Indian/Antananarivo": { a: "Africa/Nairobi", c: [ "MG" ], r: 1 }, "Indian/Chagos": { u: 360, c: [ "IO" ] }, "Indian/Christmas": { a: "Asia/Bangkok", c: [ "CX" ], r: 1 }, "Indian/Cocos": { a: "Asia/Yangon", c: [ "CC" ], r: 1 }, "Indian/Comoro": { a: "Africa/Nairobi", c: [ "KM" ], r: 1 }, "Indian/Kerguelen": { a: "Indian/Maldives", c: [ "TF" ], r: 1 }, "Indian/Mahe": { a: "Asia/Dubai", c: [ "SC" ], r: 1 }, "Indian/Maldives": { u: 300, c: [ "MV", "TF" ] }, "Indian/Mauritius": { u: 240, c: [ "MU" ] }, "Indian/Mayotte": { a: "Africa/Nairobi", c: [ "YT" ], r: 1 }, "Indian/Reunion": { a: "Asia/Dubai", c: [ "RE" ], r: 1 }, Iran: { a: "Asia/Tehran", r: 1 }, Israel: { a: "Asia/Jerusalem", r: 1 }, Jamaica: { a: "America/Jamaica", r: 1 }, Japan: { a: "Asia/Tokyo", r: 1 }, Kwajalein: { a: "Pacific/Kwajalein", r: 1 }, Libya: { a: "Africa/Tripoli", r: 1 }, MET: { u: 60, d: 120 }, MST: { u: -420 }, MST7MDT: { u: -420, d: -360 }, "Mexico/BajaNorte": { a: "America/Tijuana", r: 1 }, "Mexico/BajaSur": { a: "America/Mazatlan", r: 1 }, "Mexico/General": { a: "America/Mexico_City", r: 1 }, NZ: { a: "Pacific/Auckland", c: [ "NZ" ], r: 1 }, "NZ-CHAT": { a: "Pacific/Chatham", r: 1 }, Navajo: { a: "America/Denver", r: 1 }, PRC: { a: "Asia/Shanghai", r: 1 }, PST8PDT: { u: -480, d: -420 }, "Pacific/Apia": { u: 780, c: [ "WS" ] }, "Pacific/Auckland": { u: 720, d: 780, c: [ "NZ", "AQ" ] }, "Pacific/Bougainville": { u: 660, c: [ "PG" ] }, "Pacific/Chatham": { u: 765, d: 825, c: [ "NZ" ] }, "Pacific/Chuuk": { a: "Pacific/Port_Moresby", c: [ "FM" ], r: 1 }, "Pacific/Easter": { u: -360, d: -300, c: [ "CL" ] }, "Pacific/Efate": { u: 660, c: [ "VU" ] }, "Pacific/Enderbury": { a: "Pacific/Kanton", r: 1 }, "Pacific/Fakaofo": { u: 780, c: [ "TK" ] }, "Pacific/Fiji": { u: 720, c: [ "FJ" ] }, "Pacific/Funafuti": { a: "Pacific/Tarawa", c: [ "TV" ], r: 1 }, "Pacific/Galapagos": { u: -360, c: [ "EC" ] }, "Pacific/Gambier": { u: -540, c: [ "PF" ] }, "Pacific/Guadalcanal": { u: 660, c: [ "SB", "FM" ] }, "Pacific/Guam": { u: 600, c: [ "GU", "MP" ] }, "Pacific/Honolulu": { u: -600, c: [ "US" ] }, "Pacific/Johnston": { a: "Pacific/Honolulu", r: 1 }, "Pacific/Kanton": { u: 780, c: [ "KI" ] }, "Pacific/Kiritimati": { u: 840, c: [ "KI" ] }, "Pacific/Kosrae": { u: 660, c: [ "FM" ] }, "Pacific/Kwajalein": { u: 720, c: [ "MH" ] }, "Pacific/Majuro": { a: "Pacific/Tarawa", c: [ "MH" ], r: 1 }, "Pacific/Marquesas": { u: -570, c: [ "PF" ] }, "Pacific/Midway": { a: "Pacific/Pago_Pago", c: [ "UM" ], r: 1 }, "Pacific/Nauru": { u: 720, c: [ "NR" ] }, "Pacific/Niue": { u: -660, c: [ "NU" ] }, "Pacific/Norfolk": { u: 660, d: 720, c: [ "NF" ] }, "Pacific/Noumea": { u: 660, c: [ "NC" ] }, "Pacific/Pago_Pago": { u: -660, c: [ "AS", "UM" ] }, "Pacific/Palau": { u: 540, c: [ "PW" ] }, "Pacific/Pitcairn": { u: -480, c: [ "PN" ] }, "Pacific/Pohnpei": { a: "Pacific/Guadalcanal", c: [ "FM" ], r: 1 }, "Pacific/Ponape": { a: "Pacific/Guadalcanal", c: [ "FM" ], r: 1 }, "Pacific/Port_Moresby": { u: 600, c: [ "PG", "AQ", "FM" ] }, "Pacific/Rarotonga": { u: -600, c: [ "CK" ] }, "Pacific/Saipan": { a: "Pacific/Guam", c: [ "MP" ], r: 1 }, "Pacific/Samoa": { a: "Pacific/Pago_Pago", c: [ "AS" ], r: 1 }, "Pacific/Tahiti": { u: -600, c: [ "PF" ] }, "Pacific/Tarawa": { u: 720, c: [ "KI", "MH", "TV", "UM", "WF" ] }, "Pacific/Tongatapu": { u: 780, c: [ "TO" ] }, "Pacific/Truk": { a: "Pacific/Port_Moresby", c: [ "FM" ], r: 1 }, "Pacific/Wake": { a: "Pacific/Tarawa", c: [ "UM" ], r: 1 }, "Pacific/Wallis": { a: "Pacific/Tarawa", c: [ "WF" ], r: 1 }, "Pacific/Yap": { a: "Pacific/Port_Moresby", c: [ "FM" ], r: 1 }, Poland: { a: "Europe/Warsaw", r: 1 }, Portugal: { a: "Europe/Lisbon", r: 1 }, ROC: { a: "Asia/Taipei", r: 1 }, ROK: { a: "Asia/Seoul", r: 1 }, Singapore: { a: "Asia/Singapore", c: [ "SG" ], r: 1 }, Turkey: { a: "Europe/Istanbul", r: 1 }, UCT: { a: "Etc/UTC", r: 1 }, "US/Alaska": { a: "America/Anchorage", r: 1 }, "US/Aleutian": { a: "America/Adak", r: 1 }, "US/Arizona": { a: "America/Phoenix", c: [ "US" ], r: 1 }, "US/Central": { a: "America/Chicago", r: 1 }, "US/East-Indiana": { a: "America/Indiana/Indianapolis", r: 1 }, "US/Eastern": { a: "America/New_York", r: 1 }, "US/Hawaii": { a: "Pacific/Honolulu", r: 1 }, "US/Indiana-Starke": { a: "America/Indiana/Knox", r: 1 }, "US/Michigan": { a: "America/Detroit", r: 1 }, "US/Mountain": { a: "America/Denver", r: 1 }, "US/Pacific": { a: "America/Los_Angeles", r: 1 }, "US/Samoa": { a: "Pacific/Pago_Pago", c: [ "AS" ], r: 1 }, UTC: { a: "Etc/UTC", r: 1 }, Universal: { a: "Etc/UTC", r: 1 }, "W-SU": { a: "Europe/Moscow", r: 1 }, WET: { u: 0, d: 60 }, Zulu: { a: "Etc/UTC", r: 1 } }; var data = { countries: countries$1, timezones: timezones$1 }; var timezonesMap; function buildCountry(data, id) { var name = data.countries[id]; if (!name) return null; var tzMap = getTimezonesMap(data)[id] || {}; return { id: id, name: name, timezones: tzMap.current || [], allTimezones: tzMap.all || [] }; } function getTimezonesMap(data) { if (!timezonesMap) timezonesMap = buildTimezonesMap(data); return timezonesMap; } function buildTimezonesMap(data) { return Object.keys(data.timezones).reduce(function (result, id) { var tz = data.timezones[id]; var c = tz.c, a = tz.a; var aliasTz = data.timezones[a] || {}; var countries = c || aliasTz.c; if (!countries) return result; countries.forEach(function (country) { if (!result[country]) Object.assign(result, _defineProperty({}, country, { current: [], all: [] })); if (tz.r === undefined) result[country].current.push(id); result[country].all.push(id); }); return result; }, {}); } function buildTimezone(data, name) { var timezone = data.timezones[name]; if (!timezone) return null; var _timezone$a = timezone.a, aliasOf = _timezone$a === void 0 ? null : _timezone$a; var aliasTz = aliasOf ? data.timezones[aliasOf] : {}; var tz = _objectSpread2(_objectSpread2({}, aliasTz), data.timezones[name]); var countries = tz.c || []; var utcOffset = tz.u; var dstOffset = Number.isInteger(tz.d) ? tz.d : utcOffset; var result = { name: name, countries: countries, utcOffset: utcOffset, utcOffsetStr: getOffsetStr(utcOffset), dstOffset: dstOffset, dstOffsetStr: getOffsetStr(dstOffset), aliasOf: aliasOf }; if (timezone.r) result.deprecated = true; return result; } function getOffsetStr(offset) { var hours = Math.floor(Math.abs(offset) / 60); var min = offset % 60; var sign = offset 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!countries$2[id]) memoizeCountry(buildCountry(data, id)); return deliverCountry(countries$2[id], options); } function memoizeCountry(country) { if (!country) return; countries$2[country.id] = country; } function getTimezone(name) { if (!timezones[name]) memoizeTimezone(buildTimezone(data, name)); return timezones[name] ? _objectSpread2({}, timezones[name]) : null; } function memoizeTimezone(timezone) { if (!timezone) return; timezones[timezone.name] = timezone; Object.keys(timezone).length; } function getCountriesForTimezone(tzName) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var timezone = getTimezone(tzName) || {}; var values = timezone.countries || []; return values.map(function (c) { return getCountry(c, options); }); } function deliverCountry(country, options) { if (!country) return null; var _ref2 = options || {}, deprecated = _ref2.deprecated; country.allTimezones; var other = _objectWithoutProperties(country, _excluded); var tz = deprecated ? country.allTimezones : country.timezones; return _objectSpread2(_objectSpread2({}, other), {}, { timezones: tz }); } const timezoneCountryId = () => { const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; return getCountriesForTimezone(timezone)[0]?.id ?? ''; }; function buildPreviewPayload(form, formState) { const terms = formState.paymentOption.terms; return { account: { city: unknownToEmpty(formConfigAs(form).requestCity), country: unknownToEmpty(formConfigAs(form).requestCountry) || timezoneCountryId(), county: '', state: unknownToEmpty(formConfigAs(form).requestState), zipCode: unknownToEmpty(formConfigAs(form).requestZipCode) }, currency: getRelevantCurrency(form, formState), ratePlanIds: [formState.paymentOption.slug], ...(terms ? { termType: terms.initialTerm.termType, ...(terms.initialTerm.termType === 'TERMED' ? { initialTerm: terms.initialTerm.period, initialTermPeriodType: terms.initialTerm.periodType, } : {}), } : { termType: "EVERGREEN", }), ...(formState.dynamicOfferResult ? { dynamicOfferResult: JSON.stringify(formState.dynamicOfferResult), productId: formState.paymentOption.productId } : {}), }; } const calculateZuoraPrice = (form, formState, formActions) => { return loadZuora() .then(() => getPreview(form, formState, formActions)) .then((previewResponse) => { if (previewResponse.pfToken) { formActions.updateFormState({ pfToken: previewResponse.pfToken }); } return { slug: formState.paymentOption.slug, productId: formState.paymentOption.productId, promoCode: formState.promoCode, addonPrices: [], totalPrice: previewResponse.amount, totalPriceFormattedString: formatCurrency(previewResponse.amount, getRelevantCurrency(form, formState)), netPrice: previewResponse.amountWithoutTax, netPriceFormattedString: formatCurrency(previewResponse.amountWithoutTax, getRelevantCurrency(form, formState)), taxPrice: previewResponse.taxAmount || null, taxPriceFormattedString: previewResponse.taxAmount ? formatCurrency(previewResponse.taxAmount, getRelevantCurrency(form, formState)) : null, discountPrice: 0, discountPriceFormattedPrice: formatCurrency(0, getRelevantCurrency(form, formState)), chargeItems: [...Object.values(previewResponse.invoiceItems)] .filter((invoiceItem) => invoiceItem.chargeAmount) .map((invoiceItem) => ({ label: invoiceItem.chargeName, priceFormattedString: formatCurrency(invoiceItem.chargeAmount, getRelevantCurrency(form, formState)) })), billingAddress: formState.billingAddress }; }); }; const unknownToEmpty = (location) => location?.toLowerCase() === 'unknown' ? '' : location; const getPreview = (form, formState, formActions) => { if (form.environment.previewMode) { return mockBillingPreviewResponse(formConfigAs(form).dynamicOfferPreview ?? {}); } const previewBody = buildPreviewPayload(form, formState); return request("zephr/public/payment/v1/billing/preview-subscription", { method: "POST", bodyObject: previewBody }, formActions).then(response => response.json()); }; const formattedDateWord = (date, locale = 'en-UK') => { if (!date) return ''; const d = new Date(date); if (Number.isNaN(d.getDate())) return 'Unknown'; return d.toLocaleDateString(locale, { day: 'numeric', month: 'short', year: 'numeric' }); }; // Example key: " >>" const keyDefaultRegex = /^ >>$/; const resolveErrorLanguagePackKey = (form, serverError) => { if (serverError == null) { return ''; } const packEntries = form.languagePack?.entries ?? {}; const error = ServerErrors[serverError]; return packEntries[error.languagePackKey] ?? error.fallbackMessage; }; const resolveLanguagePackKey = (languagePack, string) => { if (!string) { return string; } try { const match = keyDefaultRegex.exec(string); if (!match || !match[1]) { return string; } const packEntries = languagePack?.entries ?? {}; return packEntries[match[1]] ?? match[2]; } catch (e) { console.warn(`error resolving language pack key in string ${string}`, e); return string; } }; const resolveLanguagePackKeyTyped = (form, key, fallback) => { try { const packEntries = form.languagePack?.entries ?? {}; return packEntries[key] ?? fallback; } catch (e) { console.warn(`error resolving language pack key in string ${key}`, e); return fallback; } }; const resolveLanguagePackLocale = (form) => resolveLanguagePackKeyTyped(form, 'pages.common.date-time-format-locale', 'en-US'); const resolveLanguagePackKeys = (languagePack, object) => { try { if (object == null) { return object; } if (typeof object !== 'object' && !Array.isArray(object)) { if (typeof object === 'string' || object instanceof String) { return resolveLanguagePackKey(languagePack, object); } return object; } if (Array.isArray(object)) { return object.map(e => resolveLanguagePackKeys(languagePack, e)); } return Object.entries(object).reduce((acc, [key, value]) => { return { ...acc, [key]: resolveLanguagePackKeys(languagePack, value) }; }, {}); } catch (e) { console.warn(`error resolving language pack entries`, e); return object; } }; const getSubscriptionAmount = (form, subscription) => { try { if (subscription.isOneOff) { return ''; } const everyLabel = resolveLanguagePackKeyTyped(form, 'forms.billing.history.every', 'every'); const firstPayment = subscription['transaction-history']?.[0] ?? subscription['next-billing-time']; const str = firstPayment?.['human-readable-amount']; if (!str) return ''; const currency = subscription.currency_code?.toUpperCase() ?? str.replace(/[0-9,.]/g, ''); const { discounts_applied: discountApplied, pre_discount_price: price, billing_frequency: freq, billing_frequency_unit: freqUnit, } = subscription ?? {}; if (!discountApplied && price && freq && freqUnit) { if (freq === 1) { return `${currency} ${price}/${freqUnit.toLowerCase()}`; } return `${currency} ${price} ${everyLabel} ${freq} ${freqUnit.toLowerCase()}s`; } const num = Number(str.replace(/[^\d.-]/g, '')); const amount = Number.isInteger(num) ? num.toFixed(0) : num; if (firstPayment.cycleCount === 1) { return `${currency}${amount}/${firstPayment.cycle}`; } return `${currency} ${amount} ${everyLabel} ${firstPayment.cycleCount} ${firstPayment.cycle}s`; } catch { console.error('Failed to get subscription amount'); return ''; } }; const getPeriod = (time, cycle, cycleCount, locale) => { try { const d = new Date(time); const addCycles = (() => { switch (cycle) { case 'day': return d.setDate(d.getDate() + cycleCount); case 'week': return d.setDate(d.getDate() + cycleCount * 7); case 'month': return d.setMonth(d.getMonth() + cycleCount); case 'year': return d.setFullYear(d.getFullYear() + cycleCount); default: return null; } })(); const start = formattedDateWord(time, locale); const end = formattedDateWord(addCycles, locale); return `${start} - ${end}`; } catch { console.error('Failed to get subscription period'); return ''; } }; const buildTaxString = (inclusive, cents, name) => (`${inclusive ? '' : '+'}` + `${(cents / 100).toFixed(2)} ${name}` + `${inclusive ? ' incl.' : ''}`); const getSpecificTax = (cents, displayName, taxInclusive, taxPercent) => { try { const taxAmount = taxPercent * (cents / 100); const totalCents = cents + (taxInclusive ? 0 : taxAmount); const total = (totalCents / 100).toFixed(2); const taxes = `(${buildTaxString(taxInclusive, taxAmount, displayName)})`; return { taxes, total }; } catch { console.error('Failed to get subscription tax'); return { taxes: '', total: 0 }; } }; const getDefaultTaxes = (cents, defaultTax) => { try { const taxes = []; let totalCents = cents; defaultTax.forEach((e) => { const taxCents = e.taxPercent * (cents / 100); const tax = buildTaxString(e.taxInclusive, taxCents, e.displayName); taxes.push(tax); totalCents += e.taxInclusive ? 0 : taxCents; }); const total = (totalCents / 100).toFixed(2); return { taxes: `(${taxes.join(', ')})`, total }; } catch { console.error('Failed to get subscription default tax'); return { taxes: '', total: 0 }; } }; const getBillingHistory = (form, subscription) => { try { const defaultTax = subscription['default-tax-rates']; const managedBy = subscription['managed-by'].toLowerCase(); const isCanceled = subscription['subscription-state'].toLowerCase() === 'canceled'; const cancelDate = formattedDateWord(managedBy === 'stripe' ? subscription.ended : subscription.ends); const locale = resolveLanguagePackLocale(form); let newArr = subscription['transaction-history'].reduce((acc, e) => { const date = formattedDateWord(e.time, locale); const period = getPeriod(e.time, e.cycle, e.cycleCount, locale); const { cents, currency, taxRate, } = e; let total; let taxes; if (taxRate) { const { displayName, taxInclusive, taxPercent } = taxRate; ({ taxes, total } = getSpecificTax(cents, displayName, taxInclusive, taxPercent)); } else if (defaultTax?.length) { ({ taxes, total } = getDefaultTaxes(cents, defaultTax)); } else { total = (cents / 100).toFixed(2); taxes = null; } const subtotal = managedBy === 'stripe' ? (e.cents / 100).toFixed(2) : null; return [...acc, { date, period, subtotal, currency, taxes, total, }]; }, []); if (isCanceled) { newArr = [{ date: cancelDate, period: 'canceled', }, ...newArr]; } return newArr; } catch { console.error('Failed to get subscription billing history'); return null; } }; const loadBraintreeStripeSubscriptions = (form, _, formActions, activeOnly) => { return request(`blaize/payment/${form.organisationConfiguration.paymentProvider}/subscriptions`, { method: "GET" }, formActions, null, true) .then(response => response.ok ? response.json() : []) .then(subscriptions => subscriptions .filter(subscription => !activeOnly || subscription['subscription-state']?.toLowerCase() === 'active') .map(subscription => { const locale = resolveLanguagePackLocale(form); const multiphasePlanMappings = getMultiphasePlanMappings(subscription); return { externalId: subscription['external-id'], productId: subscription['blaize-product'].id, productLabel: subscription['blaize-product'].label ?? subscription['blaize-product'].id, planId: subscription['plan_id'], planLabel: subscription['plan_name'], currency: subscription['currency_code'], status: subscription['subscription-state']?.toLowerCase() === 'active' ? 'active' : 'inactive', nextBillingTime: formattedDateWord(subscription['next-billing-time'], locale), amount: getSubscriptionAmount(form, subscription), transactionHistory: getBillingHistory(form, subscription), ...(subscription['multiphase_plan'] && { multiphasePlan: subscription['multiphase_plan'] }), ...(Object.keys(multiphasePlanMappings).length > 0 && { multiphasePlanMappings }) }; })); }; const getMultiphasePlanMappings = (subscription) => { const multiPhasedPlans = subscription['blaize-product'].mapping?.recurring?.multiPhasedPlans || []; return multiPhasedPlans.reduce((acc, plan) => { acc[plan.id] = plan; return acc; }, {}); }; const calculateStripeSubscriptionProrate = (form, formState, formActions) => { const changingFromSubscription = formState .validChangeFromPlans .find(plan => formState.paymentOption.slug === plan.planSlug && formState.paymentOption.productId === plan.productId) ?.changesFromSubscription; if (!changingFromSubscription) { console.error("No valid change from subscription"); return; } return request(`zephr/payment/stripe/subscriptions/${changingFromSubscription.externalId}/change-previews`, { method: 'POST', bodyObject: { plan_id: formState.paymentOption.slug } }, formActions) .then(response => response.json()) .then(preview => { const currencyMultiplier = isZeroDecimalCurrency(formState.paymentOption.currencyCode.toUpperCase()) ? 1 : 0.01; return { totalPrice: preview.total * currencyMultiplier, totalPriceFormattedString: formatCurrency(preview.total * currencyMultiplier, formState.paymentOption.currencyCode), subTotalPrice: preview.sub_total * currencyMultiplier, subTotalPriceFormattedString: formatCurrency(preview.sub_total * currencyMultiplier, formState.paymentOption.currencyCode), }; }); }; // Standalone service to load gift subscriptions without importing paymentProviderConfigurations const loadGiftSubscriptions = async (form, formState, formActions) => { try { const response = await request("zephr/public/gifts/v1/gifts", { method: "GET" }, formActions, null, true); if (response.ok) { const json = await response.json(); const rawGiftSubscriptions = json || []; // Map API response fields from camelCase to the structure consumers expect const giftSubscriptions = rawGiftSubscriptions .filter((gift) => gift.subscriptionDetails) .map((gift) => ({ gift_code: gift.giftCode, subscription_number: gift.subscriptionNumber, status: gift.status, is_purchaser: gift.isPurchaser, is_recipient: gift.isRecipient, error_reason: gift.errorReason, host: gift.host, externalId: gift.subscriptionDetails?.id, recipientFirstName: gift.subscriptionDetails?.soldToContact?.firstName, recipientLastName: gift.subscriptionDetails?.soldToContact?.lastName, subscriptionStartDate: gift.subscriptionDetails?.subscriptionStartDate, subscriptionEndDate: gift.subscriptionDetails?.termEndDate, subscriptionType: gift.subscriptionDetails?.ratePlans?.[0]?.productName, currency: gift.subscriptionDetails?.currency, })); formActions.updateFormState({ giftSubscriptions: giftSubscriptions, formPrerequisiteLoaded: true }); } else { formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); } } catch (error) { formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); } }; const formatChargeCadence = (form, charge) => { // Early return if we don't have the required charge data if (!charge.price || !charge.currency) { return null; } const price = formatCurrency(charge.price, charge.currency); // Use listPriceBase as the primary display denominator if (charge.listPriceBase && charge.listPriceBase !== 'Per_Billing_Period') { // Convert "Per_Month" -> "month", "Per_Year" -> "year", etc. const unit = charge.listPriceBase.replace('Per_', '').toLowerCase(); return `${price}/${unit}`; } // Fall back to billingPeriod for "Per_Billing_Period" or missing listPriceBase if (charge.billingPeriod) { const period = charge.billingPeriod.toLowerCase(); // Handle special cases if (period === 'specificmonths') { return `${price}/month`; // Default to month for specific months } return `${price}/${period}`; } // Final fallback - assume monthly return `${price}/month`; }; // Helper function to format Zuora subscription amount based on billing period const formatZuoraSubscriptionAmount = (form, subscription) => { // Early return for completely invalid inputs if (!subscription.contractedMrr || !subscription.currency) { return ''; } // Get the first active rate plan charge for accurate pricing const ratePlanList = [...Object.values(subscription.ratePlans)]; const activeRatePlans = ratePlanList.length === 1 ? ratePlanList : ratePlanList.filter(ratePlan => ratePlan.lastChangeType === 'Add'); // Try to use accurate charge-level data first if (activeRatePlans[0]?.ratePlanCharges?.[0]) { const firstCharge = activeRatePlans[0].ratePlanCharges[0]; const accurateAmount = formatChargeCadence(form, firstCharge); if (accurateAmount) { return accurateAmount; } } // Fallback: display MRR per month if we don't have the required charge data const fallbackAmount = formatCurrency(subscription.contractedMrr, subscription.currency); return `${fallbackAmount}/month`; }; // Helper function to extract only custom fields (those ending with "__c") const extractCustomFields = (subscription) => { const customFields = {}; for (const [key, value] of Object.entries(subscription)) { if (key.endsWith('__c')) { customFields[key] = value; } } return customFields; }; const zuoraStatusMap = { 'draft': 'pending', 'pending activation': 'pending', 'pending acceptance': 'pending', 'active': 'active', 'cancelled': 'inactive', 'expired': 'inactive', 'suspended': 'inactive' }; const isTodayOrFutureDate = (dateString) => { if (!dateString) return false; const parsedDate = new Date(dateString); if (Number.isNaN(parsedDate.getTime())) return false; parsedDate.setHours(23, 59, 59, 999); return parsedDate.getTime() >= Date.now(); }; const resolveSubscriptionStatus = (rawStatus, endDate) => { const mapped = zuoraStatusMap[rawStatus?.toLowerCase() ?? ''] ?? 'inactive'; if (mapped === 'inactive' && isTodayOrFutureDate(endDate)) { return 'active'; } return mapped; }; const deduplicateSubscriptions = (regularSubscriptions, giftSubscriptions) => { const giftExternalIds = new Set(giftSubscriptions.map(g => g.externalId)); const dedupedRegular = regularSubscriptions.filter(s => !giftExternalIds.has(s.externalId)); return [...dedupedRegular, ...giftSubscriptions]; }; const normalizeGiftStatus = (status) => { if (!status) return 'inactive'; if (status === 'REDEEMED' || status === 'PENDING') return 'active'; return zuoraStatusMap[status.toLowerCase()] ?? 'inactive'; }; const loadZuoraSubscriptions = async (form, formState, formActions, activeOnly, isGiftSubscriptions = false) => { // Load gift subscriptions first via standalone service (no circular deps) let giftSubscriptions = []; try { await loadGiftSubscriptions(form, formState, formActions); const updatedFormState = formActions.getFormState(); giftSubscriptions = (updatedFormState.giftSubscriptions || []).map((giftSub) => ({ externalId: giftSub.externalId, accountId: '', productId: giftSub.subscriptionType || '', productLabel: giftSub.subscriptionType || '', planId: '', planLabel: null, currency: giftSub.currency, status: isTodayOrFutureDate(giftSub.subscriptionEndDate) ? 'active' : normalizeGiftStatus(giftSub.status), amount: '', isGift: true, recipientFirstName: giftSub.recipientFirstName, recipientLastName: giftSub.recipientLastName, subscriptionStartDate: giftSub.subscriptionStartDate, subscriptionEndDate: giftSub.subscriptionEndDate, subscriptionType: giftSub.subscriptionType, subscriptionNumber: giftSub.subscriptionNumber, })); } catch (error) { console.error('Error loading gift subscriptions:', error); // Continue without gift subscriptions } // Load regular Zuora subscriptions const regularSubscriptions = await request('plugins/public/zuora-billing/subscriptions', { method: "GET" }, formActions, null, true) .then(response => response.json()) .then(subscriptionsResponse => [...Object.values(subscriptionsResponse.subscriptions || {})]) .then(subscriptions => subscriptions .filter(subscription => !activeOnly || subscription.status?.toLowerCase() === 'active') .map(subscription => { // Assuming that Zephr created Zuora subscriptions only have 1 active rate plan const ratePlanList = [...Object.values(subscription.ratePlans)]; const activeRatePlans = ratePlanList.length === 1 ? ratePlanList : ratePlanList.filter(ratePlan => ratePlan.lastChangeType === 'Add'); if (activeRatePlans.length !== 1) { console.warn(`Subscription ${subscription.id} has ${activeRatePlans.length} active rate plans`, ratePlanList); } // Verify currency if (activeRatePlans[0] && !formConfigAs(form).dynamicOffer?.id && getRelevantCurrency(form, formState) && ![...Object.values(activeRatePlans[0].ratePlanCharges ?? {})] .every(charge => charge?.currency === getRelevantCurrency(form, formState))) { console.log(`Subscription ${subscription.id} is not in the form currency`); return null; } const amount = formatZuoraSubscriptionAmount(form, subscription); return { // Start with only custom fields from the raw subscription (those ending with "__c") ...extractCustomFields(subscription), // Override with our specific mappings externalId: subscription.id, accountId: subscription.accountId, productId: subscription['SubscriptionExperienceProductID__c'], productLabel: activeRatePlans[0]?.productName, planId: activeRatePlans[0]?.productRatePlanId, planLabel: null, currency: activeRatePlans[0]?.ratePlanCharges[0]?.currency, status: resolveSubscriptionStatus(subscription.status, subscription.termEndDate), amount, autoRenew: subscription?.autoRenew, billToContact: subscription.billToContact, termType: subscription.termType, ...(isGiftSubscriptions ? { recipientFirstName: subscription.soldToContact?.firstName, recipientLastName: subscription.soldToContact?.lastName, recipientEmail: subscription.soldToContact?.personalEmail, subscriptionStartDate: subscription.subscriptionStartDate, subscriptionEndDate: subscription.termEndDate, subscriptionType: subscription?.ratePlans[0]?.productName, subscriptionNumber: subscription.subscriptionNumber, } : {}) }; }) .filter(existingSubscription => existingSubscription && existingSubscription.planId != null && existingSubscription.productId != null)); return deduplicateSubscriptions(regularSubscriptions, giftSubscriptions); }; const calculateZuoraSubscriptionProrate = (form, formState, formActions) => { const changingFromSubscription = formState .validChangeFromPlans .find(plan => formState.paymentOption.slug === plan.planSlug && formState.paymentOption.productId === plan.productId) ?.changesFromSubscription; if (!changingFromSubscription) { console.error("No valid change from subscription"); return; } return request(`plugins/public/zuora-billing/subscription-change-preview`, { method: 'POST', bodyObject: { subscriptionId: changingFromSubscription.externalId, newProductRatePlanId: formState.paymentOption.slug, currency: getRelevantCurrency(form, formState), ...(formState.dynamicOfferResult ? { dynamicOfferResult: JSON.stringify(formState.dynamicOfferResult), productId: formState.paymentOption.productId } : {}), } }, formActions) .then(response => response.json()) .then(preview => { return { totalPrice: preview.amount, totalPriceFormattedString: formatCurrency(preview.amount, getRelevantCurrency(form, formState)), subTotalPrice: preview.amountWithoutTax, subTotalPriceFormattedString: formatCurrency(preview.amountWithoutTax, getRelevantCurrency(form, formState)), }; }); }; const stripePriceCalculator = (form, formState, formActions) => { // Fallback to the generic price calculator if there is no billing address if (!form.organisationConfiguration.stripeAutomaticTaxEnabled || formState.billingAddress.country == null) { return calculateBraintreeStripePrice(form, formState); } return fetchStripeTaxPreview(formState, formActions) .then((taxPreview) => { if (!taxPreview.total) { return calculateBraintreeStripePrice(form, formState); } const currencyMultiplier = isZeroDecimalCurrency(formState.paymentOption.currencyCode.toUpperCase()) ? 1 : 0.01; const currencyFormatter = (value) => formatCurrency(value * currencyMultiplier, formState.paymentOption.currencyCode); return { slug: formState.paymentOption.slug, productId: formState.paymentOption.productId, promoCode: formState.promoCode, billingAddress: formState.billingAddress, addonPrices: [], totalPrice: taxPreview.total * currencyMultiplier, totalPriceFormattedString: currencyFormatter(taxPreview.total), netPrice: taxPreview.sub_total * currencyMultiplier, netPriceFormattedString: currencyFormatter(taxPreview.sub_total), taxPrice: taxPreview.tax ? taxPreview.tax * currencyMultiplier : null, taxPriceFormattedString: taxPreview.tax ? currencyFormatter(taxPreview.tax) : null, discountPrice: taxPreview.discount ? taxPreview.discount * currencyMultiplier : null, discountPriceFormattedPrice: taxPreview.discount ? currencyFormatter(taxPreview.discount) : null, chargeItems: [], }; }) .catch((error) => { console.error(`Error calculating stripe tax preview ${JSON.stringify(error)}`); return calculateBraintreeStripePrice(form, formState); }); }; const fetchStripeTaxPreview = (formState, formActions) => { return request('zephr/payment/stripe/create-subscription-previews', { method: 'POST', bodyObject: { product_id: formState.paymentOption.productId, plan_id: formState.paymentOption.slug, billing_country: formState.billingAddress.country, billing_post_code: formState.billingAddress.postalCode, promo_code: formState.promoCodeValid ? formState.promoCode : undefined, }, }, formActions, null, true).then((response) => response.json()); }; const verifyingPromoCodeBusyKey$1 = "promo-code"; const checkDoPromoCode = async (form, formState, formActions) => { if (form.environment.previewMode) { return; } const dynamicOfferId = formConfigAs(form).dynamicOffer?.id; if (!dynamicOfferId) { throw Error('Missing Dynamic Offer id'); } let session; try { session = document.cookie.match(/blaize_session=[0-9a-z-]+/)[0].substring(15); } catch { session = null; } const doProducts = formState?.dynamicOfferResult?.products ?? []; const promoProducts = doProducts.flatMap(p => p.paymentPlans.map(plan => ({ id: p.id, payment_plan: { "provider": "zuora-billing", "plan_id": plan.planId, charges: plan.charges.map(c => ({ "charge_definition_id": c.chargeDefinitionData.productChargeDefinitionId, "currency": c.prices[0]?.currency, "price": c.prices[0].price })) } }))); const response = await request('zephr/public/decisions/v1/promo-codes', { method: "POST", bodyObject: { "promo_code": formState.promoCode, "session": session, "selected_products": promoProducts }, }, formActions, verifyingPromoCodeBusyKey$1); if (!response.ok) { logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PROMO_CODE_INVALID_ERROR], }); return Promise.resolve(formActions.updateFormState({ promoCodeValid: false, serverErrors: [ServerError.PROMO_CODE_INVALID_ERROR], discountedPlanPrices: [] })); } const json = await response.json(); const matchingProduct = json?.products?.find(p => p.id === formState.paymentOption.productId && p.paymentPlans.some(plan => plan.planId === formState.paymentOption.slug)); if (!matchingProduct) { logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PROMO_CODE_INVALID_ERROR], }); return Promise.resolve(formActions.updateFormState({ promoCodeValid: false, serverErrors: [ServerError.PROMO_CODE_INVALID_ERROR], discountedPlanPrices: [] })); } const updatedState = formActions.updateFormState({ promoCodeValid: true, serverErrors: [], discountedPlanPrices: [], originalDynamicOfferResult: formState.dynamicOfferResult, dynamicOfferResult: { ...formState.dynamicOfferResult, ...json } }); await calculatePrices(form, updatedState, formActions); }; const zuoraDoPromoCodeService = async (form, formState, formActions) => checkDoPromoCode(form, formState, formActions); /* src/components/elements/payment/zuora/ZuoraDynamicFormPreLoader.svelte generated by Svelte v4.2.12 */ function create_fragment$Y(ctx) { let script; let script_src_value; return { c() { script = element("script"); script.innerHTML = ``; attr(script, "type", "text/javascript"); if (!src_url_equal(script.src, script_src_value = "https://js.zuora.com/payment/1.4.0/zuora.js")) attr(script, "src", script_src_value); attr(script, "onload", "window.zuoraLoadCallback()"); }, m(target, anchor) { append(document.head, script); }, p: noop, i: noop, o: noop, d(detaching) { detach(script); } }; } function instance$X($$self, $$props, $$invalidate) { let { onMountCallback } = $$props; onMount(onMountCallback); $$self.$$set = $$props => { if ('onMountCallback' in $$props) $$invalidate(0, onMountCallback = $$props.onMountCallback); }; return [onMountCallback]; } class ZuoraDynamicFormPreLoader extends SvelteComponent { constructor(options) { super(); init(this, options, instance$X, create_fragment$Y, safe_not_equal, { onMountCallback: 0 }); } } const paymentProviderConfigurations = { [paymentProviders.BRAINTREE]: { loader: loadBraintreeUi, preLoader: null, completer: braintreePay, changePaymentCompleter: braintreeChangePayment, component: BraintreePayment, preLoaderComponent: null, promoCodeCheckPath: 'blaize/payment/braintree/promo-code-check', productAddonPath: 'blaize/payment/braintree/addons-check', existingSubscriptionLoader: loadBraintreeStripeSubscriptions, priceCalculator: calculateBraintreeStripePrice, hasProductAddons: true, hasPromoCodes: () => true, internalSubmit: () => false, noPaymentForm: (form, formState) => false, canAttemptIncompletePaymentFormSubmission: false, }, [paymentProviders.STRIPE]: { loader: loadStripeUi, preLoader: null, completer: stripePay, changePaymentCompleter: stripeChangePayment, component: StripePayment, preLoaderComponent: null, promoCodeCheckPath: 'zephr/payment/stripe/promo-code-check', existingSubscriptionLoader: loadBraintreeStripeSubscriptions, priceCalculator: stripePriceCalculator, changeSubscriptionProrateCalculator: calculateStripeSubscriptionProrate, hasProductAddons: false, hasPromoCodes: () => true, internalSubmit: () => false, noPaymentForm: (form, formState) => false, canAttemptIncompletePaymentFormSubmission: true, }, [paymentProviders.ZUORA]: { loader: loadZuoraUi, preLoader: loadZuora, completer: zuoraComplete, changePaymentCompleter: zuoraChangePayment, component: ZuoraPayment, preLoaderComponent: (config) => config?.useDynamicForm ? ZuoraDynamicFormPreLoader : ZuoraPreLoader, promoCodeCheckPath: '', promoCodeServiceOverride: zuoraDoPromoCodeService, priceCalculator: calculateZuoraPrice, existingSubscriptionLoader: loadZuoraSubscriptions, changeSubscriptionProrateCalculator: calculateZuoraSubscriptionProrate, hasProductAddons: false, hasPromoCodes: (form) => formConfigAs(form).dynamicOffer && !formConfigAs(form).changeSubscriptionMode, internalSubmit: (form) => !formConfigAs(form).changeSubscriptionMode, noPaymentForm: (form, formState) => { const config = formConfigAs(form); const isChangeSubscriptionMode = config.changeSubscriptionMode; const requiresPaymentMethodSetup = formState?.requiresPaymentMethodSetup; // Show payment form if we're in payment method setup mode, even during change subscription return isChangeSubscriptionMode && !requiresPaymentMethodSetup; }, canAttemptIncompletePaymentFormSubmission: false, } }; const mobilePaymentServiceConfigurations = { [paymentProviders.BRAINTREE]: { loader: configureBraintreeMobilePayments, completer: braintreePayWithMobile, component: BraintreeMobilePayment, previewMode: (form) => form.environment.previewMode, }, [paymentProviders.STRIPE]: { loader: configureStripeMobilePay, completer: stripePay, component: StripeMobilePayment, previewMode: (form) => form.environment.previewMode, }, }; const paymentProviderFor = (providerName) => { const configuration = paymentProviderConfigurations[providerName]; if (!configuration) { throw `Payment provider ${providerName} not configured.`; } return configuration; }; const supportsMobilePayments = (providerName) => { return !!mobilePaymentServiceConfigurations[providerName]; }; const mobilePaymentServiceFor = (providerName) => { const configuration = mobilePaymentServiceConfigurations[providerName]; if (!configuration) { throw `Mobile payment provider ${providerName} not configured.`; } return configuration; }; const factory$s = { matches: (sectionElement) => sectionElement.type === elementTypes.BUTTON && !sectionElement.config.isLogin && !sectionElement.config.isCancel, create: (form, formState, formActions, elementConfig) => { const isSubmitButton = elementConfig.isSubmit === true; const inChangePaymentSection = formState.currentSection?.type === sectionTypes.CHANGE_PAYMENT.type; const providerHandlesSubmit = inChangePaymentSection && isSubmitButton ? paymentProviderFor(form.organisationConfiguration.paymentProvider).internalSubmit(form) : false; const handleClick = () => { if (providerHandlesSubmit) { return; } logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.attemptCompleteSection(); }; return { component: Button, props: { disabled: formState.isBusy || !formState.canAttemptSectionCompletion || providerHandlesSubmit, text: elementConfig.text, onClick: handleClick, isPaymentForm: form.formType === FormType.PAYMENT, hidden: providerHandlesSubmit, } }; } }; /** * Permissive email check: requires exactly one '@' with at least one non-space character * on each side. Does not validate full email syntax (e.g., dots, domain rules), * just catches obvious typos like spaces or missing parts. * Front-end email validation should be lightweight. * @param email */ const isValidEmail = (email) => { if (!email) return false; return /^[^\s@]+@[^\s@]+$/.test(email); }; const updateElementValidity = (component, formState, sectionElement, formActions) => { if (component?.isValid !== undefined) { const validity = { partType: formState.currentPart.type, sectionType: formState.currentSection.type, sectionOrder: formState.currentSection.order, elementType: sectionElement.type, elementOrder: sectionElement.order, isValid: component.isValid, elementId: sectionElement.config?.slug, }; const existingValidity = formState.elementValidity.find((other) => other.partType === validity.partType && other.sectionType === validity.sectionType && other.sectionOrder === validity.sectionOrder && other.elementType === validity.elementType && other.elementOrder === validity.elementOrder); if (existingValidity?.isValid !== validity.isValid) { formActions.updateFormState({ elementValidity: [ ...formState.elementValidity.filter((v) => v != existingValidity), validity, ], }); } } }; /* src/components/elements/email/EmailAddress.svelte generated by Svelte v4.2.12 */ function create_fragment$X(ctx) { let label_1; let t; let div; let input; let current; label_1 = new Label({ props: { forInput: /*id*/ ctx[11], label: /*label*/ ctx[2], isPaymentForm: /*isPaymentForm*/ ctx[6] } }); input = new Input({ props: { id: /*id*/ ctx[11], autocomplete: "email", type: "email", name: "email", disabled: /*disabled*/ ctx[1], value: /*emailAddress*/ ctx[0], placeholder: /*placeholder*/ ctx[3], errorMessage: /*error*/ ctx[5], innerTextOnClick: /*onEdit*/ ctx[7], innerText: /*onEdit*/ ctx[7] && (/*editText*/ ctx[4] || 'Edit'), isPaymentForm: /*isPaymentForm*/ ctx[6], onFocus: /*onFocus*/ ctx[9], onBlur: /*onBlur*/ ctx[10] } }); input.$on("change", /*change_handler*/ ctx[13]); return { c() { create_component(label_1.$$.fragment); t = space(); div = element("div"); create_component(input.$$.fragment); attr(div, "class", "zephr-form-relative-container"); toggle_class(div, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[6]); }, m(target, anchor) { mount_component(label_1, target, anchor); insert(target, t, anchor); insert(target, div, anchor); mount_component(input, div, null); current = true; }, p(ctx, [dirty]) { const label_1_changes = {}; if (dirty & /*label*/ 4) label_1_changes.label = /*label*/ ctx[2]; if (dirty & /*isPaymentForm*/ 64) label_1_changes.isPaymentForm = /*isPaymentForm*/ ctx[6]; label_1.$set(label_1_changes); const input_changes = {}; if (dirty & /*disabled*/ 2) input_changes.disabled = /*disabled*/ ctx[1]; if (dirty & /*emailAddress*/ 1) input_changes.value = /*emailAddress*/ ctx[0]; if (dirty & /*placeholder*/ 8) input_changes.placeholder = /*placeholder*/ ctx[3]; if (dirty & /*error*/ 32) input_changes.errorMessage = /*error*/ ctx[5]; if (dirty & /*onEdit*/ 128) input_changes.innerTextOnClick = /*onEdit*/ ctx[7]; if (dirty & /*onEdit, editText*/ 144) input_changes.innerText = /*onEdit*/ ctx[7] && (/*editText*/ ctx[4] || 'Edit'); if (dirty & /*isPaymentForm*/ 64) input_changes.isPaymentForm = /*isPaymentForm*/ ctx[6]; if (dirty & /*onFocus*/ 512) input_changes.onFocus = /*onFocus*/ ctx[9]; if (dirty & /*onBlur*/ 1024) input_changes.onBlur = /*onBlur*/ ctx[10]; input.$set(input_changes); if (!current || dirty & /*isPaymentForm*/ 64) { toggle_class(div, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[6]); } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(input.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t); detach(div); } destroy_component(label_1, detaching); destroy_component(input); } }; } function instance$W($$self, $$props, $$invalidate) { let { formKey } = $$props; let { emailAddress } = $$props; let { disabled } = $$props; let { label } = $$props; let { placeholder } = $$props; let { editText } = $$props; let { error = null } = $$props; let { isPaymentForm = false } = $$props; let { onEdit } = $$props; let { onChange } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; const id = `zephr-form-identifier-${formKey}`; const change_handler = ({ detail }) => onChange(detail); $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(12, formKey = $$props.formKey); if ('emailAddress' in $$props) $$invalidate(0, emailAddress = $$props.emailAddress); if ('disabled' in $$props) $$invalidate(1, disabled = $$props.disabled); if ('label' in $$props) $$invalidate(2, label = $$props.label); if ('placeholder' in $$props) $$invalidate(3, placeholder = $$props.placeholder); if ('editText' in $$props) $$invalidate(4, editText = $$props.editText); if ('error' in $$props) $$invalidate(5, error = $$props.error); if ('isPaymentForm' in $$props) $$invalidate(6, isPaymentForm = $$props.isPaymentForm); if ('onEdit' in $$props) $$invalidate(7, onEdit = $$props.onEdit); if ('onChange' in $$props) $$invalidate(8, onChange = $$props.onChange); if ('onFocus' in $$props) $$invalidate(9, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(10, onBlur = $$props.onBlur); }; return [ emailAddress, disabled, label, placeholder, editText, error, isPaymentForm, onEdit, onChange, onFocus, onBlur, id, formKey, change_handler ]; } class EmailAddress extends SvelteComponent { constructor(options) { super(); init(this, options, instance$W, create_fragment$X, safe_not_equal, { formKey: 12, emailAddress: 0, disabled: 1, label: 2, placeholder: 3, editText: 4, error: 5, isPaymentForm: 6, onEdit: 7, onChange: 8, onFocus: 9, onBlur: 10 }); } } const factory$r = { matches: (sectionElement) => sectionElement.type === elementTypes.EMAIL_ADDRESS, create: (form, formState, formActions, elementConfig) => { const disabled = elementConfig.disabled || formState.isBusy; return ({ component: EmailAddress, props: { formKey: form.uniqueKey, disabled, emailAddress: formState.emailAddress, label: elementConfig.label, placeholder: elementConfig.placeholder, editText: elementConfig.editText, onChange: (value) => { !disabled && formActions.updateFormState({ userExists: undefined, emailIsContact: undefined, emailAddress: value, verificationCode: "", verificationCodeValid: undefined, serverErrors: [] }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: `zephr-form-identifier-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'email' }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: `zephr-form-identifier-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'email' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: `zephr-form-identifier-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'email' }), onEdit: elementConfig.disabled && (() => { formActions.jumpToPartStart(partTypes.ACCOUNT_VERIFICATION.type); }), isPaymentForm: form.formType === FormType.PAYMENT, }, isValid: isValidEmail(formState.emailAddress) }); } }; /* src/components/elements/payment/EmptyPayment.svelte generated by Svelte v4.2.12 */ function create_fragment$W(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*providerError*/ ctx[0]?.message ?? /*error*/ ctx[1] ?? "", isPaymentForm: true } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, [dirty]) { const errormessage_changes = {}; if (dirty & /*providerError, error*/ 3) errormessage_changes.error = /*providerError*/ ctx[0]?.message ?? /*error*/ ctx[1] ?? ""; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function instance$V($$self, $$props, $$invalidate) { let { providerError } = $$props; let { error = null } = $$props; $$self.$$set = $$props => { if ('providerError' in $$props) $$invalidate(0, providerError = $$props.providerError); if ('error' in $$props) $$invalidate(1, error = $$props.error); }; return [providerError, error]; } class EmptyPayment extends SvelteComponent { constructor(options) { super(); init(this, options, instance$V, create_fragment$W, safe_not_equal, { providerError: 0, error: 1 }); } } const factory$q = { matches: (sectionElement) => sectionElement.type === elementTypes.PAYMENT || sectionElement.type === elementTypes.CHNAGE_PAYMENT_METHOD, create: (form, formState, formActions) => { const paymentProvider = paymentProviderFor(form.organisationConfiguration.paymentProvider); if (paymentProvider.noPaymentForm(form, formState)) { return { component: EmptyPayment, props: { providerError: formState.paymentProviderError, }, isValid: true }; } return { component: paymentProvider.component, props: { isLoaded: formState.paymentProviderFormLoaded, isBusy: formState.paymentProviderFormBusy, providerError: formState.paymentProviderError, isComplete: formState.paymentFormComplete, isDisabled: paymentProvider.internalSubmit(form) ? !formState.canAttemptSectionCompletion : (formState.isBusy || formState.mobilePaymentService != null), formKey: form.uniqueKey, onMountCallback: () => { formActions.updateFormState({ paymentProviderFormLoaded: false }); void paymentProvider.loader(form, formState, formActions); } }, isValid: paymentProvider.internalSubmit(form) ? undefined : formState.paymentFormComplete && !formState.paymentProviderError }; } }; const regularPaymentElementIsPresent = form => form.parts.flatMap(part => part.sections) .flatMap(section => section.elements) .some(element => element.type === elementTypes.PAYMENT && element.config?.enabled !== false); const factory$p = { matches: (sectionElement) => sectionElement.type === elementTypes.MOBILE_PAYMENT, create: (form, formState, formActions) => { if (form.environment.previewMode) { return null; } // Check if the payment provider supports mobile payments if (!supportsMobilePayments(form.organisationConfiguration.paymentProvider)) { return null; } const paymentProvider = mobilePaymentServiceFor(form.organisationConfiguration.paymentProvider); return { component: paymentProvider.component, props: { isDisabled: formState.isBusy || formState.mobilePaymentService != null, onMountCallback: () => paymentProvider.loader(form, formState, formActions), // Minor-hack to prevent injecting the payment provider lib twice disableCoreDependencyHeader: regularPaymentElementIsPresent(form) } }; } }; /* src/components/elements/Checkbox.svelte generated by Svelte v4.2.12 */ function create_fragment$V(ctx) { let input; let t0; let label_1; let div; let t1; let t2; let mounted; let dispose; let input_levels = [ { id: /*id*/ ctx[0] }, { name: /*name*/ ctx[1] }, { required: /*required*/ ctx[2] }, { disabled: /*disabled*/ ctx[3] }, /*conditionalProps*/ ctx[8], { type: "checkbox" }, { class: "zephr-form-checkbox" } ]; let input_data = {}; for (let i = 0; i { dispatch("change", e.target.checked); }; $$self.$$set = $$props => { if ('id' in $$props) $$invalidate(0, id = $$props.id); if ('name' in $$props) $$invalidate(1, name = $$props.name); if ('required' in $$props) $$invalidate(2, required = $$props.required); if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); if ('hasError' in $$props) $$invalidate(4, hasError = $$props.hasError); if ('isPaymentForm' in $$props) $$invalidate(5, isPaymentForm = $$props.isPaymentForm); if ('label' in $$props) $$invalidate(6, label = $$props.label); if ('value' in $$props) $$invalidate(10, value = $$props.value); if ('placeholder' in $$props) $$invalidate(11, placeholder = $$props.placeholder); if ('checked' in $$props) $$invalidate(7, checked = $$props.checked); if ('pattern' in $$props) $$invalidate(12, pattern = $$props.pattern); }; return [ id, name, required, disabled, hasError, isPaymentForm, label, checked, conditionalProps, handleInputChange, value, placeholder, pattern ]; } class Checkbox extends SvelteComponent { constructor(options) { super(); init(this, options, instance$U, create_fragment$V, safe_not_equal, { id: 0, name: 1, required: 2, disabled: 3, hasError: 4, isPaymentForm: 5, label: 6, value: 10, placeholder: 11, checked: 7, pattern: 12 }); } } /* src/components/elements/payment/PaymentAutoRenewToggle.svelte generated by Svelte v4.2.12 */ function create_if_block$E(ctx) { let div; let checkbox; let current; checkbox = new Checkbox({ props: { id: "payment-auto-renew-toggle-" + /*paymentOption*/ ctx[0].productId + "-" + /*paymentOption*/ ctx[0].slug, name: "payment-auto-renew-toggle", label: /*toggleLabel*/ ctx[3], value: "true", checked: /*checked*/ ctx[1], disabled: /*disabled*/ ctx[2], required: false } }); checkbox.$on("change", /*handleChange*/ ctx[5]); return { c() { div = element("div"); create_component(checkbox.$$.fragment); attr(div, "class", "zephr-form-payment-auto-renew-toggle svelte-1yfwddr"); }, m(target, anchor) { insert(target, div, anchor); mount_component(checkbox, div, null); current = true; }, p(ctx, dirty) { const checkbox_changes = {}; if (dirty & /*paymentOption*/ 1) checkbox_changes.id = "payment-auto-renew-toggle-" + /*paymentOption*/ ctx[0].productId + "-" + /*paymentOption*/ ctx[0].slug; if (dirty & /*toggleLabel*/ 8) checkbox_changes.label = /*toggleLabel*/ ctx[3]; if (dirty & /*checked*/ 2) checkbox_changes.checked = /*checked*/ ctx[1]; if (dirty & /*disabled*/ 4) checkbox_changes.disabled = /*disabled*/ ctx[2]; checkbox.$set(checkbox_changes); }, i(local) { if (current) return; transition_in(checkbox.$$.fragment, local); current = true; }, o(local) { transition_out(checkbox.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(checkbox); } }; } function create_fragment$U(ctx) { let if_block_anchor; let current; let if_block = /*shouldShow*/ ctx[4] && create_if_block$E(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { if (/*shouldShow*/ ctx[4]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*shouldShow*/ 16) { transition_in(if_block, 1); } } else { if_block = create_if_block$E(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$T($$self, $$props, $$invalidate) { let shouldShow; let toggleLabel; let { paymentOption } = $$props; let { checked = false } = $$props; let { disabled = false } = $$props; let { onChange } = $$props; const handleChange = event => { const isChecked = event.detail; onChange(isChecked); }; $$self.$$set = $$props => { if ('paymentOption' in $$props) $$invalidate(0, paymentOption = $$props.paymentOption); if ('checked' in $$props) $$invalidate(1, checked = $$props.checked); if ('disabled' in $$props) $$invalidate(2, disabled = $$props.disabled); if ('onChange' in $$props) $$invalidate(6, onChange = $$props.onChange); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*paymentOption*/ 1) { // Only show if the payment option is configured for custom toggle $$invalidate(4, shouldShow = paymentOption?.autoRenewConfig === 'custom_toggle' && paymentOption.type !== 'ONE_OFF'); } if ($$self.$$.dirty & /*paymentOption*/ 1) { $$invalidate(3, toggleLabel = paymentOption?.autoRenewToggleLabel || 'Auto-renew subscription'); } }; return [ paymentOption, checked, disabled, toggleLabel, shouldShow, handleChange, onChange ]; } class PaymentAutoRenewToggle extends SvelteComponent { constructor(options) { super(); init(this, options, instance$T, create_fragment$U, safe_not_equal, { paymentOption: 0, checked: 1, disabled: 2, onChange: 6 }); } } const paymentAutoRenewToggleFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.PAYMENT_AUTO_RENEW_TOGGLE, create: (form, formState, formActions) => { // Only show for Zuora billing payment forms if (form.organisationConfiguration.paymentProvider !== 'zuora-billing') { return null; } // Only show if there's a selected payment option if (!formState.paymentOption) { return null; } // Only show if the payment option is configured for custom toggle if (formState.paymentOption.autoRenewConfig !== 'custom_toggle') { return null; } // Don't show for one-off purchases if (formState.paymentOption.type === 'ONE_OFF') { return null; } const paymentOptionKey = `${formState.paymentOption.productId}-${formState.paymentOption.slug}`; const handleToggleChange = (isChecked) => { // Update the payment option specific autoRenew state const updatedAutoRenewState = { ...formState.paymentOptionAutoRenew, [paymentOptionKey]: isChecked }; formActions.updateFormState({ paymentOptionAutoRenew: updatedAutoRenewState }); logDataLayerEvent(form, 'zephr_form_input_change', { field: 'payment-auto-renew-toggle', inputName: `payment-auto-renew-toggle-${formState.paymentOption.productId}-${formState.paymentOption.slug}`, sectionId: formState.currentSection.type, }); }; // Get the current checked state for this payment option // State is now properly initialized when payment option is selected const checkedState = formState.paymentOptionAutoRenew?.[paymentOptionKey] ?? false; return { component: PaymentAutoRenewToggle, props: { paymentOption: formState.paymentOption, checked: checkedState, disabled: formState.isBusy || formState.paymentProviderFormBusy || false, onChange: handleToggleChange, }, isValid: true, }; }, }; var checkMarkImageBase64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGEAAABiCAYAAABAkr0NAAAJa0lEQVR4Xu2dT28TRxTA39oGUsHBiC/giKT/LiRHpBYIUPWQEmfVD9BwrQoJpZW4JbkhtRUO9E74AO3GQTkVCLSVOGIurVRCky/QkgNIodjezoxjsrZ3Zt7Mzu7OOraEkOLZ9Zv3m3lv/rx540BWPtc2S1Cvl6DplJjITb/1f/CTc7bAgW1w/G0oFLbg+vBWFqrnWCfkwmYRXtbH4HVuDPJwwp24MBNFRu9BtUbAERjOIzjUrMH3ow+jvC+OZ+2AQFv5q+Y0gF92z0+diaOiwXd691YJCKcKh3MrNvSW9CDQFv9Pk7TyZBTPA8t6iuMswVD+YVpAkofwzbMzUPdn3InpL+Ju8arv99bvLsNQbjFpGMlBoMp/7cwnYW5Uld9dnpmrQ/5iUv4jfgjfbo7BTuOGKeUzBeWpow35NPwi+WsRcn7RPVseiwwjoZ4RHwRq87fr8+5EeU5HGS1lw1PIE1t9AGpaJoI2gCaUoEFGWw3ntG5D8NarFRgqLGnJgKh8PBCI6XE/Lq8jfr+jiLe+ugQFfwWOFGqwMLyt+jyqfASfROS7CJWRZdTvKBQyC0Gj9Sdtfzt0c3VzGhpvplUGCaxXFAuLJhuJOQhkrO+enNzENgBSmUVSmYrJymB/u6fctT9LsJNfUILxeG3YlHkyA+HqxrR7asrDKMEq5XcLrAjD+3XVhR9GVjD1FpWJDuHy83n33IUFmSDM7Bx+cxGufxA+spG9IMnvFWB49+8uwM3ji1HEiwYBC8BQi4lSUa1nv96YcU9P3ZY9GxWEPgQEANb6j+VdK+y+TJO875G9IgoIPQgoAHevwK3jFd26W/fc3DPiuMvzIrl0QahDwAD4rTqR1JQ/UViI+Y8OCDUIlzdn3XOTwtbtPf6JDN0y4Hx16RHz5J78XDgU9+79TKzA+2grgIdAlgDcjyafCLtjvwNoVx4D4ve1cfhuuIZhjYOAmIj1fQ8ImVNIewRyQoeDcGljXbT4te8AIHsEGx3eGpmQ9QY5BIkj9hS6nUyYTH4vMdMY/yCGIDFD3r0+G4bqtgLJpM6TmCUxhNlnT3ibI2wNqDIqXa7QrVfmnpt7XiGRIbNhcsvMEh+CjG75D7kpy5wmIwhMl/Ff1Nf5jZa/F8FVpFv90OeJtG8dsYyRzD88WTsatoQTDkHgjAdmSEJCsLzB010vBJkzHpghMQViltzxyRdcKxLSG3ohCHxBXHussl6eue/Jtql7ajJ0kyusN/RAEPqCQS/AtwfBBNfr0mMnhEEvwCtZVlKw4ur9QrZFf9zbFu2EoEBPJsPge6IBjj675w17EAQOeeALNJvUpedz7vkLN0IncAEHvQdB9MB+8AU0PH+IHDAxGXQmGCkFHfQehNm/yRLFZz3xmyxSuXL8omZbsP+xrgmWzs6YsJKc5YygSWpBEJmift2qpPXmzHCNml+Rg941SS0IolFRv5oiwRKDd9+rws33yMkhMx/esL8NuwVh7q/lsBDAvjVFsjUewxBk+m1B4PqDeKKQzbQvzbdg9spNb1RJLI0DIg/ebxv3GADrayT8fXhZE3H4Y4LAAI/4BQdEjqOf/EFaAHaxcP0CGfg4wJkfyHaDjLaUuF+WMgBWvcsbK+65qXJ3VekWsQO8cSw9NVMZ0TrqFLdOld5vAwA2+Anf/qSnkxwRoczHktoCgELgWRwyEiPmKDymyMv6JM0mABTCV2SP4ZPePQbvwUrNETmMzAb12gaAQviShJF+Gh5GyocQ1/A0EFTMUhq8U3BNnf1ivsJGAFQuwTA1WQicSYssOArtiG0FYBUEzjCNyhgZhM0AsgIhEgjbAVgFAXPSBRlO/tZEZQGAVRDYpAVx9gsLIisAtCGYXkkMelcTILIEgNZdYAUc7jJ2V1gGeoSCLRgFRNYACCDQNbp0ly10QGQRgHTZIu0FPBUQWQUgXcATLCyZ3GcVWikMCJKaQZbExItjQwZrXmXluIFgdCnblk0dBAhRPa0GQAQXb+rYtL2pCcJ2AMKQIra9KaIUU7qxqKYp+Lz1AKiwvDUzsowNS++O2xnyguwRmQDAnLI4pMje4C8JiMwAQFiaFgSRX0hzh40DIksAhAOf3T2bQFQ2Z5sz7Q3/LhCZAiAyRbv+gBbZgyA6dcg5+ikbGhv7np4R3iGZf02HrhsTkP8i7tA0kA1hD4LIJA3SJ+jhEoU/BraPUcel+ioQTE+dWk/xe0Fn9pdOCJywDCpB5kNgtNQY4SGFQ5joI7SD3qAGROUocu9hcpGDzmp+UzX9RS+t0As6R0ftn9ZICxBd6v56g2pylvAEIxpJMvpLjRFqo5GcJRyCrDfEuf8cof6pP6qZnEUr6RQLXzxamDB65jd1DUYXQGiGBCvS4uxdojQL9DKHyuiV6KL3yRtEZog22qXRcV5NxRAkSVi9+6szcHPkTp+oUb8akszJskxpYghULEG6BTaJ2+/+QXYcF5GwUQ6BgZAlpzV3tYl+c0zhSZkjNpacltYNkxsaG7qYgq5i+UmDqatxPYHWAhPzs19AYAAomGk8BIR/YD6i30FgACgu/atBoFpGbML37YorJrQf4Yi7zaM6BCwIA7cuxWLLdV+KucBDAwAVRw8CFkRCF4jq6hX1HLs3uuHJ7u2MkrRXHwISBPMTaQSRoTQsKYS8xC8KgGg9oS0/wke0QKRz4bQWC3ZdfeO2rPW36hU9e360ntCuoSAjbrcSrIZBTc+/TXJ5k/wGRQbA0CaXGQhUIsSELgjEKhiKym8Nxc3domUOApWMXQXcJJfChV/mEGYaGIy8XzVxkaiy6dG4sp7dGV3ML5hcxjcLoa0F5J2Voaaq0LwTW04N2kheklvK6w65g3kq9NYPEci45j/xQNg1T7BzcE6lV3SYK3Y9vP8I8k4Ncvkt7J1lHUqkDvZNg1wND2fIvxMYRxveW823/uDvxAeh/SvIC0QxpoTt6DUdem38NoETfn18wy/pKrunZ9KGMJS/otUAMBXaLRM/hLYwGvZXoR5GiyZ9ZX1yEGLoGUY1T0c8dJAQp0/iCJw8hCCM/w4QW+3P8m5kMq3kUHtPTQ44VTiWWzY54lGRPT0IQSmp33h1kKRF9sum7LlwlNNW/OHcitGEVyqaD5S1A0K38Mx/5EgGe/805IijPVvuyWavUl9mZhrwFA41a3CkUEurxfNkthNCmLR0uFmvl8AvFMFvFKHpl3qK5Zwt9recvwWFwpYNrRzTWP4HK7laSxb9gaIAAAAASUVORK5CYII="; /* src/components/elements/successMessage/SuccessMessage.svelte generated by Svelte v4.2.12 */ function create_fragment$T(ctx) { let div1; let img; let img_src_value; let t0; let div0; let t1; return { c() { div1 = element("div"); img = element("img"); t0 = space(); div0 = element("div"); t1 = text(/*text*/ ctx[0]); attr(img, "class", "check-image svelte-w5z6iw"); if (!src_url_equal(img.src, img_src_value = checkMarkImageBase64)) attr(img, "src", img_src_value); attr(img, "alt", "Success indicator"); attr(div0, "class", "zephr-form-success-message svelte-w5z6iw"); toggle_class(div0, "zephr-payment-form-success-message", /*isPaymentForm*/ ctx[1]); }, m(target, anchor) { insert(target, div1, anchor); append(div1, img); append(div1, t0); append(div1, div0); append(div0, t1); }, p(ctx, [dirty]) { if (dirty & /*text*/ 1) set_data(t1, /*text*/ ctx[0]); if (dirty & /*isPaymentForm*/ 2) { toggle_class(div0, "zephr-payment-form-success-message", /*isPaymentForm*/ ctx[1]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div1); } } }; } function instance$S($$self, $$props, $$invalidate) { let { text } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('isPaymentForm' in $$props) $$invalidate(1, isPaymentForm = $$props.isPaymentForm); }; return [text, isPaymentForm]; } class SuccessMessage extends SvelteComponent { constructor(options) { super(); init(this, options, instance$S, create_fragment$T, safe_not_equal, { text: 0, isPaymentForm: 1 }); } } const factory$o = { matches: (sectionElement) => sectionElement.type === elementTypes.SUCCESS_MESSAGE, create: (form, formState, formActions, elementConfig) => ({ component: SuccessMessage, props: { text: elementConfig?.text, isPaymentForm: form.formType === FormType.PAYMENT, } }) }; const createTokenExchangePayload = (action, emailAddress) => { return { identifiers: { email_address: emailAddress, }, delivery: { method: 'email', destination: emailAddress, action, redirect: window.location.href.replace(window.location.origin, ''), }, }; }; const sendLink = async (form, action, emailAddress, formActions) => { try { const response = await request('blaize/token-exchange', { method: 'POST', bodyObject: createTokenExchangePayload(action, emailAddress), }, formActions); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } } catch (err) { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } }; const getFormIsPasswordless = (form) => { return (form.formType === FormType.REGISTRATION && formConfigAs(form).usePassword === false && form.organisationConfiguration.requireEmailVerfication === true && formConfigAs(form).useVerificationCodes === false); }; const onEmailEntered = async (form, formState, formActions) => { return getUserInfo(formState, formActions) .then(async (response) => { if (response.redirected) { window.location.replace(response.url); return; } else { const existsInAnyState = response.status === 200; const formCanOtp = form.parts.flatMap(p => p.sections) .some(s => s.type === sectionTypes.VERIFICATION_CODE_REGISTRATION.type); const isContact = existsInAnyState ? ((await response.json()).contact) && formCanOtp : false; const exists = existsInAnyState && !isContact; formActions.updateFormState({ userExists: exists, emailIsContact: isContact, }); const isPasswordless = getFormIsPasswordless(form); if (isPasswordless) { if (exists) { void sendLink(form, 'login', formState.emailAddress, formActions); return jumpToSection(sectionTypes.PASSWORDLESS_VIA_LOGIN_LINK.type, form, formActions); } else { return moveToNextSection(form, formState, formActions); } } const needsVerificationCode = isContact || formConfigAs(form).useVerificationCodes || form.organisationConfiguration.twoFactorEmailAuthenticationEnabled; if (needsVerificationCode) { void send2FaCode(form, formState, formActions); } if (form.organisationConfiguration.recaptchaV2Enabled) { return jumpToSection(sectionTypes.RECAPTCHA.type, form, formActions); } if (needsVerificationCode) { return jumpToSection(exists ? sectionTypes.VERIFICATION_CODE_LOGIN.type : sectionTypes.VERIFICATION_CODE_REGISTRATION.type, form, formActions); } return jumpToSection(exists ? sectionTypes.LOGIN_PASSWORD.type : sectionTypes.PASSWORD_SETUP.type, form, formActions); } }); }; const twoFactorPayload = (formState) => ({ identifiers: { email_address: formState.emailAddress }, delivery: { method: "email", destination: formState.emailAddress, action: formState.userExists ? "login" : "register", redirect: window.location.href.replace(window.location.origin, ""), } }); const send2FaCode = async (form, formState, formActions) => { formActions.updateFormState({ verificationCode: "", verificationCodeValid: undefined }); const response = await request('blaize/two-factor-authentication', { method: "POST", bodyObject: twoFactorPayload(formState) }, formActions); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.VERIFICATION_CODE_SEND_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); } return response.ok; }; const getUserInfo = async (formState, formActions) => { formActions.updateFormState({ password: "", verificationCode: undefined, verificationCodeValid: undefined, forgotPassword: false, recaptchaCompleted: false, recaptchaToken: undefined, }); return await request('zephr/media/user/info', { method: "POST", bodyObject: { identifiers: { email_address: formState.emailAddress } } }, formActions); }; const verifyOtp = async (form, formState, formActions) => { const response = await request('zephr/media/user/otp-check', { method: "POST", bodyObject: { code: formState.verificationCode, email: formState.emailAddress } }, formActions); if (!response.ok) { formActions.updateFormState({ verificationCodeValid: false, serverErrors: [ServerError.VERIFICATION_CODE_INCORRECT] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.VERIFICATION_CODE_INCORRECT], }); return; } formActions.updateFormState({ verificationCodeValid: false, serverErrors: [] }); formActions.completeSection(); }; const postVerificationCodeDelaySeconds = 1.5; const waitAfterCode = async (form) => await new Promise(r => setTimeout(r, form.environment.reduceDelays ? 1 : (postVerificationCodeDelaySeconds * 1000))); const verifiyPasswordResetCode = async (form, formState, formActions) => { formActions.incrementRequestCount(); formActions.updateFormState({ verificationCodeValid: undefined }); const response = await request(`zephr/users/reset/${formState.verificationCode}`, { method: "POST", bodyObject: { identifiers: { email_address: formState.emailAddress, }, } }, formActions); logDataLayerEvent(form, 'zephr_form_password_reset_code_validate', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.VERIFICATION_CODE_INCORRECT] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.VERIFICATION_CODE_INCORRECT], }); formActions.decrementRequestCount(); return Promise.resolve(); } return waitAfterCode(form) .then(() => { formActions.decrementRequestCount(); formActions.jumpToSection(sectionTypes.PASSWORD_RESET.type); }); }; const sendPasswordResetCode = async (form, formState, formActions) => { formActions.updateFormState({ createPassword: "", confirmCreatePassword: "", forgotPassword: true, verificationCode: "", }); formActions.incrementRequestCount(); const response = await request('zephr/users/reset', { method: "POST", bodyObject: { identifiers: { email_address: formState.emailAddress, }, } }, formActions); logDataLayerEvent(form, 'zephr_form_password_reset_code_sent', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.PASSWORD_RESET_LINK_SEND_ERROR] }); formActions.decrementRequestCount(); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PASSWORD_RESET_LINK_SEND_ERROR], }); return Promise.resolve(); } return waitAfterCode(form) .then(() => { formActions.decrementRequestCount(); formActions.jumpToSection(sectionTypes.FORGOT_PASSWORD.type); }); }; const resetPassword = async (form, formState, formActions) => { const response = await request(`zephr/users/reset/${formState.verificationCode}`, { method: "POST", bodyObject: { identifiers: { email_address: formState.emailAddress, }, validators: { password: formState.createPassword } } }, formActions); logDataLayerEvent(form, 'zephr_form_password_reset', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.PASSWORD_RESET_ERROR] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.MOBILE_PAYMENT_PROCESSING_ERROR], }); return Promise.resolve(); } formActions.updateFormState({ verificationCode: "", forgotPassword: false }); return formActions.jumpToPartStart(partTypes.ACCOUNT_VERIFICATION.type); }; /* src/components/elements/verificationCode/VerificationCode.svelte generated by Svelte v4.2.12 */ function create_if_block_2$i(ctx) { let if_block_anchor; function select_block_type(ctx, dirty) { if (/*showMessage*/ ctx[14] && !/*error*/ ctx[5]) return create_if_block_3$c; return create_else_block$9; } let current_block_type = select_block_type(ctx); let if_block = current_block_type(ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, dirty) { if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) { if_block.p(ctx, dirty); } else { if_block.d(1); if_block = current_block_type(ctx); if (if_block) { if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } }, d(detaching) { if (detaching) { detach(if_block_anchor); } if_block.d(detaching); } }; } // (53:6) {:else} function create_else_block$9(ctx) { let button; let t; let mounted; let dispose; return { c() { button = element("button"); t = text(/*resendText*/ ctx[3]); attr(button, "class", "zephr-form-verification-resend-link svelte-1yj9ceh"); toggle_class(button, "zephr-payment-form-verification-resend-link", /*isPaymentForm*/ ctx[9]); }, m(target, anchor) { insert(target, button, anchor); append(button, t); if (!mounted) { dispose = listen(button, "click", /*click_handler*/ ctx[15]); mounted = true; } }, p(ctx, dirty) { if (dirty & /*resendText*/ 8) set_data(t, /*resendText*/ ctx[3]); if (dirty & /*isPaymentForm*/ 512) { toggle_class(button, "zephr-payment-form-verification-resend-link", /*isPaymentForm*/ ctx[9]); } }, d(detaching) { if (detaching) { detach(button); } mounted = false; dispose(); } }; } // (46:6) {#if showMessage && !error} function create_if_block_3$c(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*resendMessage*/ ctx[2]); attr(div, "class", "zephr-form-verification-resend-text svelte-1yj9ceh"); toggle_class(div, "zephr-payment-form-verification-resend-text", /*isPaymentForm*/ ctx[9]); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*resendMessage*/ 4) set_data(t, /*resendMessage*/ ctx[2]); if (dirty & /*isPaymentForm*/ 512) { toggle_class(div, "zephr-payment-form-verification-resend-text", /*isPaymentForm*/ ctx[9]); } }, d(detaching) { if (detaching) { detach(div); } } }; } // (32:2) !disabled && onChange(detail)} onFocus={onFocus} onBlur={onBlur} > function create_default_slot$6(ctx) { let if_block_anchor; let if_block = /*resendText*/ ctx[3] && create_if_block_2$i(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, dirty) { if (/*resendText*/ ctx[3]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_2$i(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (74:4) {#if codeValid} function create_if_block_1$t(ctx) { let fa; let current; fa = new Fa({ props: { icon: faCheck } }); return { c() { create_component(fa.$$.fragment); }, m(target, anchor) { mount_component(fa, target, anchor); current = true; }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { destroy_component(fa, detaching); } }; } // (77:4) {#if code && !codeValid && formBusy} function create_if_block$D(ctx) { let fa; let current; fa = new Fa({ props: { icon: faSpinner, spin: true } }); return { c() { create_component(fa.$$.fragment); }, m(target, anchor) { mount_component(fa, target, anchor); current = true; }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { destroy_component(fa, detaching); } }; } function create_fragment$S(ctx) { let label_1; let t0; let div1; let input; let t1; let div0; let t2; let current; label_1 = new Label({ props: { forInput: "zephr-form-verification-code", label: /*label*/ ctx[0], isPaymentForm: /*isPaymentForm*/ ctx[9] } }); input = new Input({ props: { id: "zephr-form-verification-code", value: /*code*/ ctx[8], placeholder: /*placeholder*/ ctx[1], maxlength: 6, hasError: /*error*/ ctx[5] != null, errorMessage: /*error*/ ctx[5], isPaymentForm: /*isPaymentForm*/ ctx[9], disabled: /*disabled*/ ctx[4], onFocus: /*onFocus*/ ctx[12], onBlur: /*onBlur*/ ctx[13], $$slots: { default: [create_default_slot$6] }, $$scope: { ctx } } }); input.$on("change", /*change_handler*/ ctx[16]); let if_block0 = /*codeValid*/ ctx[6] && create_if_block_1$t(); let if_block1 = /*code*/ ctx[8] && !/*codeValid*/ ctx[6] && /*formBusy*/ ctx[7] && create_if_block$D(); return { c() { create_component(label_1.$$.fragment); t0 = space(); div1 = element("div"); create_component(input.$$.fragment); t1 = space(); div0 = element("div"); if (if_block0) if_block0.c(); t2 = space(); if (if_block1) if_block1.c(); attr(div0, "class", "zephr-form-input-inner-text"); toggle_class(div0, "zephr-payment-form-input-inner-text", /*isPaymentForm*/ ctx[9]); attr(div1, "class", "zephr-form-relative-container zephr-form-verification-resend-link-container svelte-1yj9ceh"); toggle_class(div1, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[9]); toggle_class(div1, "zephr-payment-form-verification-resend-link-container", /*isPaymentForm*/ ctx[9]); }, m(target, anchor) { mount_component(label_1, target, anchor); insert(target, t0, anchor); insert(target, div1, anchor); mount_component(input, div1, null); append(div1, t1); append(div1, div0); if (if_block0) if_block0.m(div0, null); append(div0, t2); if (if_block1) if_block1.m(div0, null); current = true; }, p(ctx, [dirty]) { const label_1_changes = {}; if (dirty & /*label*/ 1) label_1_changes.label = /*label*/ ctx[0]; if (dirty & /*isPaymentForm*/ 512) label_1_changes.isPaymentForm = /*isPaymentForm*/ ctx[9]; label_1.$set(label_1_changes); const input_changes = {}; if (dirty & /*code*/ 256) input_changes.value = /*code*/ ctx[8]; if (dirty & /*placeholder*/ 2) input_changes.placeholder = /*placeholder*/ ctx[1]; if (dirty & /*error*/ 32) input_changes.hasError = /*error*/ ctx[5] != null; if (dirty & /*error*/ 32) input_changes.errorMessage = /*error*/ ctx[5]; if (dirty & /*isPaymentForm*/ 512) input_changes.isPaymentForm = /*isPaymentForm*/ ctx[9]; if (dirty & /*disabled*/ 16) input_changes.disabled = /*disabled*/ ctx[4]; if (dirty & /*onFocus*/ 4096) input_changes.onFocus = /*onFocus*/ ctx[12]; if (dirty & /*onBlur*/ 8192) input_changes.onBlur = /*onBlur*/ ctx[13]; if (dirty & /*$$scope, isPaymentForm, resendMessage, showMessage, error, onResendVerificationCode, resendText*/ 150060) { input_changes.$$scope = { dirty, ctx }; } input.$set(input_changes); if (/*codeValid*/ ctx[6]) { if (if_block0) { if (dirty & /*codeValid*/ 64) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_1$t(); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div0, t2); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (/*code*/ ctx[8] && !/*codeValid*/ ctx[6] && /*formBusy*/ ctx[7]) { if (if_block1) { if (dirty & /*code, codeValid, formBusy*/ 448) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$D(); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div0, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (!current || dirty & /*isPaymentForm*/ 512) { toggle_class(div0, "zephr-payment-form-input-inner-text", /*isPaymentForm*/ ctx[9]); } if (!current || dirty & /*isPaymentForm*/ 512) { toggle_class(div1, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[9]); } if (!current || dirty & /*isPaymentForm*/ 512) { toggle_class(div1, "zephr-payment-form-verification-resend-link-container", /*isPaymentForm*/ ctx[9]); } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(input.$$.fragment, local); transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(input.$$.fragment, local); transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(div1); } destroy_component(label_1, detaching); destroy_component(input); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); } }; } function instance$R($$self, $$props, $$invalidate) { let { label } = $$props; let { placeholder } = $$props; let { resendMessage = null } = $$props; let { resendText = null } = $$props; let { disabled } = $$props; let { error = null } = $$props; let { codeValid } = $$props; let { formBusy } = $$props; let { code } = $$props; let { isPaymentForm = false } = $$props; let { onChange } = $$props; let { onResendVerificationCode } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; let showMessage = false; const click_handler = () => { if (resendMessage) { $$invalidate(14, showMessage = true); setTimeout(() => $$invalidate(14, showMessage = false), 2000); } onResendVerificationCode(); }; const change_handler = ({ detail }) => !disabled && onChange(detail); $$self.$$set = $$props => { if ('label' in $$props) $$invalidate(0, label = $$props.label); if ('placeholder' in $$props) $$invalidate(1, placeholder = $$props.placeholder); if ('resendMessage' in $$props) $$invalidate(2, resendMessage = $$props.resendMessage); if ('resendText' in $$props) $$invalidate(3, resendText = $$props.resendText); if ('disabled' in $$props) $$invalidate(4, disabled = $$props.disabled); if ('error' in $$props) $$invalidate(5, error = $$props.error); if ('codeValid' in $$props) $$invalidate(6, codeValid = $$props.codeValid); if ('formBusy' in $$props) $$invalidate(7, formBusy = $$props.formBusy); if ('code' in $$props) $$invalidate(8, code = $$props.code); if ('isPaymentForm' in $$props) $$invalidate(9, isPaymentForm = $$props.isPaymentForm); if ('onChange' in $$props) $$invalidate(10, onChange = $$props.onChange); if ('onResendVerificationCode' in $$props) $$invalidate(11, onResendVerificationCode = $$props.onResendVerificationCode); if ('onFocus' in $$props) $$invalidate(12, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(13, onBlur = $$props.onBlur); }; return [ label, placeholder, resendMessage, resendText, disabled, error, codeValid, formBusy, code, isPaymentForm, onChange, onResendVerificationCode, onFocus, onBlur, showMessage, click_handler, change_handler ]; } class VerificationCode extends SvelteComponent { constructor(options) { super(); init(this, options, instance$R, create_fragment$S, safe_not_equal, { label: 0, placeholder: 1, resendMessage: 2, resendText: 3, disabled: 4, error: 5, codeValid: 6, formBusy: 7, code: 8, isPaymentForm: 9, onChange: 10, onResendVerificationCode: 11, onFocus: 12, onBlur: 13 }); } } const verificationCodeLength = 6; const isPossiblyValidCode = code => code?.length === verificationCodeLength; const checkUserAttributesValid = (formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order && e.elementType === 'user_attribute') .some((e) => !e.isValid); }; const factory$n = { matches: (sectionElement) => sectionElement.type === elementTypes.VERIFICATION_CODE, create: (form, formState, formActions, elementConfig) => ({ component: VerificationCode, props: { code: formState.verificationCode, label: elementConfig.label, placeholder: elementConfig.placeholder, resendMessage: elementConfig.message, resendText: elementConfig.resendText, disabled: formState.isBusy || formState.verificationCodeValid || !checkUserAttributesValid(formState), codeValid: formState.verificationCodeValid, formBusy: formState.isBusy, isPaymentForm: form.formType === FormType.PAYMENT, onResendVerificationCode: () => { void (formState.currentSection.type === sectionTypes.FORGOT_PASSWORD.type ? sendPasswordResetCode : send2FaCode)(form, formState, formActions); }, onChange: (value) => { const updatedState = formActions.updateFormState({ verificationCodeValid: undefined, verificationCode: value, serverErrors: [] }); const userAttributesValid = checkUserAttributesValid(formState); formActions.updateFormState({ showFieldErrors: !userAttributesValid }); if (isPossiblyValidCode(value)) { if (elementConfig.verificationEvent) { formActions.onEvent(elementConfig.verificationEvent); return; } if (formState.currentSection.type === sectionTypes.FORGOT_PASSWORD.type) { formActions.completeSection(); } else if (userAttributesValid) { void verifyOtp(form, updatedState, formActions); } } logDataLayerEvent(form, 'zephr_form_input_change', { inputName: 'zephr-form-verification-code', sectionId: formState.currentSection.type, field: 'verification-code' }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: 'zephr-form-verification-code', sectionId: formState.currentSection.type, field: 'verification-code' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: 'zephr-form-verification-code', sectionId: formState.currentSection.type, field: 'verification-code' }), }, isValid: isPossiblyValidCode(formState.verificationCode) }) }; /* src/components/elements/text/Text.svelte generated by Svelte v4.2.12 */ function create_fragment$R(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "zephr-form-custom-text svelte-3sd7s2"); set_style(div, "text-align", /*centerText*/ ctx[1] ? 'center' : 'initial'); toggle_class(div, "zephr-payment-form-custom-text", /*isPaymentForm*/ ctx[2]); }, m(target, anchor) { insert(target, div, anchor); div.innerHTML = /*text*/ ctx[0]; }, p(ctx, [dirty]) { if (dirty & /*text*/ 1) div.innerHTML = /*text*/ ctx[0]; if (dirty & /*centerText*/ 2) { set_style(div, "text-align", /*centerText*/ ctx[1] ? 'center' : 'initial'); } if (dirty & /*isPaymentForm*/ 4) { toggle_class(div, "zephr-payment-form-custom-text", /*isPaymentForm*/ ctx[2]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } } }; } function instance$Q($$self, $$props, $$invalidate) { let { text } = $$props; let { centerText = false } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('centerText' in $$props) $$invalidate(1, centerText = $$props.centerText); if ('isPaymentForm' in $$props) $$invalidate(2, isPaymentForm = $$props.isPaymentForm); }; return [text, centerText, isPaymentForm]; } class Text extends SvelteComponent { constructor(options) { super(); init(this, options, instance$Q, create_fragment$R, safe_not_equal, { text: 0, centerText: 1, isPaymentForm: 2 }); } } const factory$m = { matches: (sectionElement) => sectionElement.type === elementTypes.TEXT, create: (form, formState, formActions, elementConfig) => ({ component: Text, props: { text: elementConfig.text, centerText: elementConfig.centerText, isPaymentForm: form.formType === FormType.PAYMENT, } }) }; /* src/components/elements/Radio.svelte generated by Svelte v4.2.12 */ function create_fragment$Q(ctx) { let input; let t0; let label_1; let span; let t1; let t2; let mounted; let dispose; let input_levels = [ { id: /*id*/ ctx[0] }, { name: /*name*/ ctx[1] }, { required: /*required*/ ctx[2] }, { disabled: /*disabled*/ ctx[3] }, /*conditionalProps*/ ctx[8], { type: "radio" }, { class: "zephr-form-input-radio" } ]; let input_data = {}; for (let i = 0; i { dispatch("change", e.target.value); }; $$self.$$set = $$props => { if ('id' in $$props) $$invalidate(0, id = $$props.id); if ('name' in $$props) $$invalidate(1, name = $$props.name); if ('required' in $$props) $$invalidate(2, required = $$props.required); if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); if ('hasError' in $$props) $$invalidate(4, hasError = $$props.hasError); if ('isPaymentForm' in $$props) $$invalidate(5, isPaymentForm = $$props.isPaymentForm); if ('label' in $$props) $$invalidate(6, label = $$props.label); if ('value' in $$props) $$invalidate(10, value = $$props.value); if ('placeholder' in $$props) $$invalidate(11, placeholder = $$props.placeholder); if ('checked' in $$props) $$invalidate(7, checked = $$props.checked); if ('pattern' in $$props) $$invalidate(12, pattern = $$props.pattern); }; return [ id, name, required, disabled, hasError, isPaymentForm, label, checked, conditionalProps, handleInputChange, value, placeholder, pattern ]; } class Radio extends SvelteComponent { constructor(options) { super(); init(this, options, instance$P, create_fragment$Q, safe_not_equal, { id: 0, name: 1, required: 2, disabled: 3, hasError: 4, isPaymentForm: 5, label: 6, value: 10, placeholder: 11, checked: 7, pattern: 12 }); } } /* src/components/elements/userAttribute/UserAttribute.svelte generated by Svelte v4.2.12 */ function get_each_context_1$5(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[19] = list[i]; return child_ctx; } function get_each_context$g(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[19] = list[i]; return child_ctx; } // (120:2) {:else} function create_else_block$8(ctx) { let input; let current; input = new Input({ props: { id: /*id*/ ctx[10], name: /*config*/ ctx[0].slug, required: /*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required, type: /*attributeSchema*/ ctx[1]?.["input-type"], value: /*value*/ ctx[2], checked: /*attributeSchema*/ ctx[1]?.["input-type"] === "checkbox" && /*value*/ ctx[2], pattern: /*attributeSchema*/ ctx[1]?.["validation-expression"], placeholder: /*config*/ ctx[0].placeholder, hasError: /*hasError*/ ctx[8], isPaymentForm: /*isPaymentForm*/ ctx[3], onFocus: /*onFocus*/ ctx[5], onBlur: /*onBlur*/ ctx[6] } }); input.$on("change", /*change_handler_4*/ ctx[18]); return { c() { create_component(input.$$.fragment); }, m(target, anchor) { mount_component(input, target, anchor); current = true; }, p(ctx, dirty) { const input_changes = {}; if (dirty & /*config*/ 1) input_changes.name = /*config*/ ctx[0].slug; if (dirty & /*config, attributeSchema*/ 3) input_changes.required = /*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required; if (dirty & /*attributeSchema*/ 2) input_changes.type = /*attributeSchema*/ ctx[1]?.["input-type"]; if (dirty & /*value*/ 4) input_changes.value = /*value*/ ctx[2]; if (dirty & /*attributeSchema, value*/ 6) input_changes.checked = /*attributeSchema*/ ctx[1]?.["input-type"] === "checkbox" && /*value*/ ctx[2]; if (dirty & /*attributeSchema*/ 2) input_changes.pattern = /*attributeSchema*/ ctx[1]?.["validation-expression"]; if (dirty & /*config*/ 1) input_changes.placeholder = /*config*/ ctx[0].placeholder; if (dirty & /*hasError*/ 256) input_changes.hasError = /*hasError*/ ctx[8]; if (dirty & /*isPaymentForm*/ 8) input_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*onFocus*/ 32) input_changes.onFocus = /*onFocus*/ ctx[5]; if (dirty & /*onBlur*/ 64) input_changes.onBlur = /*onBlur*/ ctx[6]; input.$set(input_changes); }, i(local) { if (current) return; transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(input.$$.fragment, local); current = false; }, d(detaching) { destroy_component(input, detaching); } }; } // (93:56) function create_if_block_5$7(ctx) { let div; let input; let t; let current; input = new Input({ props: { id: /*id*/ ctx[10], required: /*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required, type: /*attributeSchema*/ ctx[1]["input-type"], value: /*value*/ ctx[2], min: /*attributeSchema*/ ctx[1]["range-start"], max: /*attributeSchema*/ ctx[1]["range-end"], step: /*attributeSchema*/ ctx[1]["range-start"], isPaymentForm: /*isPaymentForm*/ ctx[3], onFocus: /*onFocus*/ ctx[5], onBlur: /*onBlur*/ ctx[6] } }); input.$on("change", /*change_handler_3*/ ctx[17]); let if_block = /*attributeSchema*/ ctx[1]["input-type"] === "range" && /*value*/ ctx[2] != null && create_if_block_6$7(ctx); return { c() { div = element("div"); create_component(input.$$.fragment); t = space(); if (if_block) if_block.c(); attr(div, "class", "zephr-form-flex-container"); toggle_class(div, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div, anchor); mount_component(input, div, null); append(div, t); if (if_block) if_block.m(div, null); current = true; }, p(ctx, dirty) { const input_changes = {}; if (dirty & /*config, attributeSchema*/ 3) input_changes.required = /*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required; if (dirty & /*attributeSchema*/ 2) input_changes.type = /*attributeSchema*/ ctx[1]["input-type"]; if (dirty & /*value*/ 4) input_changes.value = /*value*/ ctx[2]; if (dirty & /*attributeSchema*/ 2) input_changes.min = /*attributeSchema*/ ctx[1]["range-start"]; if (dirty & /*attributeSchema*/ 2) input_changes.max = /*attributeSchema*/ ctx[1]["range-end"]; if (dirty & /*attributeSchema*/ 2) input_changes.step = /*attributeSchema*/ ctx[1]["range-start"]; if (dirty & /*isPaymentForm*/ 8) input_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*onFocus*/ 32) input_changes.onFocus = /*onFocus*/ ctx[5]; if (dirty & /*onBlur*/ 64) input_changes.onBlur = /*onBlur*/ ctx[6]; input.$set(input_changes); if (/*attributeSchema*/ ctx[1]["input-type"] === "range" && /*value*/ ctx[2] != null) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_6$7(ctx); if_block.c(); if_block.m(div, null); } } else if (if_block) { if_block.d(1); if_block = null; } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(div, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[3]); } }, i(local) { if (current) return; transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(input.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(input); if (if_block) if_block.d(); } }; } // (84:59) function create_if_block_4$9(ctx) { let textarea; let textarea_required_value; let textarea_placeholder_value; let mounted; let dispose; return { c() { textarea = element("textarea"); attr(textarea, "id", /*id*/ ctx[10]); attr(textarea, "class", "zephr-form-input zephr-form-input-textarea svelte-wlae04"); textarea.required = textarea_required_value = /*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required; attr(textarea, "placeholder", textarea_placeholder_value = /*config*/ ctx[0].placeholder); toggle_class(textarea, "zephr-payment-form-input", /*isPaymentForm*/ ctx[3]); toggle_class(textarea, "zephr-payment-form-input-textarea", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, textarea, anchor); set_input_value(textarea, /*currentValue*/ ctx[7]); if (!mounted) { dispose = listen(textarea, "input", /*textarea_input_handler*/ ctx[16]); mounted = true; } }, p(ctx, dirty) { if (dirty & /*config, attributeSchema*/ 3 && textarea_required_value !== (textarea_required_value = /*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required)) { textarea.required = textarea_required_value; } if (dirty & /*config*/ 1 && textarea_placeholder_value !== (textarea_placeholder_value = /*config*/ ctx[0].placeholder)) { attr(textarea, "placeholder", textarea_placeholder_value); } if (dirty & /*currentValue*/ 128) { set_input_value(textarea, /*currentValue*/ ctx[7]); } if (dirty & /*isPaymentForm*/ 8) { toggle_class(textarea, "zephr-payment-form-input", /*isPaymentForm*/ ctx[3]); } if (dirty & /*isPaymentForm*/ 8) { toggle_class(textarea, "zephr-payment-form-input-textarea", /*isPaymentForm*/ ctx[3]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(textarea); } mounted = false; dispose(); } }; } // (64:57) function create_if_block_3$b(ctx) { let select; let option_1; let t_value = (/*config*/ ctx[0].placeholder ?? "") + ""; let t; let select_name_value; let select_required_value; let select_value_value; let mounted; let dispose; let each_value_1 = ensure_array_like(/*attributeSchema*/ ctx[1]?.["select-options"]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { for (let i = 0; i function create_default_slot$5(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; const if_block_creators = [ create_if_block_1$s, create_if_block_2$h, create_if_block_3$b, create_if_block_4$9, create_if_block_5$7, create_else_block$8 ]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*attributeSchema*/ ctx[1]?.["input-type"] === "radio") return 0; if (/*attributeSchema*/ ctx[1]?.["input-type"] === "checkbox") return 1; if (/*attributeSchema*/ ctx[1]?.["input-type"] === "select") return 2; if (/*attributeSchema*/ ctx[1]?.["input-type"] === "textarea") return 3; if (/*attributeSchema*/ ctx[1]?.["input-type"] === "range") return 4; return 5; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if_blocks[current_block_type_index].m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if_blocks[current_block_type_index].d(detaching); } }; } // (138:0) {#if hasError} function create_if_block$C(ctx) { let div; return { c() { div = element("div"); div.textContent = "Mandatory information must be entered"; attr(div, "class", "zephr-form-input-error-text svelte-wlae04"); toggle_class(div, "zephr-payment-form-input-error-text", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div, anchor); }, p(ctx, dirty) { if (dirty & /*isPaymentForm*/ 8) { toggle_class(div, "zephr-payment-form-input-error-text", /*isPaymentForm*/ ctx[3]); } }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$P(ctx) { let label; let t; let if_block_anchor; let current; label = new Label({ props: { forInput: /*id*/ ctx[10], sublabel: /*attributeSchema*/ ctx[1]["public-description"], label: !(/(hidden|checkbox)/).test(/*attributeSchema*/ ctx[1]?.["input-type"] || "") ? `${/*config*/ ctx[0].label}${/*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required ? "*" : ""}` : "", isPaymentForm: /*isPaymentForm*/ ctx[3], $$slots: { default: [create_default_slot$5] }, $$scope: { ctx } } }); let if_block = /*hasError*/ ctx[8] && create_if_block$C(ctx); return { c() { create_component(label.$$.fragment); t = space(); if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { mount_component(label, target, anchor); insert(target, t, anchor); if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { const label_changes = {}; if (dirty & /*attributeSchema*/ 2) label_changes.sublabel = /*attributeSchema*/ ctx[1]["public-description"]; if (dirty & /*attributeSchema, config*/ 3) label_changes.label = !(/(hidden|checkbox)/).test(/*attributeSchema*/ ctx[1]?.["input-type"] || "") ? `${/*config*/ ctx[0].label}${/*config*/ ctx[0].required || /*attributeSchema*/ ctx[1]?.required ? "*" : ""}` : ""; if (dirty & /*isPaymentForm*/ 8) label_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*$$scope, attributeSchema, config, value, hasError, isPaymentForm, onChange, currentValue, onFocus, onBlur*/ 16777727) { label_changes.$$scope = { dirty, ctx }; } label.$set(label_changes); if (/*hasError*/ ctx[8]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$C(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, i(local) { if (current) return; transition_in(label.$$.fragment, local); current = true; }, o(local) { transition_out(label.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t); detach(if_block_anchor); } destroy_component(label, detaching); if (if_block) if_block.d(detaching); } }; } function instance$O($$self, $$props, $$invalidate) { let hasError; let { formKey } = $$props; let { config } = $$props; let { attributeSchema } = $$props; let { value } = $$props; let { error } = $$props; let { isPaymentForm = false } = $$props; let { onChange } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; let currentValue = value; // Casting functions for typescript const asSelect = target => target; const id = `zephr-form-${config.slug}-${formKey}`; const change_handler = ({ detail }) => onChange(detail); const change_handler_1 = ({ detail }) => onChange(detail); const change_handler_2 = e => onChange(asSelect(e.target).value); function textarea_input_handler() { currentValue = this.value; $$invalidate(7, currentValue); } const change_handler_3 = ({ detail }) => onChange(detail); const change_handler_4 = ({ detail }) => onChange(detail); $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(11, formKey = $$props.formKey); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('attributeSchema' in $$props) $$invalidate(1, attributeSchema = $$props.attributeSchema); if ('value' in $$props) $$invalidate(2, value = $$props.value); if ('error' in $$props) $$invalidate(12, error = $$props.error); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); if ('onChange' in $$props) $$invalidate(4, onChange = $$props.onChange); if ('onFocus' in $$props) $$invalidate(5, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(6, onBlur = $$props.onBlur); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*error*/ 4096) { $$invalidate(8, hasError = !!error); } if ($$self.$$.dirty & /*attributeSchema, currentValue, value, onChange*/ 150) { if (attributeSchema?.["input-type"] === "textarea" && currentValue !== value) { onChange(currentValue); } } }; return [ config, attributeSchema, value, isPaymentForm, onChange, onFocus, onBlur, currentValue, hasError, asSelect, id, formKey, error, change_handler, change_handler_1, change_handler_2, textarea_input_handler, change_handler_3, change_handler_4 ]; } class UserAttribute extends SvelteComponent { constructor(options) { super(); init(this, options, instance$O, create_fragment$P, safe_not_equal, { formKey: 11, config: 0, attributeSchema: 1, value: 2, error: 12, isPaymentForm: 3, onChange: 4, onFocus: 5, onBlur: 6 }); } } const isEmpty = value => value == null || value === ""; const factory$l = { matches: (sectionElement) => sectionElement.type === elementTypes.USER_ATTRIBUTE, create: (form, formState, formActions, elementConfig) => { const attributeSchema = form.organisationConfiguration.schemaFields.find(s => s.slug === elementConfig.slug); const hide = formState.hideIfSetAttributes?.includes(elementConfig.slug); if (attributeSchema == undefined || hide) { return undefined; } const required = attributeSchema.required || elementConfig.required; const currentValue = (formState.userAttributes[elementConfig.slug] ?? (formState.readOnlyAttributeValues ?? {})[elementConfig.slug]); return { component: UserAttribute, props: { formKey: form.uniqueKey, config: elementConfig, value: currentValue, attributeSchema, isPaymentForm: form.formType === FormType.PAYMENT, onChange: (value) => { formActions.updateFormState({ userAttributes: { ...formState.userAttributes, [elementConfig.slug]: value } }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: `zephr-form-${elementConfig.slug}-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: elementConfig.slug }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: `zephr-form-${elementConfig.slug}-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: elementConfig.slug }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: `zephr-form-${elementConfig.slug}-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: elementConfig.slug }), }, isValid: !(required && isEmpty(currentValue)) && !(required && attributeSchema["input-type"] === 'checkbox' && !currentValue) && !(attributeSchema["input-type"] === 'email' && !isEmpty(currentValue) && !isValidEmail(currentValue)) }; } }; /* src/components/elements/Link.svelte generated by Svelte v4.2.12 */ function create_fragment$O(ctx) { let button; let t; let mounted; let dispose; return { c() { button = element("button"); t = text(/*text*/ ctx[0]); attr(button, "type", "button"); attr(button, "class", "zephr-form-link svelte-14vxk2u"); toggle_class(button, "zephr-form-link-disabled", /*disabled*/ ctx[1]); toggle_class(button, "zephr-form-link-no-underline", /*noUnderline*/ ctx[3]); }, m(target, anchor) { insert(target, button, anchor); append(button, t); if (!mounted) { dispose = listen(button, "click", /*click_handler*/ ctx[5]); mounted = true; } }, p(ctx, [dirty]) { if (dirty & /*text*/ 1) set_data(t, /*text*/ ctx[0]); if (dirty & /*disabled*/ 2) { toggle_class(button, "zephr-form-link-disabled", /*disabled*/ ctx[1]); } if (dirty & /*noUnderline*/ 8) { toggle_class(button, "zephr-form-link-no-underline", /*noUnderline*/ ctx[3]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(button); } mounted = false; dispose(); } }; } function instance$N($$self, $$props, $$invalidate) { let { text } = $$props; let { disabled = false } = $$props; let { onClick = () => { } } = $$props; let { noUnderline = false } = $$props; const dispatch = createEventDispatcher(); const click_handler = () => { onClick(); dispatch('linkClick', null); }; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('disabled' in $$props) $$invalidate(1, disabled = $$props.disabled); if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick); if ('noUnderline' in $$props) $$invalidate(3, noUnderline = $$props.noUnderline); }; return [text, disabled, onClick, noUnderline, dispatch, click_handler]; } class Link extends SvelteComponent { constructor(options) { super(); init(this, options, instance$N, create_fragment$O, safe_not_equal, { text: 0, disabled: 1, onClick: 2, noUnderline: 3 }); } } /* src/components/elements/resetPasswordLink/ResetPasswordLink.svelte generated by Svelte v4.2.12 */ function create_else_block$7(ctx) { let link; let current; link = new Link({ props: { text: /*text*/ ctx[0], onClick: /*onClick*/ ctx[2] } }); link.$on("linkClick", /*linkClick_handler*/ ctx[7]); return { c() { create_component(link.$$.fragment); }, m(target, anchor) { mount_component(link, target, anchor); current = true; }, p(ctx, dirty) { const link_changes = {}; if (dirty & /*text*/ 1) link_changes.text = /*text*/ ctx[0]; if (dirty & /*onClick*/ 4) link_changes.onClick = /*onClick*/ ctx[2]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { destroy_component(link, detaching); } }; } // (16:2) {#if showMessage && !error} function create_if_block_1$r(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*message*/ ctx[1]); attr(div, "class", "zephr-form-link-message svelte-49aomy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*message*/ 2) set_data(t, /*message*/ ctx[1]); }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } } }; } // (32:2) {#if error} function create_if_block$B(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*error*/ ctx[3], isPaymentForm: /*isPaymentForm*/ ctx[5] } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, dirty) { const errormessage_changes = {}; if (dirty & /*error*/ 8) errormessage_changes.error = /*error*/ ctx[3]; if (dirty & /*isPaymentForm*/ 32) errormessage_changes.isPaymentForm = /*isPaymentForm*/ ctx[5]; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function create_fragment$N(ctx) { let div; let current_block_type_index; let if_block0; let t; let current; const if_block_creators = [create_if_block_1$r, create_else_block$7]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*showMessage*/ ctx[6] && !/*error*/ ctx[3]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); let if_block1 = /*error*/ ctx[3] && create_if_block$B(ctx); return { c() { div = element("div"); if_block0.c(); t = space(); if (if_block1) if_block1.c(); attr(div, "class", "zephr-form-flex-container zephr-form-reset-link-container svelte-49aomy"); toggle_class(div, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[5]); }, m(target, anchor) { insert(target, div, anchor); if_blocks[current_block_type_index].m(div, null); append(div, t); if (if_block1) if_block1.m(div, null); current = true; }, p(ctx, [dirty]) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block0 = if_blocks[current_block_type_index]; if (!if_block0) { if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block0.c(); } else { if_block0.p(ctx, dirty); } transition_in(if_block0, 1); if_block0.m(div, t); } if (/*error*/ ctx[3]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*error*/ 8) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$B(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (!current || dirty & /*isPaymentForm*/ 32) { toggle_class(div, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[5]); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div); } if_blocks[current_block_type_index].d(); if (if_block1) if_block1.d(); } }; } function instance$M($$self, $$props, $$invalidate) { let { text } = $$props; let { message } = $$props; let { onClick } = $$props; let { error = null } = $$props; let { delayMs } = $$props; let { isPaymentForm = false } = $$props; let showMessage = false; const linkClick_handler = () => { if (message) { $$invalidate(6, showMessage = true); setTimeout(() => $$invalidate(6, showMessage = false), delayMs); } }; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('message' in $$props) $$invalidate(1, message = $$props.message); if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick); if ('error' in $$props) $$invalidate(3, error = $$props.error); if ('delayMs' in $$props) $$invalidate(4, delayMs = $$props.delayMs); if ('isPaymentForm' in $$props) $$invalidate(5, isPaymentForm = $$props.isPaymentForm); }; return [ text, message, onClick, error, delayMs, isPaymentForm, showMessage, linkClick_handler ]; } class ResetPasswordLink extends SvelteComponent { constructor(options) { super(); init(this, options, instance$M, create_fragment$N, safe_not_equal, { text: 0, message: 1, onClick: 2, error: 3, delayMs: 4, isPaymentForm: 5 }); } } const factory$k = { matches: (sectionElement) => sectionElement.type === elementTypes.RESET_PASSWORD_LINK, create: (form, formState, formActions, elementConfig) => ({ component: ResetPasswordLink, props: { text: elementConfig.text, message: elementConfig.message, delayMs: form.environment.reduceDelays ? 1 : 3000, isPaymentForm: form.formType === FormType.PAYMENT, onClick: async () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'RESET_PASSWORD_LINK' }); await sendPasswordResetCode(form, formState, formActions); } } }) }; /* src/components/elements/resendLoginLink/ResendLoginLink.svelte generated by Svelte v4.2.12 */ function create_else_block$6(ctx) { let link; let current; link = new Link({ props: { text: /*text*/ ctx[0], onClick: /*onClick*/ ctx[2] } }); link.$on("linkClick", /*linkClick_handler*/ ctx[7]); return { c() { create_component(link.$$.fragment); }, m(target, anchor) { mount_component(link, target, anchor); current = true; }, p(ctx, dirty) { const link_changes = {}; if (dirty & /*text*/ 1) link_changes.text = /*text*/ ctx[0]; if (dirty & /*onClick*/ 4) link_changes.onClick = /*onClick*/ ctx[2]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { destroy_component(link, detaching); } }; } // (16:2) {#if showMessage && !error} function create_if_block_1$q(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*message*/ ctx[1]); attr(div, "class", "zephr-form-link-message svelte-49aomy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*message*/ 2) set_data(t, /*message*/ ctx[1]); }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } } }; } // (32:2) {#if error} function create_if_block$A(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*error*/ ctx[3], isPaymentForm: /*isPaymentForm*/ ctx[5] } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, dirty) { const errormessage_changes = {}; if (dirty & /*error*/ 8) errormessage_changes.error = /*error*/ ctx[3]; if (dirty & /*isPaymentForm*/ 32) errormessage_changes.isPaymentForm = /*isPaymentForm*/ ctx[5]; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function create_fragment$M(ctx) { let div; let current_block_type_index; let if_block0; let t; let current; const if_block_creators = [create_if_block_1$q, create_else_block$6]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*showMessage*/ ctx[6] && !/*error*/ ctx[3]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); let if_block1 = /*error*/ ctx[3] && create_if_block$A(ctx); return { c() { div = element("div"); if_block0.c(); t = space(); if (if_block1) if_block1.c(); attr(div, "class", "zephr-form-flex-container zephr-form-reset-link-container svelte-49aomy"); toggle_class(div, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[5]); }, m(target, anchor) { insert(target, div, anchor); if_blocks[current_block_type_index].m(div, null); append(div, t); if (if_block1) if_block1.m(div, null); current = true; }, p(ctx, [dirty]) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block0 = if_blocks[current_block_type_index]; if (!if_block0) { if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block0.c(); } else { if_block0.p(ctx, dirty); } transition_in(if_block0, 1); if_block0.m(div, t); } if (/*error*/ ctx[3]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*error*/ 8) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$A(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (!current || dirty & /*isPaymentForm*/ 32) { toggle_class(div, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[5]); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div); } if_blocks[current_block_type_index].d(); if (if_block1) if_block1.d(); } }; } function instance$L($$self, $$props, $$invalidate) { let { text } = $$props; let { message } = $$props; let { onClick } = $$props; let { error = null } = $$props; let { delayMs } = $$props; let { isPaymentForm = false } = $$props; let showMessage = false; const linkClick_handler = () => { if (message) { $$invalidate(6, showMessage = true); setTimeout(() => $$invalidate(6, showMessage = false), delayMs); } }; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('message' in $$props) $$invalidate(1, message = $$props.message); if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick); if ('error' in $$props) $$invalidate(3, error = $$props.error); if ('delayMs' in $$props) $$invalidate(4, delayMs = $$props.delayMs); if ('isPaymentForm' in $$props) $$invalidate(5, isPaymentForm = $$props.isPaymentForm); }; return [ text, message, onClick, error, delayMs, isPaymentForm, showMessage, linkClick_handler ]; } class ResendLoginLink extends SvelteComponent { constructor(options) { super(); init(this, options, instance$L, create_fragment$M, safe_not_equal, { text: 0, message: 1, onClick: 2, error: 3, delayMs: 4, isPaymentForm: 5 }); } } const factory$j = { matches: (sectionElement) => sectionElement.type === elementTypes.RESEND_LOGIN_LINK, create: (form, formState, formActions, elementConfig) => ({ component: ResendLoginLink, props: { text: elementConfig.text, message: elementConfig.message, delayMs: form.environment.reduceDelays ? 1 : 3000, isPaymentForm: form.formType === FormType.PAYMENT, onClick: async () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'RESEND_LOGIN_LINK' }); await sendLink(form, 'login', formState.emailAddress, formActions); } } }) }; const oauthProviderWindowFeatures = "menubar=no,location=yes,resizable=no,scrollbars=no,status=no,width=500,height=600"; const useOAuthProvider = (provider, form, formActions) => { formActions.updateFormState({ socialSigninError: undefined }); window.open(`${form.environment.apiUrlBase ?? ""}/blaize/oauth/${provider}`, provider + " sign-in", oauthProviderWindowFeatures); const listener = messageAction(form, formActions); window.zephrOAuthListener = listener; window.addEventListener("message", listener); }; const messageAction = (form, formActions) => (message) => { if (!message?.data?.fromZephr) { return; } window.removeEventListener("message", window.zephrOAuthListener); form.environment.debugLogging && console.log("Social signin message:", message); if (message.data.action === "register") { // This is a fresh user who is registering, they may need to add some required attributes first. // If not, register immediately. const newFormState = formActions.updateFormState({ emailAddress: message.data.identifier, socialSigninToken: message.data.stateKey, userAttributes: message.data.userAttributes ?? {}, socialSignin: true, userExists: false, emailIsContact: undefined }); if (formConfigAs(form).useVerificationCodes) { void send2FaCode(form, newFormState, formActions); } void moveToNextSection(form, newFormState, formActions); } else if (message.data.action == "otp") { // Already registered user and verification via OTP is needed formActions.updateFormState({ emailAddress: message.data.identifier, socialSigninToken: message.data.stateKey, userAttributes: message.data.userAttributes ?? {}, socialSignin: true, userExists: true, emailIsContact: false }); formActions.jumpToSection(sectionTypes.VERIFICATION_CODE_LOGIN.type); } else if (message.data.action === "login") { // Already registered user who is now logged in. document.cookie = message.data.cookie; formActions.updateFormState({ socialSignin: true, userExists: true, loginRegistrationComplete: true, emailIsContact: false }); void formActions.onEvent(FormEvent.LOGIN_REGISTRATION_COMPLETE); } else { // Failure formActions.updateFormState({ socialSigninError: message.data.message ?? "Something went wrong. Please try again later!" }); } }; var faMicrosoft = { prefix: 'fab', iconName: 'microsoft', icon: [448, 512, [], "f3ca", "M0 32h214.6v214.6H0V32zm233.4 0H448v214.6H233.4V32zM0 265.4h214.6V480H0V265.4zm233.4 0H448V480H233.4V265.4z"] }; var faApple = { prefix: 'fab', iconName: 'apple', icon: [384, 512, [], "f179", "M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"] }; var faLinkedin = { prefix: 'fab', iconName: 'linkedin', icon: [448, 512, [], "f08c", "M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"] }; var faFacebook = { prefix: 'fab', iconName: 'facebook', icon: [512, 512, [62000], "f09a", "M512 256C512 114.6 397.4 0 256 0S0 114.6 0 256C0 376 82.7 476.8 194.2 504.5V334.2H141.4V256h52.8V222.3c0-87.1 39.4-127.5 125-127.5c16.2 0 44.2 3.2 55.7 6.4V172c-6-.6-16.5-1-29.6-1c-42 0-58.2 15.9-58.2 57.2V256h83.6l-14.4 78.2H287V510.1C413.8 494.8 512 386.9 512 256h0z"] }; var faTwitter = { prefix: 'fab', iconName: 'twitter', icon: [512, 512, [], "f099", "M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"] }; /* src/components/elements/socialSignIn/GoogleLogo.svelte generated by Svelte v4.2.12 */ function create_fragment$L(ctx) { let svg; let path0; let path1; let path2; let path3; return { c() { svg = svg_element("svg"); path0 = svg_element("path"); path1 = svg_element("path"); path2 = svg_element("path"); path3 = svg_element("path"); attr(path0, "d", "M533.5 278.4c0-18.5-1.5-37.1-4.7-55.3H272.1v104.8h147c-6.1 33.8-25.7 63.7-54.4 82.7v68h87.7c51.5-47.4 81.1-117.4 81.1-200.2z"); attr(path0, "fill", "#4285f4"); attr(path1, "d", "M272.1 544.3c73.4 0 135.3-24.1 180.4-65.7l-87.7-68c-24.4 16.6-55.9 26-92.6 26-71 0-131.2-47.9-152.8-112.3H28.9v70.1c46.2 91.9 140.3 149.9 243.2 149.9z"); attr(path1, "fill", "#34a853"); attr(path2, "d", "M119.3 324.3c-11.4-33.8-11.4-70.4 0-104.2V150H28.9c-38.6 76.9-38.6 167.5 0 244.4l90.4-70.1z"); attr(path2, "fill", "#fbbc04"); attr(path3, "d", "M272.1 107.7c38.8-.6 76.3 14 104.4 40.8l77.7-77.7C405 24.6 339.7-.8 272.1 0 169.2 0 75.1 58 28.9 150l90.4 70.1c21.5-64.5 81.8-112.4 152.8-112.4z"); attr(path3, "fill", "#ea4335"); attr(svg, "class", "zephr-form-social-sign-in-icon zephr-form-google-icon svelte-aktnoc"); attr(svg, "viewBox", "0 0 533.5 544.3"); attr(svg, "xmlns", "http://www.w3.org/2000/svg"); }, m(target, anchor) { insert(target, svg, anchor); append(svg, path0); append(svg, path1); append(svg, path2); append(svg, path3); }, p: noop, i: noop, o: noop, d(detaching) { if (detaching) { detach(svg); } } }; } class GoogleLogo extends SvelteComponent { constructor(options) { super(); init(this, options, null, create_fragment$L, safe_not_equal, {}); } } /* src/components/elements/socialSignIn/SocialSignIn.svelte generated by Svelte v4.2.12 */ function get_each_context$f(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[8] = list[i]; return child_ctx; } // (30:2) {#if config[option] === true && option !== 'labelText' && option !== 'allowEmptyLabel'} function create_if_block_1$p(ctx) { let button; let span1; let span0; let current_block_type_index; let if_block; let t0; let t1; let t2; let t3_value = /*option*/ ctx[8] + ""; let t3; let current; let mounted; let dispose; const if_block_creators = [create_if_block_2$g, create_else_block$5]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*option*/ ctx[8] === "Google") return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); function click_handler() { return /*click_handler*/ ctx[6](/*option*/ ctx[8]); } return { c() { button = element("button"); span1 = element("span"); span0 = element("span"); if_block.c(); t0 = space(); t1 = text(/*labelText*/ ctx[4]); t2 = space(); t3 = text(t3_value); attr(span0, "class", "zephr-form-social-sign-in-icon svelte-1e2xtn4"); toggle_class(span0, "zephr-payment-form-social-sign-in-icon", /*isPaymentForm*/ ctx[3]); attr(span1, "class", "zephr-form-flex-container zephr-form-social-sign-in svelte-1e2xtn4"); toggle_class(span1, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[3]); toggle_class(span1, "zephr-payment-form-social-sign-in", /*isPaymentForm*/ ctx[3]); attr(button, "type", "button"); attr(button, "class", "zephr-form-button zephr-form-social-sign-in-button svelte-1e2xtn4"); toggle_class(button, "zephr-payment-form-button", /*isPaymentForm*/ ctx[3]); toggle_class(button, "zephr-payment-form-social-sign-in-button", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, button, anchor); append(button, span1); append(span1, span0); if_blocks[current_block_type_index].m(span0, null); append(span1, t0); append(span1, t1); append(span1, t2); append(span1, t3); current = true; if (!mounted) { dispose = listen(button, "click", prevent_default(click_handler)); mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(span0, null); } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(span0, "zephr-payment-form-social-sign-in-icon", /*isPaymentForm*/ ctx[3]); } if ((!current || dirty & /*config*/ 1) && t3_value !== (t3_value = /*option*/ ctx[8] + "")) set_data(t3, t3_value); if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(span1, "zephr-payment-form-flex-container", /*isPaymentForm*/ ctx[3]); } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(span1, "zephr-payment-form-social-sign-in", /*isPaymentForm*/ ctx[3]); } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(button, "zephr-payment-form-button", /*isPaymentForm*/ ctx[3]); } if (!current || dirty & /*isPaymentForm*/ 8) { toggle_class(button, "zephr-payment-form-social-sign-in-button", /*isPaymentForm*/ ctx[3]); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(button); } if_blocks[current_block_type_index].d(); mounted = false; dispose(); } }; } // (49:10) {:else} function create_else_block$5(ctx) { let fa; let current; const fa_spread_levels = [/*getProviderIcon*/ ctx[5](/*option*/ ctx[8])]; let fa_props = {}; for (let i = 0; i { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (58:0) {#if error} function create_if_block$z(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*error*/ ctx[2], isPaymentForm: /*isPaymentForm*/ ctx[3] } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, dirty) { const errormessage_changes = {}; if (dirty & /*error*/ 4) errormessage_changes.error = /*error*/ ctx[2]; if (dirty & /*isPaymentForm*/ 8) errormessage_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function create_fragment$K(ctx) { let t; let if_block_anchor; let current; let each_value = ensure_array_like(Object.keys(/*config*/ ctx[0])); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); let if_block = /*error*/ ctx[2] && create_if_block$z(ctx); return { c() { for (let i = 0; i { if_block = null; }); check_outros(); } }, i(local) { if (current) return; for (let i = 0; i { switch (provider) { case "Facebook": return { icon: faFacebook, color: "#1877f2", size: "lg" }; case "LinkedIn": return { icon: faLinkedin, color: "#0a66c2", size: "lg" }; case "Apple": return { icon: faApple, color: "#000", size: "lg" }; case "Microsoft": return { icon: faMicrosoft, color: "#00a4ef", size: "lg" }; case "Twitter": return { icon: faTwitter, color: "#08a0e9", size: "lg" }; default: return { icon: faFacebook, color: "#1877f2", size: "lg" }; } }; const click_handler = option => onSelectProvider(option.toLowerCase()); $$self.$$set = $$props => { if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('onSelectProvider' in $$props) $$invalidate(1, onSelectProvider = $$props.onSelectProvider); if ('error' in $$props) $$invalidate(2, error = $$props.error); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); }; return [ config, onSelectProvider, error, isPaymentForm, labelText, getProviderIcon, click_handler ]; } class SocialSignIn extends SvelteComponent { constructor(options) { super(); init(this, options, instance$K, create_fragment$K, safe_not_equal, { config: 0, onSelectProvider: 1, error: 2, isPaymentForm: 3 }); } } const factory$i = { matches: (sectionElement) => sectionElement.type === elementTypes.SOCIAL_SIGNIN, create: (form, _, formActions, elementConfig) => { const { enabled: __, hide: ___, show: ____, ...cleanedConfig } = elementConfig ?? {}; return ({ component: SocialSignIn, props: { config: cleanedConfig, isPaymentForm: form.formType === FormType.PAYMENT, onSelectProvider: (provider) => useOAuthProvider(provider, form, formActions) } }); } }; const verifyingPromoCodeBusyKey = "promo-code"; const runPromoCodeValidation = async (form, formState, formActions) => { formActions.updateFormState({ promoCodeValid: undefined, serverErrors: [], discountedPlanPrices: [] }); const providerConfig = paymentProviderFor(form.organisationConfiguration.paymentProvider); const response = await request(providerConfig.promoCodeCheckPath, { method: 'POST', bodyObject: { promoCode: formState.promoCode, paymentOptions: formConfigAs(form).paymentOptions } }, formActions, verifyingPromoCodeBusyKey); if (!response.ok) { let serverError; if (response.status === 403) { const json = await response.json(); if (json?.code === 2 || json?.code === 3) { serverError = ServerError.PROMO_CODE_EXPIRED_ERROR; } else { serverError = ServerError.PROMO_CODE_INVALID_ERROR; } } else { serverError = ServerError.PROMO_CODE_INVALID_ERROR; console.error("Unknown error evaluating promo code", response); } logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); return Promise.resolve(formActions.updateFormState({ promoCodeValid: false, serverErrors: [serverError], discountedPlanPrices: [] })); } const json = await response.json(); const discountedPlanPrices = json.paymentOptions.map(p => ({ planSlug: p.slug, productId: p.productId, discountPrice: p.discountPrice })); if (!discountedPlanPrices.find(discount => discount.planSlug === formState.paymentOption.slug && discount.productId === formState.paymentOption.productId)) { logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.PROMO_CODE_NOT_VALID_FOR_PLAN_ERROR], }); return Promise.resolve(formActions.updateFormState({ promoCodeValid: false, serverErrors: [ServerError.PROMO_CODE_NOT_VALID_FOR_PLAN_ERROR], discountedPlanPrices: discountedPlanPrices })); } return Promise.resolve(formActions.updateFormState({ promoCodeValid: true, serverErrors: [], discountedPlanPrices: discountedPlanPrices })); }; /* If we're using mobile payment and we're on the payment screen, we'll need to reload the mobile payment button so it has the discounted amount and make sure they can't press the button while the button is updating */ const afterPromoCodeChange = async (form, formState, formActions) => { const formStateWithAddons = await getProductAddons(form, formState, formActions, true); const formStateWithPrices = await calculatePrices(form, formStateWithAddons, formActions); if (formState.currentSection.elements.some(element => element.type === elementTypes.MOBILE_PAYMENT && element.config?.enabled !== false)) { formActions.incrementRequestCount(); try { // Only reload mobile payment service if the provider actually supports mobile payments if (supportsMobilePayments(form.organisationConfiguration.paymentProvider)) { await mobilePaymentServiceFor(form.organisationConfiguration.paymentProvider).loader(form, formStateWithPrices, formActions); } } finally { formActions.decrementRequestCount(); } } }; const validatePromoCode = async (form, formState, formActions) => { const providerConfig = paymentProviderFor(form.organisationConfiguration.paymentProvider); if (!providerConfig.hasPromoCodes(form)) { return formState; } if (providerConfig?.promoCodeServiceOverride) { return providerConfig.promoCodeServiceOverride(form, formState, formActions); } return runPromoCodeValidation(form, formState, formActions) .then((updatedFormState) => afterPromoCodeChange(form, updatedFormState, formActions)); }; /* src/components/elements/paymentSummary/PaymentSummary.svelte generated by Svelte v4.2.12 */ function get_each_context$e(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[35] = list[i]; return child_ctx; } function get_each_context_1$4(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[38] = list[i]; return child_ctx; } function get_each_context_2(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[41] = list[i]; return child_ctx; } // (50:2) {#each chargeItems as chargeItem} function create_each_block_2(ctx) { let div1; let span0; let t0_value = /*chargeItem*/ ctx[41].label + ""; let t0; let t1; let div0; let span1; let t2_value = /*chargeItem*/ ctx[41].priceFormattedString + ""; let t2; return { c() { div1 = element("div"); span0 = element("span"); t0 = text(t0_value); t1 = space(); div0 = element("div"); span1 = element("span"); t2 = text(t2_value); attr(span0, "class", "zephr-form-summary-charge-description zephr-payment-form-summary-charge-description svelte-xf8v79"); attr(div0, "class", "zephr-form-summary-line-right zephr-payment-form-summary-line-right svelte-xf8v79"); attr(div1, "class", "zephr-form-charge-line zephr-payment-form-charge-line svelte-xf8v79"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, span0); append(span0, t0); append(div1, t1); append(div1, div0); append(div0, span1); append(span1, t2); }, p(ctx, dirty) { if (dirty[0] & /*chargeItems*/ 524288 && t0_value !== (t0_value = /*chargeItem*/ ctx[41].label + "")) set_data(t0, t0_value); if (dirty[0] & /*chargeItems*/ 524288 && t2_value !== (t2_value = /*chargeItem*/ ctx[41].priceFormattedString + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); } } }; } // (63:2) {#if paymentProvider === 'braintree' && discounts.length > 0} function create_if_block_14$2(ctx) { let each_1_anchor; let each_value_1 = ensure_array_like(/*discounts*/ ctx[23]); let each_blocks = []; for (let i = 0; i { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block1); current = true; }, o(local) { transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(t); detach(if_block1_anchor); } if (if_block0) if_block0.d(detaching); if (if_block1) if_block1.d(detaching); } }; } // (99:4) {#if !paymentProcessed && !(showPromoCode || promoCode)} function create_if_block_12$2(ctx) { let button; let span; let t; let mounted; let dispose; return { c() { button = element("button"); span = element("span"); t = text(/*promoCodeLinkText*/ ctx[4]); attr(button, "type", "button"); attr(button, "class", "zephr-form-promo-activate-line zephr-payment-form-promo-activate-line svelte-xf8v79"); }, m(target, anchor) { insert(target, button, anchor); append(button, span); append(span, t); if (!mounted) { dispose = listen(button, "click", /*click_handler*/ ctx[33]); mounted = true; } }, p(ctx, dirty) { if (dirty[0] & /*promoCodeLinkText*/ 16) set_data(t, /*promoCodeLinkText*/ ctx[4]); }, d(detaching) { if (detaching) { detach(button); } mounted = false; dispose(); } }; } // (108:4) {#if showPromoCode || promoCode} function create_if_block_3$a(ctx) { let div2; let div0; let current_block_type_index; let if_block0; let t0; let div1; let current_block_type_index_1; let if_block1; let div1_class_value; let t1; let if_block2_anchor; let current; const if_block_creators = [create_if_block_8$2, create_if_block_9$2]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*paymentProcessed*/ ctx[17] && /*promoCode*/ ctx[11]) return 0; if (!/*paymentProcessed*/ ctx[17]) return 1; return -1; } if (~(current_block_type_index = select_block_type(ctx))) { if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); } const if_block_creators_1 = [create_if_block_5$6, create_if_block_7$2]; const if_blocks_1 = []; function select_block_type_2(ctx, dirty) { if (/*promoCodeValid*/ ctx[12]) return 0; if (!/*paymentProcessed*/ ctx[17]) return 1; return -1; } if (~(current_block_type_index_1 = select_block_type_2(ctx))) { if_block1 = if_blocks_1[current_block_type_index_1] = if_block_creators_1[current_block_type_index_1](ctx); } let if_block2 = /*error*/ ctx[14] && create_if_block_4$8(ctx); return { c() { div2 = element("div"); div0 = element("div"); if (if_block0) if_block0.c(); t0 = space(); div1 = element("div"); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); if_block2_anchor = empty(); attr(div0, "class", "zephr-form-promo-input-container zephr-payment-form-promo-input-container svelte-xf8v79"); attr(div1, "class", div1_class_value = "" + (null_to_empty(/*promoCodeValid*/ ctx[12] ? "zephr-form-summary-line-right zephr-payment-form-summary-line-right" : "zephr-form-summary-line-left zephr-payment-form-summary-line-left") + " svelte-xf8v79")); attr(div2, "class", "zephr-form-promo-line zephr-payment-form-promo-line svelte-xf8v79"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div0); if (~current_block_type_index) { if_blocks[current_block_type_index].m(div0, null); } append(div2, t0); append(div2, div1); if (~current_block_type_index_1) { if_blocks_1[current_block_type_index_1].m(div1, null); } insert(target, t1, anchor); if (if_block2) if_block2.m(target, anchor); insert(target, if_block2_anchor, anchor); current = true; }, p(ctx, dirty) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if (~current_block_type_index) { if_blocks[current_block_type_index].p(ctx, dirty); } } else { if (if_block0) { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); } if (~current_block_type_index) { if_block0 = if_blocks[current_block_type_index]; if (!if_block0) { if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block0.c(); } else { if_block0.p(ctx, dirty); } transition_in(if_block0, 1); if_block0.m(div0, null); } else { if_block0 = null; } } let previous_block_index_1 = current_block_type_index_1; current_block_type_index_1 = select_block_type_2(ctx); if (current_block_type_index_1 === previous_block_index_1) { if (~current_block_type_index_1) { if_blocks_1[current_block_type_index_1].p(ctx, dirty); } } else { if (if_block1) { group_outros(); transition_out(if_blocks_1[previous_block_index_1], 1, 1, () => { if_blocks_1[previous_block_index_1] = null; }); check_outros(); } if (~current_block_type_index_1) { if_block1 = if_blocks_1[current_block_type_index_1]; if (!if_block1) { if_block1 = if_blocks_1[current_block_type_index_1] = if_block_creators_1[current_block_type_index_1](ctx); if_block1.c(); } else { if_block1.p(ctx, dirty); } transition_in(if_block1, 1); if_block1.m(div1, null); } else { if_block1 = null; } } if (!current || dirty[0] & /*promoCodeValid*/ 4096 && div1_class_value !== (div1_class_value = "" + (null_to_empty(/*promoCodeValid*/ ctx[12] ? "zephr-form-summary-line-right zephr-payment-form-summary-line-right" : "zephr-form-summary-line-left zephr-payment-form-summary-line-left") + " svelte-xf8v79"))) { attr(div1, "class", div1_class_value); } if (/*error*/ ctx[14]) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty[0] & /*error*/ 16384) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_4$8(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(if_block2_anchor.parentNode, if_block2_anchor); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); transition_in(if_block2); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); transition_out(if_block2); current = false; }, d(detaching) { if (detaching) { detach(div2); detach(t1); detach(if_block2_anchor); } if (~current_block_type_index) { if_blocks[current_block_type_index].d(); } if (~current_block_type_index_1) { if_blocks_1[current_block_type_index_1].d(); } if (if_block2) if_block2.d(detaching); } }; } // (115:38) function create_if_block_9$2(ctx) { let div; let input; let current; input = new Input({ props: { id: "zephr-form-promo-code", value: /*promoCode*/ ctx[11], placeholder: /*promoCodePlaceholder*/ ctx[5], maxlength: 50, hasError: /*error*/ ctx[14] != null, fill: true, isPaymentForm: true, onFocus: /*onFocus*/ ctx[27], onBlur: /*onBlur*/ ctx[28], $$slots: { default: [create_default_slot$4] }, $$scope: { ctx } } }); input.$on("change", /*change_handler*/ ctx[34]); return { c() { div = element("div"); create_component(input.$$.fragment); attr(div, "class", "zephr-form-relative-container zephr-form-promo-input zephr-form-relative-container zephr-payment-form-promo-input"); }, m(target, anchor) { insert(target, div, anchor); mount_component(input, div, null); current = true; }, p(ctx, dirty) { const input_changes = {}; if (dirty[0] & /*promoCode*/ 2048) input_changes.value = /*promoCode*/ ctx[11]; if (dirty[0] & /*promoCodePlaceholder*/ 32) input_changes.placeholder = /*promoCodePlaceholder*/ ctx[5]; if (dirty[0] & /*error*/ 16384) input_changes.hasError = /*error*/ ctx[14] != null; if (dirty[0] & /*onFocus*/ 134217728) input_changes.onFocus = /*onFocus*/ ctx[27]; if (dirty[0] & /*onBlur*/ 268435456) input_changes.onBlur = /*onBlur*/ ctx[28]; if (dirty[0] & /*promoCodeValid, busy, error*/ 53248 | dirty[1] & /*$$scope*/ 8192) { input_changes.$$scope = { dirty, ctx }; } input.$set(input_changes); }, i(local) { if (current) return; transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(input.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(input); } }; } // (111:10) {#if paymentProcessed && promoCode} function create_if_block_8$2(ctx) { let span; let t; return { c() { span = element("span"); t = text(/*promoCode*/ ctx[11]); attr(span, "class", "zephr-form-summary-promo-middle zephr-payment-form-summary-promo-middle svelte-xf8v79"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty[0] & /*promoCode*/ 2048) set_data(t, /*promoCode*/ ctx[11]); }, i: noop, o: noop, d(detaching) { if (detaching) { detach(span); } } }; } // (134:43) function create_if_block_11$2(ctx) { let fa; let current; fa = new Fa({ props: { icon: faSpinner, spin: true } }); return { c() { create_component(fa.$$.fragment); }, m(target, anchor) { mount_component(fa, target, anchor); current = true; }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { destroy_component(fa, detaching); } }; } // (132:18) {#if promoCodeValid} function create_if_block_10$2(ctx) { let fa; let current; fa = new Fa({ props: { icon: faCheck } }); return { c() { create_component(fa.$$.fragment); }, m(target, anchor) { mount_component(fa, target, anchor); current = true; }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { destroy_component(fa, detaching); } }; } // (119:14) onChangePromoCode(detail)} onFocus={onFocus} onBlur={onBlur} > function create_default_slot$4(ctx) { let div; let current_block_type_index; let if_block; let current; const if_block_creators = [create_if_block_10$2, create_if_block_11$2]; const if_blocks = []; function select_block_type_1(ctx, dirty) { if (/*promoCodeValid*/ ctx[12]) return 0; if (/*busy*/ ctx[15] && !/*error*/ ctx[14]) return 1; return -1; } if (~(current_block_type_index = select_block_type_1(ctx))) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); } return { c() { div = element("div"); if (if_block) if_block.c(); attr(div, "class", "zephr-form-input-inner-text zephr-payment-form-input-inner-text zephr-form-input-inner-button"); }, m(target, anchor) { insert(target, div, anchor); if (~current_block_type_index) { if_blocks[current_block_type_index].m(div, null); } current = true; }, p(ctx, dirty) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type_1(ctx); if (current_block_type_index !== previous_block_index) { if (if_block) { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); } if (~current_block_type_index) { if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } transition_in(if_block, 1); if_block.m(div, null); } else { if_block = null; } } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(div); } if (~current_block_type_index) { if_blocks[current_block_type_index].d(); } } }; } // (153:38) function create_if_block_7$2(ctx) { let button; let current; button = new Button({ props: { disabled: /*promoCodeDisabled*/ ctx[16], text: /*promoCodeButtonText*/ ctx[6], onClick: /*verifyPromoCode*/ ctx[26], noMargin: true, inputHeight: true, isPaymentForm: true } }); return { c() { create_component(button.$$.fragment); }, m(target, anchor) { mount_component(button, target, anchor); current = true; }, p(ctx, dirty) { const button_changes = {}; if (dirty[0] & /*promoCodeDisabled*/ 65536) button_changes.disabled = /*promoCodeDisabled*/ ctx[16]; if (dirty[0] & /*promoCodeButtonText*/ 64) button_changes.text = /*promoCodeButtonText*/ ctx[6]; if (dirty[0] & /*verifyPromoCode*/ 67108864) button_changes.onClick = /*verifyPromoCode*/ ctx[26]; button.$set(button_changes); }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { destroy_component(button, detaching); } }; } // (147:10) {#if promoCodeValid} function create_if_block_5$6(ctx) { let span; let if_block = /*showPromoCodeDiscountAmount*/ ctx[0] && create_if_block_6$6(ctx); return { c() { span = element("span"); if (if_block) if_block.c(); attr(span, "class", "zephr-form-summary-promo-middle zephr-payment-form-summary-promo-middle svelte-xf8v79"); }, m(target, anchor) { insert(target, span, anchor); if (if_block) if_block.m(span, null); }, p(ctx, dirty) { if (/*showPromoCodeDiscountAmount*/ ctx[0]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_6$6(ctx); if_block.c(); if_block.m(span, null); } } else if (if_block) { if_block.d(1); if_block = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(span); } if (if_block) if_block.d(); } }; } // (149:14) {#if showPromoCodeDiscountAmount} function create_if_block_6$6(ctx) { let t0; let t1; return { c() { t0 = text("- "); t1 = text(/*discountAmount*/ ctx[13]); }, m(target, anchor) { insert(target, t0, anchor); insert(target, t1, anchor); }, p(ctx, dirty) { if (dirty[0] & /*discountAmount*/ 8192) set_data(t1, /*discountAmount*/ ctx[13]); }, d(detaching) { if (detaching) { detach(t0); detach(t1); } } }; } // (165:6) {#if error} function create_if_block_4$8(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: /*error*/ ctx[14], isPaymentForm: true } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p(ctx, dirty) { const errormessage_changes = {}; if (dirty[0] & /*error*/ 16384) errormessage_changes.error = /*error*/ ctx[14]; errormessage.$set(errormessage_changes); }, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } // (178:2) {#if prorateDisclaimer} function create_if_block_1$o(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*prorateDisclaimer*/ ctx[10]); attr(div, "class", "zephr-form-summary-prorate-disclaimer zephr-payment-form-summary-prorate-disclaimer svelte-xf8v79"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty[0] & /*prorateDisclaimer*/ 1024) set_data(t, /*prorateDisclaimer*/ ctx[10]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (183:2) {#if changeSubscriptionProrate} function create_if_block$y(ctx) { let div2; let div0; let t0_value = (/*prorateLabel*/ ctx[9] ?? "DUE TODAY") + ""; let t0; let t1; let div1; let t2_value = /*changeSubscriptionProrate*/ ctx[20].totalPriceFormattedString + ""; let t2; return { c() { div2 = element("div"); div0 = element("div"); t0 = text(t0_value); t1 = space(); div1 = element("div"); t2 = text(t2_value); attr(div0, "class", "zephr-form-summary-line-total-title zephr-payment-form-summary-line-total-title"); attr(div1, "class", "zephr-form-summary-line-price zephr-payment-form-summary-line-price svelte-xf8v79"); attr(div2, "class", "zephr-form-summary-line zephr-form-summary-price-line zephr-payment-form-summary-line zephr-payment-form-summary-price-line svelte-xf8v79"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div0); append(div0, t0); append(div2, t1); append(div2, div1); append(div1, t2); }, p(ctx, dirty) { if (dirty[0] & /*prorateLabel*/ 512 && t0_value !== (t0_value = (/*prorateLabel*/ ctx[9] ?? "DUE TODAY") + "")) set_data(t0, t0_value); if (dirty[0] & /*changeSubscriptionProrate*/ 1048576 && t2_value !== (t2_value = /*changeSubscriptionProrate*/ ctx[20].totalPriceFormattedString + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div2); } } }; } function create_fragment$J(ctx) { let div7; let div0; let t0; let t1; let div3; let div1; let t2; let t3; let div2; let t4; let t5; let t6; let t7; let t8; let t9; let t10; let div6; let div4; let t11; let t12; let div5; let t13; let t14; let t15; let current; let each_value_2 = ensure_array_like(/*chargeItems*/ ctx[19]); let each_blocks_1 = []; for (let i = 0; i 0 && create_if_block_14$2(ctx); let if_block1 = /*tax*/ ctx[21] && create_if_block_13$2(ctx); let each_value = ensure_array_like(/*addons*/ ctx[18]); let each_blocks = []; for (let i = 0; i 0) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_14$2(ctx); if_block0.c(); if_block0.m(div7, t7); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*tax*/ ctx[21]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_13$2(ctx); if_block1.c(); if_block1.m(div7, t8); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (dirty[0] & /*addons*/ 262144) { each_value = ensure_array_like(/*addons*/ ctx[18]); let i; for (i = 0; i { if_block2 = null; }); check_outros(); } if (!current || dirty[0] & /*totalLabel*/ 256) set_data(t11, /*totalLabel*/ ctx[8]); if (!current || dirty[0] & /*totalPrice*/ 4) set_data(t13, /*totalPrice*/ ctx[2]); if (/*prorateDisclaimer*/ ctx[10]) { if (if_block3) { if_block3.p(ctx, dirty); } else { if_block3 = create_if_block_1$o(ctx); if_block3.c(); if_block3.m(div7, t15); } } else if (if_block3) { if_block3.d(1); if_block3 = null; } if (/*changeSubscriptionProrate*/ ctx[20]) { if (if_block4) { if_block4.p(ctx, dirty); } else { if_block4 = create_if_block$y(ctx); if_block4.c(); if_block4.m(div7, null); } } else if (if_block4) { if_block4.d(1); if_block4 = null; } }, i(local) { if (current) return; transition_in(if_block2); current = true; }, o(local) { transition_out(if_block2); current = false; }, d(detaching) { if (detaching) { detach(div7); } destroy_each(each_blocks_1, detaching); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); destroy_each(each_blocks, detaching); if (if_block2) if_block2.d(); if (if_block3) if_block3.d(); if (if_block4) if_block4.d(); } }; } function instance$J($$self, $$props, $$invalidate) { let displayPrice; let { showPromoCodeDiscountAmount = true } = $$props; let { planTitle } = $$props; let { price } = $$props; let { totalPrice } = $$props; let { allowPromoCodes } = $$props; let { promoCodeLinkText } = $$props; let { promoCodePlaceholder } = $$props; let { promoCodeButtonText } = $$props; let { title } = $$props; let { totalLabel } = $$props; let { prorateLabel } = $$props; let { prorateDisclaimer } = $$props; let { promoCode } = $$props; let { promoCodeValid } = $$props; let { discountAmount } = $$props; let { error = null } = $$props; let { busy } = $$props; let { promoCodeDisabled } = $$props; let { paymentProcessed } = $$props; let { addons } = $$props; let { chargeItems } = $$props; let { changeSubscriptionProrate } = $$props; let { tax } = $$props; let { taxLabel } = $$props; let { subTotal } = $$props; let { discounts = [] } = $$props; let { paymentProvider = '' } = $$props; let { onChangePromoCode } = $$props; let { verifyPromoCode } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; let showPromoCode = false; const click_handler = () => $$invalidate(29, showPromoCode = true); const change_handler = ({ detail }) => onChangePromoCode(detail); $$self.$$set = $$props => { if ('showPromoCodeDiscountAmount' in $$props) $$invalidate(0, showPromoCodeDiscountAmount = $$props.showPromoCodeDiscountAmount); if ('planTitle' in $$props) $$invalidate(1, planTitle = $$props.planTitle); if ('price' in $$props) $$invalidate(31, price = $$props.price); if ('totalPrice' in $$props) $$invalidate(2, totalPrice = $$props.totalPrice); if ('allowPromoCodes' in $$props) $$invalidate(3, allowPromoCodes = $$props.allowPromoCodes); if ('promoCodeLinkText' in $$props) $$invalidate(4, promoCodeLinkText = $$props.promoCodeLinkText); if ('promoCodePlaceholder' in $$props) $$invalidate(5, promoCodePlaceholder = $$props.promoCodePlaceholder); if ('promoCodeButtonText' in $$props) $$invalidate(6, promoCodeButtonText = $$props.promoCodeButtonText); if ('title' in $$props) $$invalidate(7, title = $$props.title); if ('totalLabel' in $$props) $$invalidate(8, totalLabel = $$props.totalLabel); if ('prorateLabel' in $$props) $$invalidate(9, prorateLabel = $$props.prorateLabel); if ('prorateDisclaimer' in $$props) $$invalidate(10, prorateDisclaimer = $$props.prorateDisclaimer); if ('promoCode' in $$props) $$invalidate(11, promoCode = $$props.promoCode); if ('promoCodeValid' in $$props) $$invalidate(12, promoCodeValid = $$props.promoCodeValid); if ('discountAmount' in $$props) $$invalidate(13, discountAmount = $$props.discountAmount); if ('error' in $$props) $$invalidate(14, error = $$props.error); if ('busy' in $$props) $$invalidate(15, busy = $$props.busy); if ('promoCodeDisabled' in $$props) $$invalidate(16, promoCodeDisabled = $$props.promoCodeDisabled); if ('paymentProcessed' in $$props) $$invalidate(17, paymentProcessed = $$props.paymentProcessed); if ('addons' in $$props) $$invalidate(18, addons = $$props.addons); if ('chargeItems' in $$props) $$invalidate(19, chargeItems = $$props.chargeItems); if ('changeSubscriptionProrate' in $$props) $$invalidate(20, changeSubscriptionProrate = $$props.changeSubscriptionProrate); if ('tax' in $$props) $$invalidate(21, tax = $$props.tax); if ('taxLabel' in $$props) $$invalidate(22, taxLabel = $$props.taxLabel); if ('subTotal' in $$props) $$invalidate(32, subTotal = $$props.subTotal); if ('discounts' in $$props) $$invalidate(23, discounts = $$props.discounts); if ('paymentProvider' in $$props) $$invalidate(24, paymentProvider = $$props.paymentProvider); if ('onChangePromoCode' in $$props) $$invalidate(25, onChangePromoCode = $$props.onChangePromoCode); if ('verifyPromoCode' in $$props) $$invalidate(26, verifyPromoCode = $$props.verifyPromoCode); if ('onFocus' in $$props) $$invalidate(27, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(28, onBlur = $$props.onBlur); }; $$self.$$.update = () => { if ($$self.$$.dirty[0] & /*chargeItems*/ 524288 | $$self.$$.dirty[1] & /*subTotal, price*/ 3) { $$invalidate(30, displayPrice = chargeItems.length ? "" : subTotal || price); } }; return [ showPromoCodeDiscountAmount, planTitle, totalPrice, allowPromoCodes, promoCodeLinkText, promoCodePlaceholder, promoCodeButtonText, title, totalLabel, prorateLabel, prorateDisclaimer, promoCode, promoCodeValid, discountAmount, error, busy, promoCodeDisabled, paymentProcessed, addons, chargeItems, changeSubscriptionProrate, tax, taxLabel, discounts, paymentProvider, onChangePromoCode, verifyPromoCode, onFocus, onBlur, showPromoCode, displayPrice, price, subTotal, click_handler, change_handler ]; } class PaymentSummary extends SvelteComponent { constructor(options) { super(); init( this, options, instance$J, create_fragment$J, safe_not_equal, { showPromoCodeDiscountAmount: 0, planTitle: 1, price: 31, totalPrice: 2, allowPromoCodes: 3, promoCodeLinkText: 4, promoCodePlaceholder: 5, promoCodeButtonText: 6, title: 7, totalLabel: 8, prorateLabel: 9, prorateDisclaimer: 10, promoCode: 11, promoCodeValid: 12, discountAmount: 13, error: 14, busy: 15, promoCodeDisabled: 16, paymentProcessed: 17, addons: 18, chargeItems: 19, changeSubscriptionProrate: 20, tax: 21, taxLabel: 22, subTotal: 32, discounts: 23, paymentProvider: 24, onChangePromoCode: 25, verifyPromoCode: 26, onFocus: 27, onBlur: 28 }, null, [-1, -1] ); } } const factory$h = { matches: (sectionElement) => sectionElement.type === elementTypes.PAYMENT_SUMMARY, create: (form, formState, formActions, elementConfig) => { const paymentProviderConfig = paymentProviderFor(form.organisationConfiguration.paymentProvider); return { component: PaymentSummary, props: { showPromoCodeDiscountAmount: !formConfigAs(form).dynamicOffer, price: formState.paymentOptionPrices?.netPriceFormattedString ?? '-', totalPrice: formState.paymentOptionPrices?.totalPriceFormattedString ?? '-', tax: formState.paymentOptionPrices?.taxPriceFormattedString, taxLabel: elementConfig.taxLabel ?? "Tax", subTotal: formState.paymentOptionPrices?.netPriceFormattedString, planTitle: formState.paymentOption.label, paymentProvider: form.organisationConfiguration.paymentProvider, // If we're using braintree we will need the full discounts array to display each discount discounts: form.organisationConfiguration.paymentProvider === 'braintree' ? (formConfigAs(form).paymentOptions .find(opt => opt.productId === formState.paymentOption.productId && opt.slug === formState.paymentOption.slug) ?.discounts || []) .map(discount => ({ description: discount.description || discount.name, formattedAmount: `- ${formatCurrency(discount.amount || 0, formState.paymentOption.currencyCode)}` })) : [], allowPromoCodes: (formConfigAs(form).promoCodeConfig?.promoCodeAllowed || formConfigAs(form).dynamicOffer /* TODO temp just for customer demo */) && paymentProviderConfig.hasPromoCodes(form), promoCodeLinkText: formConfigAs(form).promoCodeConfig?.promoCodeText, promoCodePlaceholder: formConfigAs(form).promoCodeConfig?.promoCodePlaceholder, promoCodeButtonText: formConfigAs(form).promoCodeConfig?.promoCodeButtonText, totalLabel: elementConfig.total, prorateLabel: elementConfig.prorateLabel, prorateDisclaimer: (!formConfigAs(form).changeSubscriptionMode || paymentProviderConfig.changeSubscriptionProrateCalculator) ? null : elementConfig.prorateDisclaimer, title: elementConfig.title, promoCode: formState.promoCode, busy: formState.isBusyByKey[verifyingPromoCodeBusyKey], promoCodeDisabled: formState.isBusy || formState.promoCode?.length === 0, paymentProcessed: formState.paymentProcessed, discountAmount: formState.paymentOptionPrices?.discountPriceFormattedPrice ?? '-', addons: addonsForPlan(formState) .map(addon => ({ label: addon.label, addonPrice: formatCurrency(addon.addonPrice, formState.paymentOption.currencyCode) })), chargeItems: formState.paymentOptionPrices?.chargeItems ?? [], promoCodeValid: formState.promoCodeValid, changeSubscriptionProrate: formState.changeSubscriptionProrate, onChangePromoCode: (value) => { let updateFormState = formActions.updateFormState({ promoCode: value, promoCodeValid: undefined, discountedPlanPrices: [] }); // If we're going from a valid promo code -> incomplete promo code, the mobile payment button needs resetting if (formState.promoCodeValid) { if (formState.originalDynamicOfferResult) { updateFormState = formActions.updateFormState({ dynamicOfferResult: formState.originalDynamicOfferResult }); } void afterPromoCodeChange(form, updateFormState, formActions); } logDataLayerEvent(form, 'zephr_form_input_change', { inputName: 'zephr-form-promo-code', sectionId: formState.currentSection.type, field: 'promo-code' }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: 'zephr-form-promo-code', sectionId: formState.currentSection.type, field: 'promo-code' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: 'zephr-form-promo-code', sectionId: formState.currentSection.type, field: 'promo-code' }), verifyPromoCode: () => { void validatePromoCode(form, formState, formActions); } } }; } }; /* src/components/elements/divider/Divider.svelte generated by Svelte v4.2.12 */ function create_if_block$x(ctx) { let div; let t0; let t1; let if_block0 = /*showLine*/ ctx[1] && create_if_block_3$9(ctx); let if_block1 = /*text*/ ctx[0] && create_if_block_2$e(ctx); let if_block2 = /*showLine*/ ctx[1] && /*text*/ ctx[0] && create_if_block_1$n(ctx); return { c() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); attr(div, "class", "zephr-form-divider-container svelte-1jhhsfx"); toggle_class(div, "zephr-payment-form-divider-container", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div, anchor); if (if_block0) if_block0.m(div, null); append(div, t0); if (if_block1) if_block1.m(div, null); append(div, t1); if (if_block2) if_block2.m(div, null); }, p(ctx, dirty) { if (/*showLine*/ ctx[1]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_3$9(ctx); if_block0.c(); if_block0.m(div, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*text*/ ctx[0]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_2$e(ctx); if_block1.c(); if_block1.m(div, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (/*showLine*/ ctx[1] && /*text*/ ctx[0]) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block_1$n(ctx); if_block2.c(); if_block2.m(div, null); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } if (dirty & /*isPaymentForm*/ 8) { toggle_class(div, "zephr-payment-form-divider-container", /*isPaymentForm*/ ctx[3]); } }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); } }; } // (12:4) {#if showLine} function create_if_block_3$9(ctx) { let if_block_anchor; function select_block_type(ctx, dirty) { if (/*text*/ ctx[0]) return create_if_block_4$7; return create_else_block$4; } let current_block_type = select_block_type(ctx); let if_block = current_block_type(ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, dirty) { if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) { if_block.p(ctx, dirty); } else { if_block.d(1); if_block = current_block_type(ctx); if (if_block) { if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } }, d(detaching) { if (detaching) { detach(if_block_anchor); } if_block.d(detaching); } }; } // (18:8) {:else} function create_else_block$4(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "zephr-form-divider-line-complete svelte-1jhhsfx"); }, m(target, anchor) { insert(target, div, anchor); }, p: noop, d(detaching) { if (detaching) { detach(div); } } }; } // (13:6) {#if text} function create_if_block_4$7(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "zephr-form-divider-line svelte-1jhhsfx"); toggle_class(div, "zephr-payment-form-divider-line", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div, anchor); }, p(ctx, dirty) { if (dirty & /*isPaymentForm*/ 8) { toggle_class(div, "zephr-payment-form-divider-line", /*isPaymentForm*/ ctx[3]); } }, d(detaching) { if (detaching) { detach(div); } } }; } // (22:4) {#if text} function create_if_block_2$e(ctx) { let span; let t; return { c() { span = element("span"); t = text(/*text*/ ctx[0]); attr(span, "class", "zephr-form-divider-text svelte-1jhhsfx"); toggle_class(span, "zephr-payment-form-divider-text", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty & /*text*/ 1) set_data(t, /*text*/ ctx[0]); if (dirty & /*isPaymentForm*/ 8) { toggle_class(span, "zephr-payment-form-divider-text", /*isPaymentForm*/ ctx[3]); } }, d(detaching) { if (detaching) { detach(span); } } }; } // (30:4) {#if showLine && text} function create_if_block_1$n(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "zephr-form-divider-line svelte-1jhhsfx"); toggle_class(div, "zephr-payment-form-divider-line", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div, anchor); }, p(ctx, dirty) { if (dirty & /*isPaymentForm*/ 8) { toggle_class(div, "zephr-payment-form-divider-line", /*isPaymentForm*/ ctx[3]); } }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$I(ctx) { let if_block_anchor; let if_block = /*show*/ ctx[2] && create_if_block$x(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, [dirty]) { if (/*show*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$x(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$I($$self, $$props, $$invalidate) { let { text } = $$props; let { showLine } = $$props; let { show } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('showLine' in $$props) $$invalidate(1, showLine = $$props.showLine); if ('show' in $$props) $$invalidate(2, show = $$props.show); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); }; return [text, showLine, show, isPaymentForm]; } class Divider extends SvelteComponent { constructor(options) { super(); init(this, options, instance$I, create_fragment$I, safe_not_equal, { text: 0, showLine: 1, show: 2, isPaymentForm: 3 }); } } const factory$g = { matches: (sectionElement) => sectionElement.type === elementTypes.DIVIDER, create: (form, formState, formActions, elementConfig) => ({ component: Divider, props: { text: elementConfig.text, showLine: elementConfig.showLine, show: elementConfig.show, isPaymentForm: form.formType === FormType.PAYMENT, } }) }; /* src/components/elements/loginLink/LoginLink.svelte generated by Svelte v4.2.12 */ function create_fragment$H(ctx) { let div; let t0; let t1; let a; let t2; return { c() { div = element("div"); t0 = text(/*text*/ ctx[0]); t1 = space(); a = element("a"); t2 = text(/*linkText*/ ctx[1]); attr(a, "href", /*url*/ ctx[2]); attr(a, "class", "svelte-1jmemom"); attr(div, "class", "zephr-form-login-link svelte-1jmemom"); toggle_class(div, "zephr-payment-login-link", /*isPaymentForm*/ ctx[3]); }, m(target, anchor) { insert(target, div, anchor); append(div, t0); append(div, t1); append(div, a); append(a, t2); }, p(ctx, [dirty]) { if (dirty & /*text*/ 1) set_data(t0, /*text*/ ctx[0]); if (dirty & /*linkText*/ 2) set_data(t2, /*linkText*/ ctx[1]); if (dirty & /*url*/ 4) { attr(a, "href", /*url*/ ctx[2]); } if (dirty & /*isPaymentForm*/ 8) { toggle_class(div, "zephr-payment-login-link", /*isPaymentForm*/ ctx[3]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } } }; } function instance$H($$self, $$props, $$invalidate) { let { text } = $$props; let { linkText } = $$props; let { url } = $$props; let { isPaymentForm = false } = $$props; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('linkText' in $$props) $$invalidate(1, linkText = $$props.linkText); if ('url' in $$props) $$invalidate(2, url = $$props.url); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); }; return [text, linkText, url, isPaymentForm]; } class LoginLink extends SvelteComponent { constructor(options) { super(); init(this, options, instance$H, create_fragment$H, safe_not_equal, { text: 0, linkText: 1, url: 2, isPaymentForm: 3 }); } } const factory$f = { matches: (sectionElement) => sectionElement.type === elementTypes.LOGIN_LINK, create: (form, formState, formActions, elementConfig) => ({ component: LoginLink, props: { text: elementConfig.alreadyRegText, linkText: elementConfig.loginText, url: elementConfig.url, isPaymentForm: form.formType === FormType.PAYMENT, } }) }; const factory$e = { matches: (sectionElement) => sectionElement.type === elementTypes.BUTTON && sectionElement.config.isLogin, create: (form, formState, formActions, elementConfig) => ({ component: Button, props: { disabled: formState.isBusy, text: elementConfig.text, onClick: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.updateFormState({ forgotPassword: false, }); formActions.jumpToPartStart(partTypes.ACCOUNT_VERIFICATION.type); }, isPaymentForm: form.formType === FormType.PAYMENT, } }) }; const factory$d = { matches: (sectionElement) => sectionElement.type === elementTypes.BUTTON && sectionElement.config.isCancel, create: (form, formState, formActions, elementConfig) => ({ component: Button, props: { text: elementConfig.text, onClick: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.updateFormState({ confirmCancel: true, }); formActions.completeSection(); }, } }) }; /* src/components/elements/accountMembershipCode/AccountMembershipCode.svelte generated by Svelte v4.2.12 */ function create_if_block_1$m(ctx) { let link; let current; link = new Link({ props: { text: /*label*/ ctx[0] } }); link.$on("linkClick", /*linkClick_handler*/ ctx[10]); return { c() { create_component(link.$$.fragment); }, m(target, anchor) { mount_component(link, target, anchor); current = true; }, p(ctx, dirty) { const link_changes = {}; if (dirty & /*label*/ 1) link_changes.text = /*label*/ ctx[0]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { destroy_component(link, detaching); } }; } // (23:2) {#if accountMembershipCode || showInput} function create_if_block$w(ctx) { let label_1; let t; let input; let current; label_1 = new Label({ props: { forInput: /*id*/ ctx[8], label: /*label*/ ctx[0] } }); input = new Input({ props: { id: /*id*/ ctx[8], value: /*accountMembershipCode*/ ctx[2], errorMessage: /*error*/ ctx[3], placeholder: /*placeholder*/ ctx[1], onFocus: /*onFocus*/ ctx[5], onBlur: /*onBlur*/ ctx[6] } }); input.$on("change", /*change_handler*/ ctx[11]); return { c() { create_component(label_1.$$.fragment); t = space(); create_component(input.$$.fragment); }, m(target, anchor) { mount_component(label_1, target, anchor); insert(target, t, anchor); mount_component(input, target, anchor); current = true; }, p(ctx, dirty) { const label_1_changes = {}; if (dirty & /*label*/ 1) label_1_changes.label = /*label*/ ctx[0]; label_1.$set(label_1_changes); const input_changes = {}; if (dirty & /*accountMembershipCode*/ 4) input_changes.value = /*accountMembershipCode*/ ctx[2]; if (dirty & /*error*/ 8) input_changes.errorMessage = /*error*/ ctx[3]; if (dirty & /*placeholder*/ 2) input_changes.placeholder = /*placeholder*/ ctx[1]; if (dirty & /*onFocus*/ 32) input_changes.onFocus = /*onFocus*/ ctx[5]; if (dirty & /*onBlur*/ 64) input_changes.onBlur = /*onBlur*/ ctx[6]; input.$set(input_changes); }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(input.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t); } destroy_component(label_1, detaching); destroy_component(input, detaching); } }; } function create_fragment$G(ctx) { let div; let t; let current; let if_block0 = !/*showInput*/ ctx[7] && create_if_block_1$m(ctx); let if_block1 = (/*accountMembershipCode*/ ctx[2] || /*showInput*/ ctx[7]) && create_if_block$w(ctx); return { c() { div = element("div"); if (if_block0) if_block0.c(); t = space(); if (if_block1) if_block1.c(); attr(div, "class", "zephr-form-account-code-container svelte-1hhep92"); }, m(target, anchor) { insert(target, div, anchor); if (if_block0) if_block0.m(div, null); append(div, t); if (if_block1) if_block1.m(div, null); current = true; }, p(ctx, [dirty]) { if (!/*showInput*/ ctx[7]) { if (if_block0) { if_block0.p(ctx, dirty); if (dirty & /*showInput*/ 128) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_1$m(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div, t); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (/*accountMembershipCode*/ ctx[2] || /*showInput*/ ctx[7]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*accountMembershipCode, showInput*/ 132) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$w(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); } }; } function instance$G($$self, $$props, $$invalidate) { let { formKey } = $$props; let { label } = $$props; let { placeholder } = $$props; let { accountMembershipCode } = $$props; let { error = null } = $$props; let { onChange } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; let showInput = false; const id = `zephr-form-account-code-${formKey}`; const linkClick_handler = () => $$invalidate(7, showInput = true); const change_handler = value => onChange(value.detail); $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(9, formKey = $$props.formKey); if ('label' in $$props) $$invalidate(0, label = $$props.label); if ('placeholder' in $$props) $$invalidate(1, placeholder = $$props.placeholder); if ('accountMembershipCode' in $$props) $$invalidate(2, accountMembershipCode = $$props.accountMembershipCode); if ('error' in $$props) $$invalidate(3, error = $$props.error); if ('onChange' in $$props) $$invalidate(4, onChange = $$props.onChange); if ('onFocus' in $$props) $$invalidate(5, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(6, onBlur = $$props.onBlur); }; return [ label, placeholder, accountMembershipCode, error, onChange, onFocus, onBlur, showInput, id, formKey, linkClick_handler, change_handler ]; } class AccountMembershipCode extends SvelteComponent { constructor(options) { super(); init(this, options, instance$G, create_fragment$G, safe_not_equal, { formKey: 9, label: 0, placeholder: 1, accountMembershipCode: 2, error: 3, onChange: 4, onFocus: 5, onBlur: 6 }); } } const factory$c = { matches: (sectionElement) => sectionElement.type === elementTypes.ACCOUNT_MEMBERSHIP_CODE, create: (form, formState, formActions, elementConfig) => ({ component: AccountMembershipCode, props: { formKey: form.uniqueKey, label: elementConfig.label, placeholder: elementConfig.placeholder, accountMembershipCode: formState.accountMembershipCode, onChange: (value) => { formActions.updateFormState({ accountMembershipCode: value, serverErrors: [], }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: `zephr-form-account-code-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'account-code' }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: `zephr-form-account-code-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'account-code' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: `zephr-form-account-code-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'account-code' }), } }) }; /* src/components/elements/invitation/Invitation.svelte generated by Svelte v4.2.12 */ function create_if_block$v(ctx) { let div; let successmessage; let current; successmessage = new SuccessMessage({ props: { text: /*linkSentText*/ ctx[4] } }); return { c() { div = element("div"); create_component(successmessage.$$.fragment); attr(div, "class", "zephr-form-invitation-success-message svelte-1qkv7d3"); }, m(target, anchor) { insert(target, div, anchor); mount_component(successmessage, div, null); current = true; }, p(ctx, dirty) { const successmessage_changes = {}; if (dirty & /*linkSentText*/ 16) successmessage_changes.text = /*linkSentText*/ ctx[4]; successmessage.$set(successmessage_changes); }, i(local) { if (current) return; transition_in(successmessage.$$.fragment, local); current = true; }, o(local) { transition_out(successmessage.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(successmessage); } }; } function create_fragment$F(ctx) { let div4; let div0; let t0; let t1; let div1; let t2; let t3; let label_1; let t4; let div3; let div2; let input; let t5; let button; let t6; let current; label_1 = new Label({ props: { forInput: /*id*/ ctx[14], label: /*label*/ ctx[2], isPaymentForm: /*isPaymentForm*/ ctx[11] } }); input = new Input({ props: { disabled: /*isBusy*/ ctx[10], required: true, id: /*id*/ ctx[14], value: /*invitationEmail*/ ctx[7] ?? '', errorMessage: /*error*/ ctx[9], isPaymentForm: /*isPaymentForm*/ ctx[11], onFocus: /*onFocus*/ ctx[12], onBlur: /*onBlur*/ ctx[13] } }); input.$on("change", /*change_handler*/ ctx[16]); button = new Button({ props: { disabled: !isValidEmail(/*invitationEmail*/ ctx[7]) || /*isBusy*/ ctx[10], text: /*btnText*/ ctx[3], onClick: /*onSendInviteClick*/ ctx[5], noMargin: true, inputHeight: true, aside: true, isPaymentForm: /*isPaymentForm*/ ctx[11] } }); let if_block = /*invitationSent*/ ctx[8] && create_if_block$v(ctx); return { c() { div4 = element("div"); div0 = element("div"); t0 = text(/*title*/ ctx[0]); t1 = space(); div1 = element("div"); t2 = text(/*description*/ ctx[1]); t3 = space(); create_component(label_1.$$.fragment); t4 = space(); div3 = element("div"); div2 = element("div"); create_component(input.$$.fragment); t5 = space(); create_component(button.$$.fragment); t6 = space(); if (if_block) if_block.c(); attr(div0, "class", "zephr-form-invitation-title svelte-1qkv7d3"); attr(div1, "class", "zephr-form-invitation-description"); attr(div2, "class", "zephr-form-invitation-input-container svelte-1qkv7d3"); attr(div3, "class", "zephr-form-relative-container zephr-form-invitation-email svelte-1qkv7d3"); toggle_class(div3, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[11]); attr(div4, "class", "zephr-form-invitation-container svelte-1qkv7d3"); }, m(target, anchor) { insert(target, div4, anchor); append(div4, div0); append(div0, t0); append(div4, t1); append(div4, div1); append(div1, t2); append(div4, t3); mount_component(label_1, div4, null); append(div4, t4); append(div4, div3); append(div3, div2); mount_component(input, div2, null); append(div3, t5); mount_component(button, div3, null); append(div4, t6); if (if_block) if_block.m(div4, null); current = true; }, p(ctx, [dirty]) { if (!current || dirty & /*title*/ 1) set_data(t0, /*title*/ ctx[0]); if (!current || dirty & /*description*/ 2) set_data(t2, /*description*/ ctx[1]); const label_1_changes = {}; if (dirty & /*label*/ 4) label_1_changes.label = /*label*/ ctx[2]; if (dirty & /*isPaymentForm*/ 2048) label_1_changes.isPaymentForm = /*isPaymentForm*/ ctx[11]; label_1.$set(label_1_changes); const input_changes = {}; if (dirty & /*isBusy*/ 1024) input_changes.disabled = /*isBusy*/ ctx[10]; if (dirty & /*invitationEmail*/ 128) input_changes.value = /*invitationEmail*/ ctx[7] ?? ''; if (dirty & /*error*/ 512) input_changes.errorMessage = /*error*/ ctx[9]; if (dirty & /*isPaymentForm*/ 2048) input_changes.isPaymentForm = /*isPaymentForm*/ ctx[11]; if (dirty & /*onFocus*/ 4096) input_changes.onFocus = /*onFocus*/ ctx[12]; if (dirty & /*onBlur*/ 8192) input_changes.onBlur = /*onBlur*/ ctx[13]; input.$set(input_changes); const button_changes = {}; if (dirty & /*invitationEmail, isBusy*/ 1152) button_changes.disabled = !isValidEmail(/*invitationEmail*/ ctx[7]) || /*isBusy*/ ctx[10]; if (dirty & /*btnText*/ 8) button_changes.text = /*btnText*/ ctx[3]; if (dirty & /*onSendInviteClick*/ 32) button_changes.onClick = /*onSendInviteClick*/ ctx[5]; if (dirty & /*isPaymentForm*/ 2048) button_changes.isPaymentForm = /*isPaymentForm*/ ctx[11]; button.$set(button_changes); if (!current || dirty & /*isPaymentForm*/ 2048) { toggle_class(div3, "zephr-payment-form-relative-container", /*isPaymentForm*/ ctx[11]); } if (/*invitationSent*/ ctx[8]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*invitationSent*/ 256) { transition_in(if_block, 1); } } else { if_block = create_if_block$v(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(div4, null); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(input.$$.fragment, local); transition_in(button.$$.fragment, local); transition_in(if_block); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(input.$$.fragment, local); transition_out(button.$$.fragment, local); transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(div4); } destroy_component(label_1); destroy_component(input); destroy_component(button); if (if_block) if_block.d(); } }; } function instance$F($$self, $$props, $$invalidate) { let { formKey } = $$props; let { title } = $$props; let { description } = $$props; let { label } = $$props; let { btnText } = $$props; let { linkSentText } = $$props; let { onSendInviteClick } = $$props; let { onChange } = $$props; let { invitationEmail } = $$props; let { invitationSent } = $$props; let { error = null } = $$props; let { isBusy } = $$props; let { isPaymentForm = false } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; const id = `zephr-form-invitation-email-${formKey}`; const change_handler = ({ detail }) => onChange(detail); $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(15, formKey = $$props.formKey); if ('title' in $$props) $$invalidate(0, title = $$props.title); if ('description' in $$props) $$invalidate(1, description = $$props.description); if ('label' in $$props) $$invalidate(2, label = $$props.label); if ('btnText' in $$props) $$invalidate(3, btnText = $$props.btnText); if ('linkSentText' in $$props) $$invalidate(4, linkSentText = $$props.linkSentText); if ('onSendInviteClick' in $$props) $$invalidate(5, onSendInviteClick = $$props.onSendInviteClick); if ('onChange' in $$props) $$invalidate(6, onChange = $$props.onChange); if ('invitationEmail' in $$props) $$invalidate(7, invitationEmail = $$props.invitationEmail); if ('invitationSent' in $$props) $$invalidate(8, invitationSent = $$props.invitationSent); if ('error' in $$props) $$invalidate(9, error = $$props.error); if ('isBusy' in $$props) $$invalidate(10, isBusy = $$props.isBusy); if ('isPaymentForm' in $$props) $$invalidate(11, isPaymentForm = $$props.isPaymentForm); if ('onFocus' in $$props) $$invalidate(12, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(13, onBlur = $$props.onBlur); }; return [ title, description, label, btnText, linkSentText, onSendInviteClick, onChange, invitationEmail, invitationSent, error, isBusy, isPaymentForm, onFocus, onBlur, id, formKey, change_handler ]; } class Invitation extends SvelteComponent { constructor(options) { super(); init(this, options, instance$F, create_fragment$F, safe_not_equal, { formKey: 15, title: 0, description: 1, label: 2, btnText: 3, linkSentText: 4, onSendInviteClick: 5, onChange: 6, invitationEmail: 7, invitationSent: 8, error: 9, isBusy: 10, isPaymentForm: 11, onFocus: 12, onBlur: 13 }); } } const mapToError = (e) => { if (e?.status === 403 && e?.message?.includes('you do not have access to')) { return ServerError.INVITATION_FAILED_NO_PRODUCT_ACCESS; } if (e?.status === 400 && e?.message?.includes('Invalid recipient email')) { return ServerError.INVITATION_FAILED_INVALID_EMAIL; } if (e?.status === 400 && e?.message?.includes('reached the configured limit')) { return ServerError.INVITATION_FAILED_LIMIT_REACHED; } if (e?.status === 409) { return ServerError.INVITATION_FAILED_DUPLICATE_EMAIL; } return ServerError.INVITATION_FAILED_UNKNOWN; }; const getUserProfile = (formActions) => request('blaize/profile', { method: "GET" }, formActions) .then(response => response.json()); const convertMapping = (mapping, profile) => (mapping ?? []).reduce((acc, curr) => { const value = profile[curr.attrSlug]; return { ...acc, [curr.fieldName]: value }; }, {}); const sendInvitationEmail = async (form, formState, formActions) => { let profile; if (formState.userExists) { profile = await getUserProfile(formActions); } else { profile = formState.userAttributes; } const profileConverted = convertMapping(formConfigAs(form).invitationMetadata.mapping, profile); const response = await request('zephr/public/products/v1/shares/invitations/emails', { method: "POST", bodyObject: { product_id: formState.paymentOption.productId, email_address: formState.invitationEmail, base_url: formConfigAs(form).invitationMetadata.url, meta_data: profileConverted, } }, formActions); const responseJson = (await response.json()); if (response.ok) { formActions.updateFormState({ invitationSent: true, invitationEmail: '', }); setTimeout(() => { formActions.updateFormState({ invitationSent: false, }); }, 3000); } else { const serverError = mapToError(responseJson); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); formActions.updateFormState({ invitationSent: false, serverErrors: [serverError], }); } }; const factory$b = { matches: (sectionElement) => sectionElement.type === elementTypes.INVITATION, create: (form, formState, formActions, elementConfig) => { if (formState.paymentOption?.product_sharing_limit > 0) { return { component: Invitation, props: { formKey: form.uniqueKey, title: elementConfig.title, description: elementConfig.description, label: elementConfig.label, btnText: elementConfig.btnText, linkSentText: elementConfig.linkSentText, onSendInviteClick: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); void sendInvitationEmail(form, formState, formActions); }, onChange: (value) => { formActions.updateFormState({ invitationEmail: value, serverErrors: [], }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: `zephr-form-invitation-email-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'invitation-email' }); }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: `zephr-form-invitation-email-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'invitation-email' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: `zephr-form-invitation-email-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'invitation-email' }), invitationEmail: formState.invitationEmail, invitationSent: formState.invitationSent, isBusy: formState.isBusy, isPaymentForm: form.formType === FormType.PAYMENT, } }; } return { component: null, props: {}, }; } }; /* src/components/elements/payment/EmptyPreLoader.svelte generated by Svelte v4.2.12 */ class EmptyPreLoader extends SvelteComponent { constructor(options) { super(); init(this, options, null, null, safe_not_equal, {}); } } const factory$a = { matches: (sectionElement) => sectionElement.type === elementTypes.PAYMENT_PRE_LOADER, create: (form, _, __) => { const paymentProvider = paymentProviderFor(form.organisationConfiguration.paymentProvider); if (paymentProvider.preLoaderComponent == null) { return { component: EmptyPreLoader, props: {}, }; } let component; const formConfig = formConfigAs(form); if (form.formType === FormType.CHANGE_SUBSCRIPTION && formConfig.allowNoPaymentMethodUpgrade) { const environment = formConfig.paymentOptions?.[0]?.virtualEnvironment || 'live'; component = paymentProvider.preLoaderComponent(formConfig.paymentMethodSetupFormConfig[environment]); } else { component = paymentProvider.preLoaderComponent(formConfig.paymentProviderFormConfig); } return { component, props: { onMountCallback: () => paymentProvider.preLoader() }, }; } }; /* src/components/elements/templateComponent/TemplateComponent.svelte generated by Svelte v4.2.12 */ function create_fragment$E(ctx) { let div; return { c() { div = element("div"); }, m(target, anchor) { insert(target, div, anchor); div.innerHTML = /*html*/ ctx[0]; }, p(ctx, [dirty]) { if (dirty & /*html*/ 1) div.innerHTML = /*html*/ ctx[0]; }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } } }; } function instance$E($$self, $$props, $$invalidate) { let { html } = $$props; $$self.$$set = $$props => { if ('html' in $$props) $$invalidate(0, html = $$props.html); }; return [html]; } class TemplateComponent extends SvelteComponent { constructor(options) { super(); init(this, options, instance$E, create_fragment$E, safe_not_equal, { html: 0 }); } } const randomId = () => (Math.random() + 1).toString(36).substring(7); // Unique ID for this instance of this form being rendered. const formInstanceId = randomId(); // Flatten the extra scope variables from DO and remove null values, as for null values the default // should be used const extractDoScopeVariables = (formState) => { if (!formState.dynamicOfferResult) { return {}; } return Object.entries({ tagline: formState.dynamicOfferResult.tagline, ...(formState.dynamicOfferResult.custom ?? {}) }).reduce((acc, [key, value]) => { if (key && value != null) { acc[key] = value; } return acc; }, {}); }; const renderTemplateComponent = (form, formState, formActions, templateElement) => { // Load the resolved template values const templateContent = (form.resolvedComponentTemplates ?? []).find(c => c.id === templateElement.templateId); if (!templateContent) { console.warn(`No component template found for id '${templateElement.templateId}'`); return ''; } // Pre-render const templateForm = prepareForm(form, formState, formActions, templateElement, templateContent); const preRenderScope = { ...(templateDefaultVariableScope(templateContent, false)), ...(templateElement.templateValues ?? {}), ...(extractDoScopeVariables(formState)), zephrForm: templateForm, zephrOutcomeId: form.outcomeId, zephrRuleId: form.ruleId, }; const scriptResult = runTemplateScript(form, formState, templateElement, templateForm, templateContent.preRenderScript, preRenderScope); // Assemble pre-render results for template rendering const scope = { ...preRenderScope, ...(scriptResult.scope ?? {}) }; templateForm.actions = scriptResult.actions ?? {}; attachFormRefToWindow(templateForm); // Render the template try { const html = mustache.render(` ${templateContent.css ? ` ${templateContent.css} ` : ''} ${templateContent.html ?? ""} `, scope); return html; } catch (e) { console.error('Error rendering mustache template', e); return ''; } }; const templateDefaultVariableScope = (template, paymentOptionLevel) => (template.templateVariables ?? []).reduce((prev, variable) => (variable.defaultValue == null || variable.paymentOptionLevel != paymentOptionLevel ? prev : { ...prev, [variable.key]: variable.defaultValue }), {}); const attachFormRefToWindow = (templateForm) => { if (!window.Zephr) { window.Zephr = {}; } if (!window.Zephr.forms) { window.Zephr.forms = {}; } window.Zephr.forms[templateForm.formInstanceId] = templateForm; }; const runTemplateScript = (form, formState, templateElement, templateForm, script, scope) => { if (!script) { return { scope: {}, actions: {} }; } try { // eslint-disable-next-line @typescript-eslint/no-implied-eval const templateScript = new Function('state', 'form', 'scope', script); const customState = (formState.customComponentState ?? {})[templateElement.id ?? '_']; const customStateWithDo = formState.dynamicOfferResult ? { ...(customState ?? {}), dynamicOfferResult: filterChangeSubDynamicOfferResponse(formState.dynamicOfferResult, form, formState) } : customState; return templateScript(customStateWithDo, templateForm, scope); } catch (e) { console.error('Error evaluating pre-render script', e); return { scope: { 'error': e }, actions: {} }; } }; const setState = (formState, formActions, elementId) => (state) => { formActions.updateFormState({ customComponentState: { ...(formState.customComponentState ?? {}), [elementId]: { ...((formState.customComponentState ?? {})[elementId] ?? {}), ...(state ?? {}) } } }); }; const selectPaymentOption = (form, formActions, formState, isDynamicOffer) => (productId, slug) => { let paymentOption; if (isDynamicOffer) { const product = formState .dynamicOfferResult.products.find((prod) => prod.id === productId); const paymentPlan = product ?.paymentPlans.find(plan => plan.planId === slug); paymentOption = { slug: paymentPlan.planId, productId: product.id, label: product.label, currencyCode: paymentPlan.charges[0].prices[0].currency, terms: paymentPlan.additionalPlanData?.terms, termsAndConditions: paymentPlan.additionalPlanData?.termsAndConditions, triggerOffsets: paymentPlan.additionalPlanData?.triggerOffsets, changeSubscriptionTriggerOffsets: paymentPlan.additionalPlanData?.changeSubscriptionTriggerOffsets, autoRenewConfig: paymentPlan.additionalPlanData?.autoRenewConfig || 'auto_renew', autoRenewToggleLabel: paymentPlan.additionalPlanData?.autoRenewToggleLabel }; } else { paymentOption = formConfigAs(form) .paymentOptions ?.find(o => o.productId === productId && o.slug === slug); } if (!paymentOption) { console.warn(`No payment option exists for ${productId} ${slug}.`); return; } const paymentOptionKey = `${paymentOption.productId}-${paymentOption.slug}`; const updateState = { paymentOption: paymentOption, serverErrors: [], billingAddress: { country: null, postalCode: null, } }; // Only initialize auto-renew state for payment options with custom_toggle config if (paymentOption.autoRenewConfig === 'custom_toggle') { updateState.paymentOptionAutoRenew = { ...formState.paymentOptionAutoRenew, [paymentOptionKey]: paymentOption.terms?.autoRenew ?? false }; } formActions.updateFormState(updateState); if (form.organisationConfiguration.trackFormDataLayerEvents) { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); } formActions.completeSection(); }; const prepareForm = (form, formState, formActions, templateElement, template) => { const isDynamicOffer = !!formConfigAs(form).dynamicOffer?.id; const paymentOptions = (formConfigAs(form).paymentOptions ?? []).map((p, i) => ({ slug: p.slug, productId: p.productId, label: p.label, price: p.price, currencyCode: p.currencyCode, formattedPrice: formatCurrency(p.price, p.currencyCode), index: i, ...(templateDefaultVariableScope(template, true)), ...(p.templateValues ?? {}), })); return { formId: form.id, formInstanceId, paymentOptions: paymentOptions, ref: `window.Zephr.forms['${formInstanceId}']`, setState: setState(formState, formActions, templateElement.id ?? '_'), getState: () => formActions.getFormState(), selectPaymentOption: selectPaymentOption(form, formActions, formState, isDynamicOffer) }; }; const factory$9 = { matches: (sectionElement) => sectionElement.type === elementTypes.TEMPLATE_COMPONENT, create: (form, formState, formActions, elementConfig) => { const renderedHtml = renderTemplateComponent(form, formState, formActions, elementConfig); return { component: TemplateComponent, props: { html: renderedHtml } }; } }; /* src/components/elements/subscriptionSelect/SubscriptionOption.svelte generated by Svelte v4.2.12 */ function create_if_block_3$8(ctx) { let div; let h3; let t_value = /*subscription*/ ctx[0].planLabel + ""; let t; return { c() { div = element("div"); h3 = element("h3"); t = text(t_value); attr(div, "class", "plan-label"); }, m(target, anchor) { insert(target, div, anchor); append(div, h3); append(h3, t); }, p(ctx, dirty) { if (dirty & /*subscription*/ 1 && t_value !== (t_value = /*subscription*/ ctx[0].planLabel + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (26:6) {#if subscription.amount && amountLabel} function create_if_block_2$d(ctx) { let hr; let t0; let div2; let div0; let t1; let t2; let div1; let t3_value = /*subscription*/ ctx[0].amount + ""; let t3; return { c() { hr = element("hr"); t0 = space(); div2 = element("div"); div0 = element("div"); t1 = text(/*amountLabel*/ ctx[2]); t2 = space(); div1 = element("div"); t3 = text(t3_value); attr(hr, "class", "svelte-1gr56ov"); attr(div0, "class", "info-label svelte-1gr56ov"); attr(div1, "class", "info svelte-1gr56ov"); attr(div2, "class", "info-row svelte-1gr56ov"); }, m(target, anchor) { insert(target, hr, anchor); insert(target, t0, anchor); insert(target, div2, anchor); append(div2, div0); append(div0, t1); append(div2, t2); append(div2, div1); append(div1, t3); }, p(ctx, dirty) { if (dirty & /*amountLabel*/ 4) set_data(t1, /*amountLabel*/ ctx[2]); if (dirty & /*subscription*/ 1 && t3_value !== (t3_value = /*subscription*/ ctx[0].amount + "")) set_data(t3, t3_value); }, d(detaching) { if (detaching) { detach(hr); detach(t0); detach(div2); } } }; } // (37:4) {#if subscription.nextBillingTime && nextBillingDateLabel} function create_if_block_1$l(ctx) { let hr; let t0; let div2; let div0; let t1; let t2; let div1; let t3_value = /*subscription*/ ctx[0].nextBillingTime + ""; let t3; return { c() { hr = element("hr"); t0 = space(); div2 = element("div"); div0 = element("div"); t1 = text(/*nextBillingDateLabel*/ ctx[3]); t2 = space(); div1 = element("div"); t3 = text(t3_value); attr(hr, "class", "svelte-1gr56ov"); attr(div0, "class", "info-label svelte-1gr56ov"); attr(div1, "class", "info svelte-1gr56ov"); attr(div2, "class", "info-row svelte-1gr56ov"); }, m(target, anchor) { insert(target, hr, anchor); insert(target, t0, anchor); insert(target, div2, anchor); append(div2, div0); append(div0, t1); append(div2, t2); append(div2, div1); append(div1, t3); }, p(ctx, dirty) { if (dirty & /*nextBillingDateLabel*/ 8) set_data(t1, /*nextBillingDateLabel*/ ctx[3]); if (dirty & /*subscription*/ 1 && t3_value !== (t3_value = /*subscription*/ ctx[0].nextBillingTime + "")) set_data(t3, t3_value); }, d(detaching) { if (detaching) { detach(hr); detach(t0); detach(div2); } } }; } // (53:6) {#if subscription.cannotBeChanged} function create_if_block$u(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "change-disabled-label svelte-1gr56ov"); }, m(target, anchor) { insert(target, div, anchor); div.innerHTML = /*noChangePlanMappingMessage*/ ctx[4]; }, p(ctx, dirty) { if (dirty & /*noChangePlanMappingMessage*/ 16) div.innerHTML = /*noChangePlanMappingMessage*/ ctx[4]; }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$D(ctx) { let div3; let div2; let div1; let div0; let h2; let t0_value = /*subscription*/ ctx[0].productLabel + ""; let t0; let t1; let t2; let t3; let t4; let button; let t5; let div2_style_value; let current; let mounted; let dispose; let if_block0 = /*subscription*/ ctx[0].planLabel && create_if_block_3$8(ctx); let if_block1 = /*subscription*/ ctx[0].amount && /*amountLabel*/ ctx[2] && create_if_block_2$d(ctx); let if_block2 = /*subscription*/ ctx[0].nextBillingTime && /*nextBillingDateLabel*/ ctx[3] && create_if_block_1$l(ctx); button = new Button({ props: { disabled: /*subscription*/ ctx[0].cannotBeChanged, text: /*selectButtonText*/ ctx[1] ?? "Select", onClick: /*onSelect*/ ctx[5] } }); let if_block3 = /*subscription*/ ctx[0].cannotBeChanged && create_if_block$u(ctx); return { c() { div3 = element("div"); div2 = element("div"); div1 = element("div"); div0 = element("div"); h2 = element("h2"); t0 = text(t0_value); t1 = space(); if (if_block0) if_block0.c(); t2 = space(); if (if_block1) if_block1.c(); t3 = space(); if (if_block2) if_block2.c(); t4 = space(); create_component(button.$$.fragment); t5 = space(); if (if_block3) if_block3.c(); attr(div0, "class", "subscription-option-product-label"); attr(div1, "class", "inner-box svelte-1gr56ov"); attr(div2, "class", "subscription-option-box"); attr(div2, "aria-hidden", "true"); attr(div2, "style", div2_style_value = /*subscription*/ ctx[0].cannotBeChanged ? "" : "cursor: pointer;"); attr(div3, "class", "subscription-option-wrapper svelte-1gr56ov"); }, m(target, anchor) { insert(target, div3, anchor); append(div3, div2); append(div2, div1); append(div1, div0); append(div0, h2); append(h2, t0); append(div1, t1); if (if_block0) if_block0.m(div1, null); append(div1, t2); if (if_block1) if_block1.m(div1, null); append(div1, t3); if (if_block2) if_block2.m(div1, null); append(div1, t4); mount_component(button, div1, null); append(div1, t5); if (if_block3) if_block3.m(div1, null); current = true; if (!mounted) { dispose = listen(div2, "click", self(prevent_default(function () { if (is_function(/*onSelect*/ ctx[5])) /*onSelect*/ ctx[5].apply(this, arguments); }))); mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if ((!current || dirty & /*subscription*/ 1) && t0_value !== (t0_value = /*subscription*/ ctx[0].productLabel + "")) set_data(t0, t0_value); if (/*subscription*/ ctx[0].planLabel) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_3$8(ctx); if_block0.c(); if_block0.m(div1, t2); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*subscription*/ ctx[0].amount && /*amountLabel*/ ctx[2]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_2$d(ctx); if_block1.c(); if_block1.m(div1, t3); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (/*subscription*/ ctx[0].nextBillingTime && /*nextBillingDateLabel*/ ctx[3]) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block_1$l(ctx); if_block2.c(); if_block2.m(div1, t4); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } const button_changes = {}; if (dirty & /*subscription*/ 1) button_changes.disabled = /*subscription*/ ctx[0].cannotBeChanged; if (dirty & /*selectButtonText*/ 2) button_changes.text = /*selectButtonText*/ ctx[1] ?? "Select"; if (dirty & /*onSelect*/ 32) button_changes.onClick = /*onSelect*/ ctx[5]; button.$set(button_changes); if (/*subscription*/ ctx[0].cannotBeChanged) { if (if_block3) { if_block3.p(ctx, dirty); } else { if_block3 = create_if_block$u(ctx); if_block3.c(); if_block3.m(div1, null); } } else if (if_block3) { if_block3.d(1); if_block3 = null; } if (!current || dirty & /*subscription*/ 1 && div2_style_value !== (div2_style_value = /*subscription*/ ctx[0].cannotBeChanged ? "" : "cursor: pointer;")) { attr(div2, "style", div2_style_value); } }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div3); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); destroy_component(button); if (if_block3) if_block3.d(); mounted = false; dispose(); } }; } function instance$D($$self, $$props, $$invalidate) { let { subscription } = $$props; let { selectButtonText } = $$props; let { amountLabel } = $$props; let { nextBillingDateLabel } = $$props; let { noChangePlanMappingMessage } = $$props; let { onSelect } = $$props; $$self.$$set = $$props => { if ('subscription' in $$props) $$invalidate(0, subscription = $$props.subscription); if ('selectButtonText' in $$props) $$invalidate(1, selectButtonText = $$props.selectButtonText); if ('amountLabel' in $$props) $$invalidate(2, amountLabel = $$props.amountLabel); if ('nextBillingDateLabel' in $$props) $$invalidate(3, nextBillingDateLabel = $$props.nextBillingDateLabel); if ('noChangePlanMappingMessage' in $$props) $$invalidate(4, noChangePlanMappingMessage = $$props.noChangePlanMappingMessage); if ('onSelect' in $$props) $$invalidate(5, onSelect = $$props.onSelect); }; return [ subscription, selectButtonText, amountLabel, nextBillingDateLabel, noChangePlanMappingMessage, onSelect ]; } class SubscriptionOption extends SvelteComponent { constructor(options) { super(); init(this, options, instance$D, create_fragment$D, safe_not_equal, { subscription: 0, selectButtonText: 1, amountLabel: 2, nextBillingDateLabel: 3, noChangePlanMappingMessage: 4, onSelect: 5 }); } } /* src/components/elements/subscriptionSelect/SubscriptionSelect.svelte generated by Svelte v4.2.12 */ function get_each_context$d(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[8] = list[i]; return child_ctx; } // (13:2) {#if subscriptions == null} function create_if_block_1$k(ctx) { let spinner; let current; spinner = new Spinner({}); return { c() { create_component(spinner.$$.fragment); }, m(target, anchor) { mount_component(spinner, target, anchor); current = true; }, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { destroy_component(spinner, detaching); } }; } // (16:2) {#if subscriptions != null && !subscriptions.length} function create_if_block$t(ctx) { let div; return { c() { div = element("div"); }, m(target, anchor) { insert(target, div, anchor); div.innerHTML = /*noSubscriptionsMessage*/ ctx[0]; }, p(ctx, dirty) { if (dirty & /*noSubscriptionsMessage*/ 1) div.innerHTML = /*noSubscriptionsMessage*/ ctx[0]; }, d(detaching) { if (detaching) { detach(div); } } }; } // (21:2) {#each subscriptions ?? [] as subscription} function create_each_block$d(ctx) { let subscriptionoption; let current; function func() { return /*func*/ ctx[7](/*subscription*/ ctx[8]); } subscriptionoption = new SubscriptionOption({ props: { subscription: /*subscription*/ ctx[8], selectButtonText: /*selectButtonText*/ ctx[5], noChangePlanMappingMessage: /*noChangePlanMappingMessage*/ ctx[1], amountLabel: /*amountLabel*/ ctx[3], nextBillingDateLabel: /*nextBillingDateLabel*/ ctx[4], onSelect: func } }); return { c() { create_component(subscriptionoption.$$.fragment); }, m(target, anchor) { mount_component(subscriptionoption, target, anchor); current = true; }, p(new_ctx, dirty) { ctx = new_ctx; const subscriptionoption_changes = {}; if (dirty & /*subscriptions*/ 4) subscriptionoption_changes.subscription = /*subscription*/ ctx[8]; if (dirty & /*selectButtonText*/ 32) subscriptionoption_changes.selectButtonText = /*selectButtonText*/ ctx[5]; if (dirty & /*noChangePlanMappingMessage*/ 2) subscriptionoption_changes.noChangePlanMappingMessage = /*noChangePlanMappingMessage*/ ctx[1]; if (dirty & /*amountLabel*/ 8) subscriptionoption_changes.amountLabel = /*amountLabel*/ ctx[3]; if (dirty & /*nextBillingDateLabel*/ 16) subscriptionoption_changes.nextBillingDateLabel = /*nextBillingDateLabel*/ ctx[4]; if (dirty & /*onSelect, subscriptions*/ 68) subscriptionoption_changes.onSelect = func; subscriptionoption.$set(subscriptionoption_changes); }, i(local) { if (current) return; transition_in(subscriptionoption.$$.fragment, local); current = true; }, o(local) { transition_out(subscriptionoption.$$.fragment, local); current = false; }, d(detaching) { destroy_component(subscriptionoption, detaching); } }; } function create_fragment$C(ctx) { let div; let t0; let t1; let current; let if_block0 = /*subscriptions*/ ctx[2] == null && create_if_block_1$k(); let if_block1 = /*subscriptions*/ ctx[2] != null && !/*subscriptions*/ ctx[2].length && create_if_block$t(ctx); let each_value = ensure_array_like(/*subscriptions*/ ctx[2] ?? []); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); for (let i = 0; i { if_block0 = null; }); check_outros(); } if (/*subscriptions*/ ctx[2] != null && !/*subscriptions*/ ctx[2].length) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$t(ctx); if_block1.c(); if_block1.m(div, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (dirty & /*subscriptions, selectButtonText, noChangePlanMappingMessage, amountLabel, nextBillingDateLabel, onSelect*/ 126) { each_value = ensure_array_like(/*subscriptions*/ ctx[2] ?? []); let i; for (i = 0; i onSelect(subscription); $$self.$$set = $$props => { if ('noSubscriptionsMessage' in $$props) $$invalidate(0, noSubscriptionsMessage = $$props.noSubscriptionsMessage); if ('noChangePlanMappingMessage' in $$props) $$invalidate(1, noChangePlanMappingMessage = $$props.noChangePlanMappingMessage); if ('subscriptions' in $$props) $$invalidate(2, subscriptions = $$props.subscriptions); if ('amountLabel' in $$props) $$invalidate(3, amountLabel = $$props.amountLabel); if ('nextBillingDateLabel' in $$props) $$invalidate(4, nextBillingDateLabel = $$props.nextBillingDateLabel); if ('selectButtonText' in $$props) $$invalidate(5, selectButtonText = $$props.selectButtonText); if ('onSelect' in $$props) $$invalidate(6, onSelect = $$props.onSelect); }; return [ noSubscriptionsMessage, noChangePlanMappingMessage, subscriptions, amountLabel, nextBillingDateLabel, selectButtonText, onSelect, func ]; } class SubscriptionSelect extends SvelteComponent { constructor(options) { super(); init(this, options, instance$C, create_fragment$C, safe_not_equal, { noSubscriptionsMessage: 0, noChangePlanMappingMessage: 1, subscriptions: 2, amountLabel: 3, nextBillingDateLabel: 4, selectButtonText: 5, onSelect: 6 }); } } const subscriptionSelectFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.SUBSCRIPTION_SELECT, create: (form, formState, formActions, elementConfig) => ({ component: SubscriptionSelect, props: { noSubscriptionsMessage: elementConfig.noSubscriptionsMessage, selectButtonText: elementConfig.selectButtonText, noChangePlanMappingMessage: elementConfig.noChangePlanMappingMessage, amountLabel: elementConfig.amountLabel, nextBillingDateLabel: elementConfig.nextBillingDateLabel, subscriptions: formState.existingSubscriptions ? formState.existingSubscriptions.filter(s => s.status !== 'inactive') : null, onSelect: (subscription) => { formActions.updateFormState({ selectedSubscription: subscription }); logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.completeSection(); } } }) }; /* src/components/elements/subscriptionsList/SubscriptionsListItem.svelte generated by Svelte v4.2.12 */ function create_if_block_4$6(ctx) { let span; let t; return { c() { span = element("span"); t = text(/*giftPillText*/ ctx[7]); attr(span, "class", "gift-pill svelte-1qhs7yc"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty & /*giftPillText*/ 128) set_data(t, /*giftPillText*/ ctx[7]); }, d(detaching) { if (detaching) { detach(span); } } }; } // (23:4) {#if showBillingHistory} function create_if_block_2$c(ctx) { let div1; let div0; let t0; let t1; let t2; let hr; let current; let if_block = /*billingHistoryLink*/ ctx[4] && create_if_block_3$7(ctx); return { c() { div1 = element("div"); div0 = element("div"); t0 = text(/*billingHistoryText*/ ctx[3]); t1 = space(); if (if_block) if_block.c(); t2 = space(); hr = element("hr"); attr(div0, "class", "information"); attr(div1, "class", "section"); attr(hr, "class", "svelte-1qhs7yc"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, div0); append(div0, t0); append(div0, t1); if (if_block) if_block.m(div0, null); insert(target, t2, anchor); insert(target, hr, anchor); current = true; }, p(ctx, dirty) { if (!current || dirty & /*billingHistoryText*/ 8) set_data(t0, /*billingHistoryText*/ ctx[3]); if (/*billingHistoryLink*/ ctx[4]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*billingHistoryLink*/ 16) { transition_in(if_block, 1); } } else { if_block = create_if_block_3$7(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(div0, null); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(div1); detach(t2); detach(hr); } if (if_block) if_block.d(); } }; } // (27:10) {#if billingHistoryLink} function create_if_block_3$7(ctx) { let link; let current; link = new Link({ props: { text: /*billingHistoryLink*/ ctx[4] } }); link.$on("linkClick", /*linkClick_handler*/ ctx[8]); return { c() { create_component(link.$$.fragment); }, m(target, anchor) { mount_component(link, target, anchor); current = true; }, p(ctx, dirty) { const link_changes = {}; if (dirty & /*billingHistoryLink*/ 16) link_changes.text = /*billingHistoryLink*/ ctx[4]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { destroy_component(link, detaching); } }; } // (34:4) {#if subscription.status === 'active' && subscription.nextBillingTime} function create_if_block_1$j(ctx) { let div1; let h3; let t0; let t1; let div0; let t2_value = /*subscription*/ ctx[0].nextBillingTime + ""; let t2; let t3; let hr; return { c() { div1 = element("div"); h3 = element("h3"); t0 = text(/*nextPaymentDateText*/ ctx[1]); t1 = space(); div0 = element("div"); t2 = text(t2_value); t3 = space(); hr = element("hr"); attr(h3, "class", "svelte-1qhs7yc"); attr(div0, "class", "information"); attr(div1, "class", "section"); attr(hr, "class", "svelte-1qhs7yc"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, h3); append(h3, t0); append(div1, t1); append(div1, div0); append(div0, t2); insert(target, t3, anchor); insert(target, hr, anchor); }, p(ctx, dirty) { if (dirty & /*nextPaymentDateText*/ 2) set_data(t0, /*nextPaymentDateText*/ ctx[1]); if (dirty & /*subscription*/ 1 && t2_value !== (t2_value = /*subscription*/ ctx[0].nextBillingTime + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); detach(t3); detach(hr); } } }; } // (41:4) {#if subscription.amount} function create_if_block$s(ctx) { let div1; let h3; let t0; let t1; let div0; let t2_value = /*subscription*/ ctx[0].amount + ""; let t2; let t3; let hr; return { c() { div1 = element("div"); h3 = element("h3"); t0 = text(/*subscriptionRateText*/ ctx[2]); t1 = space(); div0 = element("div"); t2 = text(t2_value); t3 = space(); hr = element("hr"); attr(h3, "class", "svelte-1qhs7yc"); attr(div0, "class", "information"); attr(div1, "class", "section"); attr(hr, "class", "svelte-1qhs7yc"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, h3); append(h3, t0); append(div1, t1); append(div1, div0); append(div0, t2); insert(target, t3, anchor); insert(target, hr, anchor); }, p(ctx, dirty) { if (dirty & /*subscriptionRateText*/ 4) set_data(t0, /*subscriptionRateText*/ ctx[2]); if (dirty & /*subscription*/ 1 && t2_value !== (t2_value = /*subscription*/ ctx[0].amount + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); detach(t3); detach(hr); } } }; } function create_fragment$B(ctx) { let div2; let div1; let div0; let h2; let t0_value = /*subscription*/ ctx[0].productLabel + ""; let t0; let t1; let h2_class_value; let t2; let hr; let t3; let t4; let t5; let current; let if_block0 = /*subscription*/ ctx[0].isGift && create_if_block_4$6(ctx); let if_block1 = /*showBillingHistory*/ ctx[6] && create_if_block_2$c(ctx); let if_block2 = /*subscription*/ ctx[0].status === 'active' && /*subscription*/ ctx[0].nextBillingTime && create_if_block_1$j(ctx); let if_block3 = /*subscription*/ ctx[0].amount && create_if_block$s(ctx); return { c() { div2 = element("div"); div1 = element("div"); div0 = element("div"); h2 = element("h2"); t0 = text(t0_value); t1 = space(); if (if_block0) if_block0.c(); t2 = space(); hr = element("hr"); t3 = space(); if (if_block1) if_block1.c(); t4 = space(); if (if_block2) if_block2.c(); t5 = space(); if (if_block3) if_block3.c(); attr(h2, "class", h2_class_value = "" + (null_to_empty(/*subscription*/ ctx[0].status === 'inactive' ? 'inactive' : '') + " svelte-1qhs7yc")); attr(div0, "class", "section"); attr(hr, "class", "svelte-1qhs7yc"); attr(div1, "class", "inner-box svelte-1qhs7yc"); attr(div2, "class", "subscription-list-item svelte-1qhs7yc"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div1); append(div1, div0); append(div0, h2); append(h2, t0); append(h2, t1); if (if_block0) if_block0.m(h2, null); append(div1, t2); append(div1, hr); append(div1, t3); if (if_block1) if_block1.m(div1, null); append(div1, t4); if (if_block2) if_block2.m(div1, null); append(div1, t5); if (if_block3) if_block3.m(div1, null); current = true; }, p(ctx, [dirty]) { if ((!current || dirty & /*subscription*/ 1) && t0_value !== (t0_value = /*subscription*/ ctx[0].productLabel + "")) set_data(t0, t0_value); if (/*subscription*/ ctx[0].isGift) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_4$6(ctx); if_block0.c(); if_block0.m(h2, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (!current || dirty & /*subscription*/ 1 && h2_class_value !== (h2_class_value = "" + (null_to_empty(/*subscription*/ ctx[0].status === 'inactive' ? 'inactive' : '') + " svelte-1qhs7yc"))) { attr(h2, "class", h2_class_value); } if (/*showBillingHistory*/ ctx[6]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*showBillingHistory*/ 64) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_2$c(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div1, t4); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*subscription*/ ctx[0].status === 'active' && /*subscription*/ ctx[0].nextBillingTime) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block_1$j(ctx); if_block2.c(); if_block2.m(div1, t5); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } if (/*subscription*/ ctx[0].amount) { if (if_block3) { if_block3.p(ctx, dirty); } else { if_block3 = create_if_block$s(ctx); if_block3.c(); if_block3.m(div1, null); } } else if (if_block3) { if_block3.d(1); if_block3 = null; } }, i(local) { if (current) return; transition_in(if_block1); current = true; }, o(local) { transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div2); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); if (if_block3) if_block3.d(); } }; } function instance$B($$self, $$props, $$invalidate) { let { subscription } = $$props; let { nextPaymentDateText } = $$props; let { subscriptionRateText } = $$props; let { billingHistoryText } = $$props; let { billingHistoryLink } = $$props; let { onViewHistory } = $$props; let { showBillingHistory } = $$props; let { giftPillText = 'Gift' } = $$props; const linkClick_handler = () => onViewHistory(subscription); $$self.$$set = $$props => { if ('subscription' in $$props) $$invalidate(0, subscription = $$props.subscription); if ('nextPaymentDateText' in $$props) $$invalidate(1, nextPaymentDateText = $$props.nextPaymentDateText); if ('subscriptionRateText' in $$props) $$invalidate(2, subscriptionRateText = $$props.subscriptionRateText); if ('billingHistoryText' in $$props) $$invalidate(3, billingHistoryText = $$props.billingHistoryText); if ('billingHistoryLink' in $$props) $$invalidate(4, billingHistoryLink = $$props.billingHistoryLink); if ('onViewHistory' in $$props) $$invalidate(5, onViewHistory = $$props.onViewHistory); if ('showBillingHistory' in $$props) $$invalidate(6, showBillingHistory = $$props.showBillingHistory); if ('giftPillText' in $$props) $$invalidate(7, giftPillText = $$props.giftPillText); }; return [ subscription, nextPaymentDateText, subscriptionRateText, billingHistoryText, billingHistoryLink, onViewHistory, showBillingHistory, giftPillText, linkClick_handler ]; } class SubscriptionsListItem extends SvelteComponent { constructor(options) { super(); init(this, options, instance$B, create_fragment$B, safe_not_equal, { subscription: 0, nextPaymentDateText: 1, subscriptionRateText: 2, billingHistoryText: 3, billingHistoryLink: 4, onViewHistory: 5, showBillingHistory: 6, giftPillText: 7 }); } } /* src/components/elements/Tablink.svelte generated by Svelte v4.2.12 */ function create_fragment$A(ctx) { let a; let span; let t0; let t1; let svg; let path_1; let a_href_value; let mounted; let dispose; return { c() { a = element("a"); span = element("span"); t0 = text(/*text*/ ctx[0]); t1 = space(); svg = svg_element("svg"); path_1 = svg_element("path"); attr(path_1, "fill", "currentColor"); attr(path_1, "d", "M305 239c9.4 9.4 9.4 24.6 0 33.9L113 465c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l175-175L79 81c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L305 239z"); attr(svg, "aria-hidden", "true"); attr(svg, "focusable", "false"); attr(svg, "data-prefix", "far"); attr(svg, "data-icon", "chevron-right"); attr(svg, "class", "svg-inline--fa fa-chevron-right sc-egTsrv kzAurc"); attr(svg, "role", "img"); attr(svg, "xmlns", "http://www.w3.org/2000/svg"); attr(svg, "viewBox", "0 0 320 512"); attr(svg, "width", "16"); attr(svg, "height", "16"); attr(a, "class", "zephr-form-tablink svelte-py0ruk"); attr(a, "href", a_href_value = /*path*/ ctx[1] && (!window.Zephr || !window.Zephr.isCustomPage || !/*path*/ ctx[1].startsWith(window.Zephr.customPagePath)) ? /*path*/ ctx[1] : "javascript: void(0)"); }, m(target, anchor) { insert(target, a, anchor); append(a, span); append(span, t0); append(a, t1); append(a, svg); append(svg, path_1); if (!mounted) { dispose = listen(a, "click", /*click_handler*/ ctx[4]); mounted = true; } }, p(ctx, [dirty]) { if (dirty & /*text*/ 1) set_data(t0, /*text*/ ctx[0]); if (dirty & /*path*/ 2 && a_href_value !== (a_href_value = /*path*/ ctx[1] && (!window.Zephr || !window.Zephr.isCustomPage || !/*path*/ ctx[1].startsWith(window.Zephr.customPagePath)) ? /*path*/ ctx[1] : "javascript: void(0)")) { attr(a, "href", a_href_value); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(a); } mounted = false; dispose(); } }; } function instance$A($$self, $$props, $$invalidate) { let { text } = $$props; let { path = '' } = $$props; let { onClick = () => { } } = $$props; let { logDlEvent = () => { } } = $$props; const click_handler = () => { logDlEvent?.(); if (window.Zephr && window.Zephr.isCustomPage && path.startsWith(window.Zephr.customPagePath)) { window.history.pushState({}, '', path); } else { onClick(); } }; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('path' in $$props) $$invalidate(1, path = $$props.path); if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick); if ('logDlEvent' in $$props) $$invalidate(3, logDlEvent = $$props.logDlEvent); }; return [text, path, onClick, logDlEvent, click_handler]; } class Tablink extends SvelteComponent { constructor(options) { super(); init(this, options, instance$A, create_fragment$A, safe_not_equal, { text: 0, path: 1, onClick: 2, logDlEvent: 3 }); } } /* src/components/elements/subscriptionsList/SubscriptionsListBoxItem.svelte generated by Svelte v4.2.12 */ function get_each_context$c(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[48] = list[i]; child_ctx[50] = i; return child_ctx; } function get_each_context_1$3(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[51] = list[i]; return child_ctx; } // (123:8) {#if subscription.isGift} function create_if_block_23(ctx) { let span; let t; return { c() { span = element("span"); t = text(/*giftPillText*/ ctx[24]); attr(span, "class", "gift-pill svelte-xxnasy"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty[0] & /*giftPillText*/ 16777216) set_data(t, /*giftPillText*/ ctx[24]); }, d(detaching) { if (detaching) { detach(span); } } }; } // (135:4) {:else} function create_else_block$3(ctx) { let each_1_anchor; let current; let each_value = ensure_array_like(/*elementsOrder*/ ctx[21]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { for (let i = 0; i { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (178:10) {#if billingHistoryLink} function create_if_block_16$1(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*billingHistoryLink*/ ctx[3], onClick: /*func*/ ctx[39] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*billingHistoryLink*/ 8) tablink_changes.text = /*billingHistoryLink*/ ctx[3]; if (dirty[0] & /*onViewHistory, subscription*/ 17) tablink_changes.onClick = /*func*/ ctx[39]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (185:8) {#if element === 'change_payment' && !elementsHide.changePayment && !subscription.isGift} function create_if_block_13$1(ctx) { let if_block_anchor; let current; let if_block = /*changePaymentMethodText*/ ctx[10] && create_if_block_14$1(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*changePaymentMethodText*/ ctx[10]) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*changePaymentMethodText*/ 1024) { transition_in(if_block, 1); } } else { if_block = create_if_block_14$1(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (186:10) {#if changePaymentMethodText} function create_if_block_14$1(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*changePaymentMethodText*/ ctx[10], onClick: /*func_1*/ ctx[40] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*changePaymentMethodText*/ 1024) tablink_changes.text = /*changePaymentMethodText*/ ctx[10]; if (dirty[0] & /*onChangePayment, subscription*/ 33) tablink_changes.onClick = /*func_1*/ ctx[40]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (193:8) {#if element === 'change_subscription' && !elementsHide.changeSubscription} function create_if_block_11$1(ctx) { let if_block_anchor; let current; let if_block = /*changeSubscriptionText*/ ctx[11] && create_if_block_12$1(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*changeSubscriptionText*/ ctx[11]) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*changeSubscriptionText*/ 2048) { transition_in(if_block, 1); } } else { if_block = create_if_block_12$1(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (194:10) {#if changeSubscriptionText} function create_if_block_12$1(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*changeSubscriptionText*/ ctx[11], path: /*withSubscriptionParam*/ ctx[33](/*changeSubscriptionPath*/ ctx[13], /*subscription*/ ctx[0].externalId), logDlEvent: /*func_2*/ ctx[41] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*changeSubscriptionText*/ 2048) tablink_changes.text = /*changeSubscriptionText*/ ctx[11]; if (dirty[0] & /*changeSubscriptionPath, subscription*/ 8193) tablink_changes.path = /*withSubscriptionParam*/ ctx[33](/*changeSubscriptionPath*/ ctx[13], /*subscription*/ ctx[0].externalId); if (dirty[0] & /*logChangeSubscription, subscription*/ 65) tablink_changes.logDlEvent = /*func_2*/ ctx[41]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (202:8) {#if element === 'cancel_subscription' && !elementsHide.cancelSubscription && !subscription.isGift} function create_if_block_9$1(ctx) { let if_block_anchor; let current; let if_block = /*cancelSubscriptionText*/ ctx[12] && create_if_block_10$1(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*cancelSubscriptionText*/ ctx[12]) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*cancelSubscriptionText*/ 4096) { transition_in(if_block, 1); } } else { if_block = create_if_block_10$1(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (203:10) {#if cancelSubscriptionText} function create_if_block_10$1(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*cancelSubscriptionText*/ ctx[12], path: /*withSubscriptionParam*/ ctx[33](/*cancelSubscriptionPath*/ ctx[14], /*subscription*/ ctx[0].externalId), logDlEvent: /*func_3*/ ctx[42] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*cancelSubscriptionText*/ 4096) tablink_changes.text = /*cancelSubscriptionText*/ ctx[12]; if (dirty[0] & /*cancelSubscriptionPath, subscription*/ 16385) tablink_changes.path = /*withSubscriptionParam*/ ctx[33](/*cancelSubscriptionPath*/ ctx[14], /*subscription*/ ctx[0].externalId); if (dirty[0] & /*logCancelSubscription, subscription*/ 129) tablink_changes.logDlEvent = /*func_3*/ ctx[42]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (211:8) {#if element === 'suspend_resume_subscription' && !elementsHide.suspendResumeSubscription && paymentProvider === 'zuora-billing'} function create_if_block_7$1(ctx) { let if_block_anchor; let current; let if_block = /*suspendResumeSubscriptionText*/ ctx[15] && create_if_block_8$1(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*suspendResumeSubscriptionText*/ ctx[15]) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*suspendResumeSubscriptionText*/ 32768) { transition_in(if_block, 1); } } else { if_block = create_if_block_8$1(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (212:10) {#if suspendResumeSubscriptionText} function create_if_block_8$1(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*suspendResumeSubscriptionText*/ ctx[15], path: /*withSubscriptionParam*/ ctx[33](/*suspendResumeSubscriptionPath*/ ctx[16], /*subscription*/ ctx[0].externalId), logDlEvent: /*func_4*/ ctx[43] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*suspendResumeSubscriptionText*/ 32768) tablink_changes.text = /*suspendResumeSubscriptionText*/ ctx[15]; if (dirty[0] & /*suspendResumeSubscriptionPath, subscription*/ 65537) tablink_changes.path = /*withSubscriptionParam*/ ctx[33](/*suspendResumeSubscriptionPath*/ ctx[16], /*subscription*/ ctx[0].externalId); if (dirty[0] & /*logSuspendResumeSubscription, subscription*/ 257) tablink_changes.logDlEvent = /*func_4*/ ctx[43]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (220:8) {#if element === 'subscription_custom_fields_list' && !elementsHide.subscriptionCustomFields} function create_if_block_5$5(ctx) { let if_block_anchor; let current; let if_block = /*subscriptionCustomFieldsText*/ ctx[17] && create_if_block_6$5(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*subscriptionCustomFieldsText*/ ctx[17]) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*subscriptionCustomFieldsText*/ 131072) { transition_in(if_block, 1); } } else { if_block = create_if_block_6$5(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (221:10) {#if subscriptionCustomFieldsText} function create_if_block_6$5(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*subscriptionCustomFieldsText*/ ctx[17], onClick: /*func_5*/ ctx[44] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*subscriptionCustomFieldsText*/ 131072) tablink_changes.text = /*subscriptionCustomFieldsText*/ ctx[17]; if (dirty[0] & /*onUpdateSubscriptionCustomFields, subscription*/ 262145) tablink_changes.onClick = /*func_5*/ ctx[44]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (228:8) {#if element === 'bill_to_contact' && !elementsHide.updateBillToContact && paymentProvider === 'zuora-billing'} function create_if_block_3$6(ctx) { let if_block_anchor; let current; let if_block = /*updateBillToContactText*/ ctx[19] && create_if_block_4$5(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*updateBillToContactText*/ ctx[19]) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*updateBillToContactText*/ 524288) { transition_in(if_block, 1); } } else { if_block = create_if_block_4$5(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (229:10) {#if updateBillToContactText} function create_if_block_4$5(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*updateBillToContactText*/ ctx[19], path: /*withSubscriptionParam*/ ctx[33](/*updateBillToContactPath*/ ctx[20], /*subscription*/ ctx[0].externalId), logDlEvent: /*func_6*/ ctx[45] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*updateBillToContactText*/ 524288) tablink_changes.text = /*updateBillToContactText*/ ctx[19]; if (dirty[0] & /*updateBillToContactPath, subscription*/ 1048577) tablink_changes.path = /*withSubscriptionParam*/ ctx[33](/*updateBillToContactPath*/ ctx[20], /*subscription*/ ctx[0].externalId); if (dirty[0] & /*logUpdateBillToContact, subscription*/ 513) tablink_changes.logDlEvent = /*func_6*/ ctx[45]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (237:8) {#if element === 'subscription_custom_fields_list' && displayedFields.length > 0} function create_if_block_2$b(ctx) { let each_1_anchor; let each_value_1 = ensure_array_like(/*displayedFields*/ ctx[32]); let each_blocks = []; for (let i = 0; i 0 && create_if_block_2$b(ctx); return { c() { if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); t2 = space(); if (if_block3) if_block3.c(); t3 = space(); if (if_block4) if_block4.c(); t4 = space(); if (if_block5) if_block5.c(); t5 = space(); if (if_block6) if_block6.c(); t6 = space(); if (if_block7) if_block7.c(); t7 = space(); if (if_block8) if_block8.c(); t8 = space(); if (if_block9) if_block9.c(); if_block9_anchor = empty(); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert(target, t0, anchor); if (if_block1) if_block1.m(target, anchor); insert(target, t1, anchor); if (if_block2) if_block2.m(target, anchor); insert(target, t2, anchor); if (if_block3) if_block3.m(target, anchor); insert(target, t3, anchor); if (if_block4) if_block4.m(target, anchor); insert(target, t4, anchor); if (if_block5) if_block5.m(target, anchor); insert(target, t5, anchor); if (if_block6) if_block6.m(target, anchor); insert(target, t6, anchor); if (if_block7) if_block7.m(target, anchor); insert(target, t7, anchor); if (if_block8) if_block8.m(target, anchor); insert(target, t8, anchor); if (if_block9) if_block9.m(target, anchor); insert(target, if_block9_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*element*/ ctx[48] === 'subscription_information' && !/*elementsHide*/ ctx[22].subscriptionInformation) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_20(ctx); if_block0.c(); if_block0.m(t0.parentNode, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*element*/ ctx[48] === 'payment_auto_renew_toggle' && /*autoRenewToggleEnabled*/ ctx[26] && /*paymentProvider*/ ctx[25] === 'zuora-billing' && /*subscription*/ ctx[0].status === 'active' && !/*subscription*/ ctx[0].isGift && /*subscription*/ ctx[0].termType === 'TERMED') { if (if_block1) { if_block1.p(ctx, dirty); if (dirty[0] & /*elementsOrder, autoRenewToggleEnabled, paymentProvider, subscription*/ 102760449) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_17$1(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(t1.parentNode, t1); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'billing_history' && !/*elementsHide*/ ctx[22].billingHistory) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 6291456) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_15$1(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(t2.parentNode, t2); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'change_payment' && !/*elementsHide*/ ctx[22].changePayment && !/*subscription*/ ctx[0].isGift) { if (if_block3) { if_block3.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide, subscription*/ 6291457) { transition_in(if_block3, 1); } } else { if_block3 = create_if_block_13$1(ctx); if_block3.c(); transition_in(if_block3, 1); if_block3.m(t3.parentNode, t3); } } else if (if_block3) { group_outros(); transition_out(if_block3, 1, 1, () => { if_block3 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'change_subscription' && !/*elementsHide*/ ctx[22].changeSubscription) { if (if_block4) { if_block4.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 6291456) { transition_in(if_block4, 1); } } else { if_block4 = create_if_block_11$1(ctx); if_block4.c(); transition_in(if_block4, 1); if_block4.m(t4.parentNode, t4); } } else if (if_block4) { group_outros(); transition_out(if_block4, 1, 1, () => { if_block4 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'cancel_subscription' && !/*elementsHide*/ ctx[22].cancelSubscription && !/*subscription*/ ctx[0].isGift) { if (if_block5) { if_block5.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide, subscription*/ 6291457) { transition_in(if_block5, 1); } } else { if_block5 = create_if_block_9$1(ctx); if_block5.c(); transition_in(if_block5, 1); if_block5.m(t5.parentNode, t5); } } else if (if_block5) { group_outros(); transition_out(if_block5, 1, 1, () => { if_block5 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'suspend_resume_subscription' && !/*elementsHide*/ ctx[22].suspendResumeSubscription && /*paymentProvider*/ ctx[25] === 'zuora-billing') { if (if_block6) { if_block6.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide, paymentProvider*/ 39845888) { transition_in(if_block6, 1); } } else { if_block6 = create_if_block_7$1(ctx); if_block6.c(); transition_in(if_block6, 1); if_block6.m(t6.parentNode, t6); } } else if (if_block6) { group_outros(); transition_out(if_block6, 1, 1, () => { if_block6 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'subscription_custom_fields_list' && !/*elementsHide*/ ctx[22].subscriptionCustomFields) { if (if_block7) { if_block7.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 6291456) { transition_in(if_block7, 1); } } else { if_block7 = create_if_block_5$5(ctx); if_block7.c(); transition_in(if_block7, 1); if_block7.m(t7.parentNode, t7); } } else if (if_block7) { group_outros(); transition_out(if_block7, 1, 1, () => { if_block7 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'bill_to_contact' && !/*elementsHide*/ ctx[22].updateBillToContact && /*paymentProvider*/ ctx[25] === 'zuora-billing') { if (if_block8) { if_block8.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide, paymentProvider*/ 39845888) { transition_in(if_block8, 1); } } else { if_block8 = create_if_block_3$6(ctx); if_block8.c(); transition_in(if_block8, 1); if_block8.m(t8.parentNode, t8); } } else if (if_block8) { group_outros(); transition_out(if_block8, 1, 1, () => { if_block8 = null; }); check_outros(); } if (/*element*/ ctx[48] === 'subscription_custom_fields_list' && /*displayedFields*/ ctx[32].length > 0) { if (if_block9) { if_block9.p(ctx, dirty); } else { if_block9 = create_if_block_2$b(ctx); if_block9.c(); if_block9.m(if_block9_anchor.parentNode, if_block9_anchor); } } else if (if_block9) { if_block9.d(1); if_block9 = null; } }, i(local) { if (current) return; transition_in(if_block1); transition_in(if_block2); transition_in(if_block3); transition_in(if_block4); transition_in(if_block5); transition_in(if_block6); transition_in(if_block7); transition_in(if_block8); current = true; }, o(local) { transition_out(if_block1); transition_out(if_block2); transition_out(if_block3); transition_out(if_block4); transition_out(if_block5); transition_out(if_block6); transition_out(if_block7); transition_out(if_block8); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(t1); detach(t2); detach(t3); detach(t4); detach(t5); detach(t6); detach(t7); detach(t8); detach(if_block9_anchor); } if (if_block0) if_block0.d(detaching); if (if_block1) if_block1.d(detaching); if (if_block2) if_block2.d(detaching); if (if_block3) if_block3.d(detaching); if (if_block4) if_block4.d(detaching); if (if_block5) if_block5.d(detaching); if (if_block6) if_block6.d(detaching); if (if_block7) if_block7.d(detaching); if (if_block8) if_block8.d(detaching); if (if_block9) if_block9.d(detaching); } }; } // (129:6) {#if subscription.amount} function create_if_block_1$i(ctx) { let div1; let span; let t0; let t1; let div0; let t2_value = /*subscription*/ ctx[0].amount + ""; let t2; return { c() { div1 = element("div"); span = element("span"); t0 = text(/*subscriptionRateText*/ ctx[2]); t1 = space(); div0 = element("div"); t2 = text(t2_value); attr(span, "class", "svelte-xxnasy"); attr(div0, "class", "zephr-box-item-information svelte-xxnasy"); attr(div1, "class", "zephr-section svelte-xxnasy"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, span); append(span, t0); append(div1, t1); append(div1, div0); append(div0, t2); }, p(ctx, dirty) { if (dirty[0] & /*subscriptionRateText*/ 4) set_data(t0, /*subscriptionRateText*/ ctx[2]); if (dirty[0] & /*subscription*/ 1 && t2_value !== (t2_value = /*subscription*/ ctx[0].amount + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); } } }; } function create_fragment$z(ctx) { let div2; let div1; let div0; let h2; let t0_value = /*subscription*/ ctx[0].productLabel + ""; let t0; let t1; let t2; let current_block_type_index; let if_block1; let current; let if_block0 = /*subscription*/ ctx[0].isGift && create_if_block_23(ctx); const if_block_creators = [create_if_block$r, create_else_block$3]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*isInactive*/ ctx[23]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); return { c() { div2 = element("div"); div1 = element("div"); div0 = element("div"); h2 = element("h2"); t0 = text(t0_value); t1 = space(); if (if_block0) if_block0.c(); t2 = space(); if_block1.c(); attr(h2, "class", "svelte-xxnasy"); attr(div0, "class", "zephr-section svelte-xxnasy"); attr(div1, "class", "zephr-inner-box svelte-xxnasy"); attr(div2, "class", "zephr-subscription-list-box-item svelte-xxnasy"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div1); append(div1, div0); append(div0, h2); append(h2, t0); append(h2, t1); if (if_block0) if_block0.m(h2, null); append(div1, t2); if_blocks[current_block_type_index].m(div1, null); current = true; }, p(ctx, dirty) { if ((!current || dirty[0] & /*subscription*/ 1) && t0_value !== (t0_value = /*subscription*/ ctx[0].productLabel + "")) set_data(t0, t0_value); if (/*subscription*/ ctx[0].isGift) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_23(ctx); if_block0.c(); if_block0.m(h2, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block1 = if_blocks[current_block_type_index]; if (!if_block1) { if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block1.c(); } else { if_block1.p(ctx, dirty); } transition_in(if_block1, 1); if_block1.m(div1, null); } }, i(local) { if (current) return; transition_in(if_block1); current = true; }, o(local) { transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div2); } if (if_block0) if_block0.d(); if_blocks[current_block_type_index].d(); } }; } function instance$z($$self, $$props, $$invalidate) { let displayedFields; let { subscription } = $$props; let { nextPaymentDateText = '' } = $$props; let { subscriptionRateText } = $$props; let { billingHistoryLink = '' } = $$props; let { onViewHistory = () => { } } = $$props; let { onChangePayment = () => { } } = $$props; let { logChangeSubscription = () => { } } = $$props; let { logCancelSubscription = () => { } } = $$props; let { logSuspendResumeSubscription = () => { } } = $$props; let { logUpdateBillToContact = () => { } } = $$props; let { changePaymentMethodText = '' } = $$props; let { changeSubscriptionText = '' } = $$props; let { cancelSubscriptionText = '' } = $$props; let { changeSubscriptionPath = '' } = $$props; let { cancelSubscriptionPath = '' } = $$props; let { suspendResumeSubscriptionText = '' } = $$props; let { suspendResumeSubscriptionPath = '' } = $$props; let { subscriptionCustomFieldsText } = $$props; let { onUpdateSubscriptionCustomFields } = $$props; let { updateBillToContactText } = $$props; let { updateBillToContactPath } = $$props; let { elementsOrder = [] } = $$props; let { elementsHide = { subscriptionInformation: false, changePayment: true, changeSubscription: true, cancelSubscription: true, billingHistory: true, suspendResumeSubscription: true, subscriptionCustomFields: true, updateBillToContact: true } } = $$props; let { isInactive = false } = $$props; let { displayedCustomFields = {} } = $$props; let { giftPillText = 'Gift' } = $$props; let { paymentProvider = '' } = $$props; let { autoRenewToggleEnabled = false } = $$props; let { autoRenewToggleText = 'Auto-renew subscription' } = $$props; let { autoRenewSuccessMessage = 'Preferences updated' } = $$props; let { autoRenewErrorMessage = 'Something went wrong. Please try again later' } = $$props; let { onAutoRenewToggle = async () => ({ success: false }) } = $$props; let isUpdatingAutoRenew = false; let statusMessage = ''; let statusType = ''; let statusTimeout = null; let autoRenewValue = subscription.autoRenew ?? false; // Local checkbox state // Ensures we append the subscription id correctly whether or not the base path already has query params const withSubscriptionParam = (basePath, subscriptionId) => { if (!basePath) return ''; const hasQuery = basePath.includes('?'); const separator = hasQuery ? '&' : '?'; return `${basePath}${separator}subscription=${encodeURIComponent(subscriptionId)}`; }; const handleAutoRenewChange = async event => { const newAutoRenewValue = event.detail; // Clear any existing status message clearStatusMessage(); // Revert checkbox to previous state immediately (will update on success) $$invalidate(31, autoRenewValue = subscription.autoRenew ?? false); $$invalidate(28, isUpdatingAutoRenew = true); try { const result = await onAutoRenewToggle(subscription, newAutoRenewValue); if (result.success) { // Update local subscription state (this will trigger checkbox update via reactive statement) $$invalidate(0, subscription.autoRenew = newAutoRenewValue, subscription); // Show success message for 5 seconds $$invalidate(29, statusMessage = autoRenewSuccessMessage); $$invalidate(30, statusType = 'success'); statusTimeout = setTimeout( () => { clearStatusMessage(); }, 5000 ); } else { // Show error message persistently (checkbox already reverted) $$invalidate(29, statusMessage = autoRenewErrorMessage); $$invalidate(30, statusType = 'error'); } } catch(error) { console.error('Failed to update auto-renewal:', error); // Show error message persistently (checkbox already reverted) $$invalidate(29, statusMessage = autoRenewErrorMessage); $$invalidate(30, statusType = 'error'); } finally { $$invalidate(28, isUpdatingAutoRenew = false); } }; const clearStatusMessage = () => { if (statusTimeout) { clearTimeout(statusTimeout); statusTimeout = null; } $$invalidate(29, statusMessage = ''); $$invalidate(30, statusType = ''); }; // Clean up timeout on component destroy onDestroy(() => { if (statusTimeout) { clearTimeout(statusTimeout); } }); const func = () => onViewHistory(subscription); const func_1 = () => onChangePayment(subscription); const func_2 = () => logChangeSubscription(subscription); const func_3 = () => logCancelSubscription(subscription); const func_4 = () => logSuspendResumeSubscription(subscription); const func_5 = () => onUpdateSubscriptionCustomFields(subscription); const func_6 = () => logUpdateBillToContact(subscription); $$self.$$set = $$props => { if ('subscription' in $$props) $$invalidate(0, subscription = $$props.subscription); if ('nextPaymentDateText' in $$props) $$invalidate(1, nextPaymentDateText = $$props.nextPaymentDateText); if ('subscriptionRateText' in $$props) $$invalidate(2, subscriptionRateText = $$props.subscriptionRateText); if ('billingHistoryLink' in $$props) $$invalidate(3, billingHistoryLink = $$props.billingHistoryLink); if ('onViewHistory' in $$props) $$invalidate(4, onViewHistory = $$props.onViewHistory); if ('onChangePayment' in $$props) $$invalidate(5, onChangePayment = $$props.onChangePayment); if ('logChangeSubscription' in $$props) $$invalidate(6, logChangeSubscription = $$props.logChangeSubscription); if ('logCancelSubscription' in $$props) $$invalidate(7, logCancelSubscription = $$props.logCancelSubscription); if ('logSuspendResumeSubscription' in $$props) $$invalidate(8, logSuspendResumeSubscription = $$props.logSuspendResumeSubscription); if ('logUpdateBillToContact' in $$props) $$invalidate(9, logUpdateBillToContact = $$props.logUpdateBillToContact); if ('changePaymentMethodText' in $$props) $$invalidate(10, changePaymentMethodText = $$props.changePaymentMethodText); if ('changeSubscriptionText' in $$props) $$invalidate(11, changeSubscriptionText = $$props.changeSubscriptionText); if ('cancelSubscriptionText' in $$props) $$invalidate(12, cancelSubscriptionText = $$props.cancelSubscriptionText); if ('changeSubscriptionPath' in $$props) $$invalidate(13, changeSubscriptionPath = $$props.changeSubscriptionPath); if ('cancelSubscriptionPath' in $$props) $$invalidate(14, cancelSubscriptionPath = $$props.cancelSubscriptionPath); if ('suspendResumeSubscriptionText' in $$props) $$invalidate(15, suspendResumeSubscriptionText = $$props.suspendResumeSubscriptionText); if ('suspendResumeSubscriptionPath' in $$props) $$invalidate(16, suspendResumeSubscriptionPath = $$props.suspendResumeSubscriptionPath); if ('subscriptionCustomFieldsText' in $$props) $$invalidate(17, subscriptionCustomFieldsText = $$props.subscriptionCustomFieldsText); if ('onUpdateSubscriptionCustomFields' in $$props) $$invalidate(18, onUpdateSubscriptionCustomFields = $$props.onUpdateSubscriptionCustomFields); if ('updateBillToContactText' in $$props) $$invalidate(19, updateBillToContactText = $$props.updateBillToContactText); if ('updateBillToContactPath' in $$props) $$invalidate(20, updateBillToContactPath = $$props.updateBillToContactPath); if ('elementsOrder' in $$props) $$invalidate(21, elementsOrder = $$props.elementsOrder); if ('elementsHide' in $$props) $$invalidate(22, elementsHide = $$props.elementsHide); if ('isInactive' in $$props) $$invalidate(23, isInactive = $$props.isInactive); if ('displayedCustomFields' in $$props) $$invalidate(35, displayedCustomFields = $$props.displayedCustomFields); if ('giftPillText' in $$props) $$invalidate(24, giftPillText = $$props.giftPillText); if ('paymentProvider' in $$props) $$invalidate(25, paymentProvider = $$props.paymentProvider); if ('autoRenewToggleEnabled' in $$props) $$invalidate(26, autoRenewToggleEnabled = $$props.autoRenewToggleEnabled); if ('autoRenewToggleText' in $$props) $$invalidate(27, autoRenewToggleText = $$props.autoRenewToggleText); if ('autoRenewSuccessMessage' in $$props) $$invalidate(36, autoRenewSuccessMessage = $$props.autoRenewSuccessMessage); if ('autoRenewErrorMessage' in $$props) $$invalidate(37, autoRenewErrorMessage = $$props.autoRenewErrorMessage); if ('onAutoRenewToggle' in $$props) $$invalidate(38, onAutoRenewToggle = $$props.onAutoRenewToggle); }; $$self.$$.update = () => { if ($$self.$$.dirty[0] & /*subscription*/ 1 | $$self.$$.dirty[1] & /*displayedCustomFields*/ 16) { // Compute displayed custom fields $$invalidate(32, displayedFields = Object.entries(displayedCustomFields).filter(([fieldId, fieldConfig]) => fieldConfig.enabled && subscription[fieldId]).map(([fieldId, fieldConfig]) => ({ label: fieldConfig.label, value: subscription[fieldId] }))); } if ($$self.$$.dirty[0] & /*subscription*/ 1) { // Update local checkbox state when subscription changes $$invalidate(31, autoRenewValue = subscription.autoRenew ?? false); } }; return [ subscription, nextPaymentDateText, subscriptionRateText, billingHistoryLink, onViewHistory, onChangePayment, logChangeSubscription, logCancelSubscription, logSuspendResumeSubscription, logUpdateBillToContact, changePaymentMethodText, changeSubscriptionText, cancelSubscriptionText, changeSubscriptionPath, cancelSubscriptionPath, suspendResumeSubscriptionText, suspendResumeSubscriptionPath, subscriptionCustomFieldsText, onUpdateSubscriptionCustomFields, updateBillToContactText, updateBillToContactPath, elementsOrder, elementsHide, isInactive, giftPillText, paymentProvider, autoRenewToggleEnabled, autoRenewToggleText, isUpdatingAutoRenew, statusMessage, statusType, autoRenewValue, displayedFields, withSubscriptionParam, handleAutoRenewChange, displayedCustomFields, autoRenewSuccessMessage, autoRenewErrorMessage, onAutoRenewToggle, func, func_1, func_2, func_3, func_4, func_5, func_6 ]; } class SubscriptionsListBoxItem extends SvelteComponent { constructor(options) { super(); init( this, options, instance$z, create_fragment$z, safe_not_equal, { subscription: 0, nextPaymentDateText: 1, subscriptionRateText: 2, billingHistoryLink: 3, onViewHistory: 4, onChangePayment: 5, logChangeSubscription: 6, logCancelSubscription: 7, logSuspendResumeSubscription: 8, logUpdateBillToContact: 9, changePaymentMethodText: 10, changeSubscriptionText: 11, cancelSubscriptionText: 12, changeSubscriptionPath: 13, cancelSubscriptionPath: 14, suspendResumeSubscriptionText: 15, suspendResumeSubscriptionPath: 16, subscriptionCustomFieldsText: 17, onUpdateSubscriptionCustomFields: 18, updateBillToContactText: 19, updateBillToContactPath: 20, elementsOrder: 21, elementsHide: 22, isInactive: 23, displayedCustomFields: 35, giftPillText: 24, paymentProvider: 25, autoRenewToggleEnabled: 26, autoRenewToggleText: 27, autoRenewSuccessMessage: 36, autoRenewErrorMessage: 37, onAutoRenewToggle: 38 }, null, [-1, -1] ); } } /* src/components/elements/subscriptionsList/SubscriptionsList.svelte generated by Svelte v4.2.12 */ function get_each_context$b(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[34] = list[i]; return child_ctx; } function get_each_context_1$2(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[34] = list[i]; return child_ctx; } // (44:2) {#if loading} function create_if_block_6$4(ctx) { let spinner; let current; spinner = new Spinner({}); return { c() { create_component(spinner.$$.fragment); }, m(target, anchor) { mount_component(spinner, target, anchor); current = true; }, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { destroy_component(spinner, detaching); } }; } // (47:2) {#if !isPastSubscriptions} function create_if_block_2$a(ctx) { let t; let each_1_anchor; let current; let if_block = !/*loading*/ ctx[10] && !/*subscriptions*/ ctx[6].length && create_if_block_5$4(ctx); let each_value_1 = ensure_array_like(/*subscriptions*/ ctx[6]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { if (if_block) if_block.c(); t = space(); for (let i = 0; i { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(subscriptionslistitem.$$.fragment, local); transition_in(if_block); current = true; }, o(local) { transition_out(subscriptionslistitem.$$.fragment, local); transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(t); detach(if_block_anchor); } destroy_component(subscriptionslistitem, detaching); if (if_block) if_block.d(detaching); } }; } // (54:6) {#if elementsOrder} function create_if_block_3$5(ctx) { let subscriptionslistboxitem; let current; subscriptionslistboxitem = new SubscriptionsListBoxItem({ props: { subscription: /*subscription*/ ctx[34], nextPaymentDateText: /*nextPaymentDateText*/ ctx[4], subscriptionRateText: /*subscriptionRateText*/ ctx[5], billingHistoryLink: /*billingHistoryLink*/ ctx[3], onViewHistory: /*onViewHistory*/ ctx[15], onChangePayment: /*onChangePayment*/ ctx[11], logChangeSubscription: /*logChangeSubscription*/ ctx[12], logCancelSubscription: /*logCancelSubscription*/ ctx[13], logSuspendResumeSubscription: /*logSuspendResumeSubscription*/ ctx[14], changePaymentMethodText: /*changePaymentMethodText*/ ctx[9], changeSubscriptionText: /*changeSubscriptionText*/ ctx[16], cancelSubscriptionText: /*cancelSubscriptionText*/ ctx[17], changeSubscriptionPath: /*changeSubscriptionPath*/ ctx[18], cancelSubscriptionPath: /*cancelSubscriptionPath*/ ctx[19], suspendResumeSubscriptionText: /*suspendResumeSubscriptionText*/ ctx[20], suspendResumeSubscriptionPath: /*suspendResumeSubscriptionPath*/ ctx[21], subscriptionCustomFieldsText: /*subscriptionCustomFieldsText*/ ctx[22], onUpdateSubscriptionCustomFields: /*onUpdateSubscriptionCustomFields*/ ctx[23], updateBillToContactText: /*updateBillToContactText*/ ctx[24], updateBillToContactPath: /*updateBillToContactPath*/ ctx[25], elementsOrder: /*elementsOrder*/ ctx[26], elementsHide: /*elementsHide*/ ctx[27], giftPillText: /*giftPillText*/ ctx[28], paymentProvider: /*paymentProvider*/ ctx[8], autoRenewToggleEnabled: /*autoRenewToggleEnabled*/ ctx[29], autoRenewToggleText: /*autoRenewToggleText*/ ctx[30], onAutoRenewToggle: /*onAutoRenewToggle*/ ctx[31], displayedCustomFields: /*displayedCustomFields*/ ctx[32] } }); return { c() { create_component(subscriptionslistboxitem.$$.fragment); }, m(target, anchor) { mount_component(subscriptionslistboxitem, target, anchor); current = true; }, p(ctx, dirty) { const subscriptionslistboxitem_changes = {}; if (dirty[0] & /*subscriptions*/ 64) subscriptionslistboxitem_changes.subscription = /*subscription*/ ctx[34]; if (dirty[0] & /*nextPaymentDateText*/ 16) subscriptionslistboxitem_changes.nextPaymentDateText = /*nextPaymentDateText*/ ctx[4]; if (dirty[0] & /*subscriptionRateText*/ 32) subscriptionslistboxitem_changes.subscriptionRateText = /*subscriptionRateText*/ ctx[5]; if (dirty[0] & /*billingHistoryLink*/ 8) subscriptionslistboxitem_changes.billingHistoryLink = /*billingHistoryLink*/ ctx[3]; if (dirty[0] & /*onViewHistory*/ 32768) subscriptionslistboxitem_changes.onViewHistory = /*onViewHistory*/ ctx[15]; if (dirty[0] & /*onChangePayment*/ 2048) subscriptionslistboxitem_changes.onChangePayment = /*onChangePayment*/ ctx[11]; if (dirty[0] & /*logChangeSubscription*/ 4096) subscriptionslistboxitem_changes.logChangeSubscription = /*logChangeSubscription*/ ctx[12]; if (dirty[0] & /*logCancelSubscription*/ 8192) subscriptionslistboxitem_changes.logCancelSubscription = /*logCancelSubscription*/ ctx[13]; if (dirty[0] & /*logSuspendResumeSubscription*/ 16384) subscriptionslistboxitem_changes.logSuspendResumeSubscription = /*logSuspendResumeSubscription*/ ctx[14]; if (dirty[0] & /*changePaymentMethodText*/ 512) subscriptionslistboxitem_changes.changePaymentMethodText = /*changePaymentMethodText*/ ctx[9]; if (dirty[0] & /*changeSubscriptionText*/ 65536) subscriptionslistboxitem_changes.changeSubscriptionText = /*changeSubscriptionText*/ ctx[16]; if (dirty[0] & /*cancelSubscriptionText*/ 131072) subscriptionslistboxitem_changes.cancelSubscriptionText = /*cancelSubscriptionText*/ ctx[17]; if (dirty[0] & /*changeSubscriptionPath*/ 262144) subscriptionslistboxitem_changes.changeSubscriptionPath = /*changeSubscriptionPath*/ ctx[18]; if (dirty[0] & /*cancelSubscriptionPath*/ 524288) subscriptionslistboxitem_changes.cancelSubscriptionPath = /*cancelSubscriptionPath*/ ctx[19]; if (dirty[0] & /*suspendResumeSubscriptionText*/ 1048576) subscriptionslistboxitem_changes.suspendResumeSubscriptionText = /*suspendResumeSubscriptionText*/ ctx[20]; if (dirty[0] & /*suspendResumeSubscriptionPath*/ 2097152) subscriptionslistboxitem_changes.suspendResumeSubscriptionPath = /*suspendResumeSubscriptionPath*/ ctx[21]; if (dirty[0] & /*subscriptionCustomFieldsText*/ 4194304) subscriptionslistboxitem_changes.subscriptionCustomFieldsText = /*subscriptionCustomFieldsText*/ ctx[22]; if (dirty[0] & /*onUpdateSubscriptionCustomFields*/ 8388608) subscriptionslistboxitem_changes.onUpdateSubscriptionCustomFields = /*onUpdateSubscriptionCustomFields*/ ctx[23]; if (dirty[0] & /*updateBillToContactText*/ 16777216) subscriptionslistboxitem_changes.updateBillToContactText = /*updateBillToContactText*/ ctx[24]; if (dirty[0] & /*updateBillToContactPath*/ 33554432) subscriptionslistboxitem_changes.updateBillToContactPath = /*updateBillToContactPath*/ ctx[25]; if (dirty[0] & /*elementsOrder*/ 67108864) subscriptionslistboxitem_changes.elementsOrder = /*elementsOrder*/ ctx[26]; if (dirty[0] & /*elementsHide*/ 134217728) subscriptionslistboxitem_changes.elementsHide = /*elementsHide*/ ctx[27]; if (dirty[0] & /*giftPillText*/ 268435456) subscriptionslistboxitem_changes.giftPillText = /*giftPillText*/ ctx[28]; if (dirty[0] & /*paymentProvider*/ 256) subscriptionslistboxitem_changes.paymentProvider = /*paymentProvider*/ ctx[8]; if (dirty[0] & /*autoRenewToggleEnabled*/ 536870912) subscriptionslistboxitem_changes.autoRenewToggleEnabled = /*autoRenewToggleEnabled*/ ctx[29]; if (dirty[0] & /*autoRenewToggleText*/ 1073741824) subscriptionslistboxitem_changes.autoRenewToggleText = /*autoRenewToggleText*/ ctx[30]; if (dirty[1] & /*onAutoRenewToggle*/ 1) subscriptionslistboxitem_changes.onAutoRenewToggle = /*onAutoRenewToggle*/ ctx[31]; if (dirty[1] & /*displayedCustomFields*/ 2) subscriptionslistboxitem_changes.displayedCustomFields = /*displayedCustomFields*/ ctx[32]; subscriptionslistboxitem.$set(subscriptionslistboxitem_changes); }, i(local) { if (current) return; transition_in(subscriptionslistboxitem.$$.fragment, local); current = true; }, o(local) { transition_out(subscriptionslistboxitem.$$.fragment, local); current = false; }, d(detaching) { destroy_component(subscriptionslistboxitem, detaching); } }; } // (96:8) {#if paymentProvider !== "zuora-billing" && subscription.status === "active" && !subscription.isGift} function create_if_block_4$4(ctx) { let button; let current; function func() { return /*func*/ ctx[33](/*subscription*/ ctx[34]); } button = new Button({ props: { disabled: false, text: /*changePaymentMethodText*/ ctx[9], onClick: func, noMargin: true } }); return { c() { create_component(button.$$.fragment); }, m(target, anchor) { mount_component(button, target, anchor); current = true; }, p(new_ctx, dirty) { ctx = new_ctx; const button_changes = {}; if (dirty[0] & /*changePaymentMethodText*/ 512) button_changes.text = /*changePaymentMethodText*/ ctx[9]; if (dirty[0] & /*onChangePayment, subscriptions*/ 2112) button_changes.onClick = func; button.$set(button_changes); }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { destroy_component(button, detaching); } }; } // (53:4) {#each subscriptions as subscription} function create_each_block_1$2(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; const if_block_creators = [create_if_block_3$5, create_else_block$2]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*elementsOrder*/ ctx[26]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if_blocks[current_block_type_index].m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if_blocks[current_block_type_index].d(detaching); } }; } // (107:2) {#if isPastSubscriptions} function create_if_block$q(ctx) { let t; let each_1_anchor; let current; let if_block = !/*loading*/ ctx[10] && !/*inactiveSubscriptions*/ ctx[7].length && create_if_block_1$h(ctx); let each_value = ensure_array_like(/*inactiveSubscriptions*/ ctx[7]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { if (if_block) if_block.c(); t = space(); for (let i = 0; i { if_block0 = null; }); check_outros(); } if (!/*isPastSubscriptions*/ ctx[0]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty[0] & /*isPastSubscriptions*/ 1) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_2$a(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div, t1); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*isPastSubscriptions*/ ctx[0]) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty[0] & /*isPastSubscriptions*/ 1) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block$q(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(div, null); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); transition_in(if_block2); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); transition_out(if_block2); current = false; }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); } }; } const func_1$1 = () => { }; function instance$y($$self, $$props, $$invalidate) { let { isPastSubscriptions } = $$props; let { noSubscriptionsMessage } = $$props; let { billingHistoryText } = $$props; let { billingHistoryLink } = $$props; let { nextPaymentDateText } = $$props; let { subscriptionRateText } = $$props; let { subscriptions } = $$props; let { inactiveSubscriptions } = $$props; let { paymentProvider } = $$props; let { changePaymentMethodText } = $$props; let { loading } = $$props; let { onChangePayment } = $$props; let { logChangeSubscription } = $$props; let { logCancelSubscription } = $$props; let { logSuspendResumeSubscription } = $$props; let { onViewHistory } = $$props; let { changeSubscriptionText } = $$props; let { cancelSubscriptionText } = $$props; let { changeSubscriptionPath } = $$props; let { cancelSubscriptionPath } = $$props; let { suspendResumeSubscriptionText } = $$props; let { suspendResumeSubscriptionPath } = $$props; let { subscriptionCustomFieldsText } = $$props; let { onUpdateSubscriptionCustomFields } = $$props; let { updateBillToContactText } = $$props; let { updateBillToContactPath } = $$props; let { elementsOrder } = $$props; let { elementsHide } = $$props; let { giftPillText = 'Gift' } = $$props; let { autoRenewToggleEnabled = false } = $$props; let { autoRenewToggleText = 'Auto-renew subscription' } = $$props; let { onAutoRenewToggle = async () => ({ success: false }) } = $$props; let { displayedCustomFields = {} } = $$props; onMount(() => { }); const func = subscription => onChangePayment(subscription); $$self.$$set = $$props => { if ('isPastSubscriptions' in $$props) $$invalidate(0, isPastSubscriptions = $$props.isPastSubscriptions); if ('noSubscriptionsMessage' in $$props) $$invalidate(1, noSubscriptionsMessage = $$props.noSubscriptionsMessage); if ('billingHistoryText' in $$props) $$invalidate(2, billingHistoryText = $$props.billingHistoryText); if ('billingHistoryLink' in $$props) $$invalidate(3, billingHistoryLink = $$props.billingHistoryLink); if ('nextPaymentDateText' in $$props) $$invalidate(4, nextPaymentDateText = $$props.nextPaymentDateText); if ('subscriptionRateText' in $$props) $$invalidate(5, subscriptionRateText = $$props.subscriptionRateText); if ('subscriptions' in $$props) $$invalidate(6, subscriptions = $$props.subscriptions); if ('inactiveSubscriptions' in $$props) $$invalidate(7, inactiveSubscriptions = $$props.inactiveSubscriptions); if ('paymentProvider' in $$props) $$invalidate(8, paymentProvider = $$props.paymentProvider); if ('changePaymentMethodText' in $$props) $$invalidate(9, changePaymentMethodText = $$props.changePaymentMethodText); if ('loading' in $$props) $$invalidate(10, loading = $$props.loading); if ('onChangePayment' in $$props) $$invalidate(11, onChangePayment = $$props.onChangePayment); if ('logChangeSubscription' in $$props) $$invalidate(12, logChangeSubscription = $$props.logChangeSubscription); if ('logCancelSubscription' in $$props) $$invalidate(13, logCancelSubscription = $$props.logCancelSubscription); if ('logSuspendResumeSubscription' in $$props) $$invalidate(14, logSuspendResumeSubscription = $$props.logSuspendResumeSubscription); if ('onViewHistory' in $$props) $$invalidate(15, onViewHistory = $$props.onViewHistory); if ('changeSubscriptionText' in $$props) $$invalidate(16, changeSubscriptionText = $$props.changeSubscriptionText); if ('cancelSubscriptionText' in $$props) $$invalidate(17, cancelSubscriptionText = $$props.cancelSubscriptionText); if ('changeSubscriptionPath' in $$props) $$invalidate(18, changeSubscriptionPath = $$props.changeSubscriptionPath); if ('cancelSubscriptionPath' in $$props) $$invalidate(19, cancelSubscriptionPath = $$props.cancelSubscriptionPath); if ('suspendResumeSubscriptionText' in $$props) $$invalidate(20, suspendResumeSubscriptionText = $$props.suspendResumeSubscriptionText); if ('suspendResumeSubscriptionPath' in $$props) $$invalidate(21, suspendResumeSubscriptionPath = $$props.suspendResumeSubscriptionPath); if ('subscriptionCustomFieldsText' in $$props) $$invalidate(22, subscriptionCustomFieldsText = $$props.subscriptionCustomFieldsText); if ('onUpdateSubscriptionCustomFields' in $$props) $$invalidate(23, onUpdateSubscriptionCustomFields = $$props.onUpdateSubscriptionCustomFields); if ('updateBillToContactText' in $$props) $$invalidate(24, updateBillToContactText = $$props.updateBillToContactText); if ('updateBillToContactPath' in $$props) $$invalidate(25, updateBillToContactPath = $$props.updateBillToContactPath); if ('elementsOrder' in $$props) $$invalidate(26, elementsOrder = $$props.elementsOrder); if ('elementsHide' in $$props) $$invalidate(27, elementsHide = $$props.elementsHide); if ('giftPillText' in $$props) $$invalidate(28, giftPillText = $$props.giftPillText); if ('autoRenewToggleEnabled' in $$props) $$invalidate(29, autoRenewToggleEnabled = $$props.autoRenewToggleEnabled); if ('autoRenewToggleText' in $$props) $$invalidate(30, autoRenewToggleText = $$props.autoRenewToggleText); if ('onAutoRenewToggle' in $$props) $$invalidate(31, onAutoRenewToggle = $$props.onAutoRenewToggle); if ('displayedCustomFields' in $$props) $$invalidate(32, displayedCustomFields = $$props.displayedCustomFields); }; return [ isPastSubscriptions, noSubscriptionsMessage, billingHistoryText, billingHistoryLink, nextPaymentDateText, subscriptionRateText, subscriptions, inactiveSubscriptions, paymentProvider, changePaymentMethodText, loading, onChangePayment, logChangeSubscription, logCancelSubscription, logSuspendResumeSubscription, onViewHistory, changeSubscriptionText, cancelSubscriptionText, changeSubscriptionPath, cancelSubscriptionPath, suspendResumeSubscriptionText, suspendResumeSubscriptionPath, subscriptionCustomFieldsText, onUpdateSubscriptionCustomFields, updateBillToContactText, updateBillToContactPath, elementsOrder, elementsHide, giftPillText, autoRenewToggleEnabled, autoRenewToggleText, onAutoRenewToggle, displayedCustomFields, func ]; } class SubscriptionsList extends SvelteComponent { constructor(options) { super(); init( this, options, instance$y, create_fragment$y, safe_not_equal, { isPastSubscriptions: 0, noSubscriptionsMessage: 1, billingHistoryText: 2, billingHistoryLink: 3, nextPaymentDateText: 4, subscriptionRateText: 5, subscriptions: 6, inactiveSubscriptions: 7, paymentProvider: 8, changePaymentMethodText: 9, loading: 10, onChangePayment: 11, logChangeSubscription: 12, logCancelSubscription: 13, logSuspendResumeSubscription: 14, onViewHistory: 15, changeSubscriptionText: 16, cancelSubscriptionText: 17, changeSubscriptionPath: 18, cancelSubscriptionPath: 19, suspendResumeSubscriptionText: 20, suspendResumeSubscriptionPath: 21, subscriptionCustomFieldsText: 22, onUpdateSubscriptionCustomFields: 23, updateBillToContactText: 24, updateBillToContactPath: 25, elementsOrder: 26, elementsHide: 27, giftPillText: 28, autoRenewToggleEnabled: 29, autoRenewToggleText: 30, onAutoRenewToggle: 31, displayedCustomFields: 32 }, null, [-1, -1] ); } } const updateZuoraSubscriptionAutoRenew = async (subscription, autoRenew, formActions) => { try { const order = { subscription: { orderActions: [{ type: "TermsAndConditions", termsAndConditions: { autoRenew } }] } }; const requestBody = { vendor_fields: { order: JSON.stringify(order) } }; const response = await request(`zephr/subscriptions/${subscription.externalId}/manage`, { method: 'POST', bodyObject: requestBody }, formActions); if (!response?.ok) { const errorText = await response?.text() || 'Unknown error occurred'; console.error('Error updating subscription auto-renewal:', response); return { success: false, error: `HTTP ${response?.status}: ${errorText}` }; } const result = await response.json(); if (result.error) { console.error('API error updating subscription auto-renewal:', result.error); return { success: false, error: result.error }; } return { success: true, message: 'Settings updated' }; } catch (error) { console.error('Exception updating subscription auto-renewal:', error); return { success: false, error: error instanceof Error ? error.message : 'An unexpected error occurred' }; } }; // Temporarily disable this feature const shouldShowSubscriptionCustomFields = false; const subscriptionCustomFieldsUpdateFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.SUBSCRIPTION_CUSTOM_FIELDS_UPDATE, create: (form, formState, formActions, elementConfig) => { // Return null component to prevent rendering { return { component: null, props: {} }; } } }; const subscriptionsListFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.SUBSCRIPTIONS_LIST, create: (form, formState, formActions, elementConfig) => { const existingSubscriptions = formState.existingSubscriptions || []; const giftPillText = elementConfig.giftPillText || 'Gift'; const allActiveSubscriptions = existingSubscriptions.filter(s => s.status === 'active'); const allInactiveSubscriptions = existingSubscriptions.filter(s => s.status !== 'active'); // Auto-renew toggle handler for Zuora billing subscriptions const onAutoRenewToggle = async (subscription, autoRenew) => { try { let result; // Mock API call in preview mode if (form.environment?.previewMode) { // Simulate API delay await new Promise(resolve => setTimeout(resolve, 1000)); // Mock successful response (you could add logic to simulate failures occasionally) result = { success: true, message: 'Preferences updated' }; } else { result = await updateZuoraSubscriptionAutoRenew(subscription, autoRenew, formActions); } if (result.success) { // Update the subscription in the local state const updatedSubscriptions = existingSubscriptions.map(sub => sub.externalId === subscription.externalId ? { ...sub, autoRenew } : sub); formActions.updateFormState({ existingSubscriptions: updatedSubscriptions }); // Log the change logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'AUTO_RENEW_TOGGLE' }); return { success: true, message: result.message }; } else { return { success: false, error: result.error }; } } catch (error) { console.error('Error updating auto-renewal:', error); return { success: false, error: error instanceof Error ? error.message : 'An unexpected error occurred' }; } }; return { component: SubscriptionsList, props: { isPastSubscriptions: elementConfig.isPastSubscriptions, subscriptionTitle: elementConfig.subscriptionTitle, billingHistoryText: elementConfig.billingHistoryText, billingHistoryLink: elementConfig.billingHistoryLink, noSubscriptionsMessage: elementConfig.noSubscriptionsMessage, nextPaymentDateText: elementConfig.nextPaymentDateText, subscriptionRateText: elementConfig.subscriptionRateText, loading: !formState.existingSubscriptions || formState.loadingSubscriptions, subscriptions: allActiveSubscriptions, inactiveSubscriptions: allInactiveSubscriptions, paymentProvider: form.organisationConfiguration.paymentProvider, changePaymentMethodText: elementConfig.changePaymentMethodText, onChangePayment: (subscription) => { formActions.updateFormState({ selectedSubscription: subscription }); logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.completeSection(); }, onViewHistory: (subscription) => { formActions.updateFormState({ selectedSubscription: subscription }); formActions.jumpToPartStart('billing-history'); logDataLayerEvent(form, 'zephr_form_billing_history_view', null); }, logChangeSubscription: (subscription) => { logDataLayerEvent(form, 'zephr_form_subscription_change_clicked', { productId: subscription.productId, planId: subscription.externalId }); }, logCancelSubscription: (subscription) => { logDataLayerEvent(form, 'zephr_form_cancel_subscription_clicked', { productId: subscription.productId, planId: subscription.externalId }); }, logSuspendResumeSubscription: (subscription) => { logDataLayerEvent(form, 'zephr_form_suspend_resume_subscription_clicked', { productId: subscription.productId, planId: subscription.externalId, status: subscription.status }); }, changeSubscriptionText: elementConfig.changeSubscriptionText, cancelSubscriptionText: elementConfig.cancelSubscriptionText, changeSubscriptionPath: elementConfig.changeSubscriptionPath, cancelSubscriptionPath: elementConfig.cancelSubscriptionPath, suspendResumeSubscriptionText: elementConfig.suspendResumeSubscriptionText, suspendResumeSubscriptionPath: elementConfig.suspendResumeSubscriptionPath, updateBillToContactText: elementConfig.updateBillToContactText, updateBillToContactPath: elementConfig.updateBillToContactPath, elementsOrder: elementConfig.elementsOrder, subscriptionCustomFieldsText: elementConfig.subscriptionCustomFieldsText || 'Update subscription details', onUpdateSubscriptionCustomFields: (subscription) => { formActions.updateFormState({ selectedSubscription: subscription }); formActions.jumpToPartStart('subscription-custom-fields'); logDataLayerEvent(form, 'zephr_form_subscription_custom_fields_clicked', { productId: subscription.productId, planId: subscription.externalId }); }, elementsHide: { subscriptionInformation: elementConfig?.hideSubscriptionInformation, changePayment: elementConfig?.hideChangePayment, changeSubscription: elementConfig?.hideChangeSubscription, cancelSubscription: elementConfig?.hideCancelSubscription, billingHistory: elementConfig?.hideBillingHistory, suspendResumeSubscription: elementConfig?.hideSuspendResumeSubscription, // elementConfig?.hideSubscriptionCustomFields, subscriptionCustomFields: !shouldShowSubscriptionCustomFields, updateBillToContact: elementConfig?.hideUpdateBillToContact }, giftPillText, autoRenewToggleEnabled: elementConfig.autoRenewToggleEnabled || false, autoRenewToggleText: elementConfig.autoRenewToggleText || 'Auto-renew subscription', onAutoRenewToggle: onAutoRenewToggle, displayedCustomFields: elementConfig.displayedCustomFields || {} } }; } }; /* src/components/elements/pastSubscriptionsLink/PastSubscriptionsLink.svelte generated by Svelte v4.2.12 */ function create_if_block$p(ctx) { let div; let link; let current; link = new Link({ props: { text: /*linkText*/ ctx[2] } }); link.$on("linkClick", function () { if (is_function(/*onClick*/ ctx[3])) /*onClick*/ ctx[3].apply(this, arguments); }); return { c() { div = element("div"); create_component(link.$$.fragment); attr(div, "class", "past-subscriptions-link-wrapper svelte-zpa2t"); }, m(target, anchor) { insert(target, div, anchor); mount_component(link, div, null); current = true; }, p(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*linkText*/ 4) link_changes.text = /*linkText*/ ctx[2]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(link); } }; } function create_fragment$x(ctx) { let if_block_anchor; let current; let if_block = /*show*/ ctx[1] && !/*loading*/ ctx[0] && create_if_block$p(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { if (/*show*/ ctx[1] && !/*loading*/ ctx[0]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*show, loading*/ 3) { transition_in(if_block, 1); } } else { if_block = create_if_block$p(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$x($$self, $$props, $$invalidate) { let { loading } = $$props; let { show } = $$props; let { linkText } = $$props; let { onClick } = $$props; $$self.$$set = $$props => { if ('loading' in $$props) $$invalidate(0, loading = $$props.loading); if ('show' in $$props) $$invalidate(1, show = $$props.show); if ('linkText' in $$props) $$invalidate(2, linkText = $$props.linkText); if ('onClick' in $$props) $$invalidate(3, onClick = $$props.onClick); }; return [loading, show, linkText, onClick]; } class PastSubscriptionsLink extends SvelteComponent { constructor(options) { super(); init(this, options, instance$x, create_fragment$x, safe_not_equal, { loading: 0, show: 1, linkText: 2, onClick: 3 }); } } const pastSubscriptionsLinkFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.PAST_SUBSCRIPTIONS_LINK, create: (form, formState, formActions, elementConfig) => ({ component: PastSubscriptionsLink, props: { loading: !formState.existingSubscriptions || formState.loadingSubscriptions, show: elementConfig.show, linkText: elementConfig.linkText, onClick: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'PAST_SUBSCRIPTIONS_LINK' }); formActions.jumpToPartStart('past-subscriptions'); } } }) }; /* src/components/elements/changePaymentMethodButton/ChangePaymentMethodButton.svelte generated by Svelte v4.2.12 */ function create_fragment$w(ctx) { let div; let button; let current; button = new Button({ props: { disabled: false, text: /*text*/ ctx[0], onClick: /*func*/ ctx[2] } }); return { c() { div = element("div"); create_component(button.$$.fragment); attr(div, "class", "change-payment-method-button-container"); }, m(target, anchor) { insert(target, div, anchor); mount_component(button, div, null); current = true; }, p(ctx, [dirty]) { const button_changes = {}; if (dirty & /*text*/ 1) button_changes.text = /*text*/ ctx[0]; if (dirty & /*onChangePayment*/ 2) button_changes.onClick = /*func*/ ctx[2]; button.$set(button_changes); }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(button); } }; } function instance$w($$self, $$props, $$invalidate) { let { text } = $$props; let { onChangePayment } = $$props; const func = () => onChangePayment(); $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('onChangePayment' in $$props) $$invalidate(1, onChangePayment = $$props.onChangePayment); }; return [text, onChangePayment, func]; } class ChangePaymentMethodButton extends SvelteComponent { constructor(options) { super(); init(this, options, instance$w, create_fragment$w, safe_not_equal, { text: 0, onChangePayment: 1 }); } } const changePaymentMethodButtonFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.CHNAGE_PAYMENT_METHOD_BUTTON, create: (form, formState, formActions, elementConfig) => ({ component: ChangePaymentMethodButton, props: { text: elementConfig.text, onChangePayment: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.completeSection(); } } }) }; /* src/components/elements/eventLink/EventLink.svelte generated by Svelte v4.2.12 */ function create_fragment$v(ctx) { let div; let link; let div_class_value; let current; link = new Link({ props: { text: /*text*/ ctx[0], onClick: /*onClick*/ ctx[2] } }); link.$on("linkClick", function () { if (is_function(/*onClick*/ ctx[2])) /*onClick*/ ctx[2].apply(this, arguments); }); return { c() { div = element("div"); create_component(link.$$.fragment); attr(div, "class", div_class_value = "" + (null_to_empty(`event-link-wrapper ${/*floatRight*/ ctx[1] ? "float-right" : ""}`) + " svelte-3cxpfz")); }, m(target, anchor) { insert(target, div, anchor); mount_component(link, div, null); current = true; }, p(new_ctx, [dirty]) { ctx = new_ctx; const link_changes = {}; if (dirty & /*text*/ 1) link_changes.text = /*text*/ ctx[0]; if (dirty & /*onClick*/ 4) link_changes.onClick = /*onClick*/ ctx[2]; link.$set(link_changes); if (!current || dirty & /*floatRight*/ 2 && div_class_value !== (div_class_value = "" + (null_to_empty(`event-link-wrapper ${/*floatRight*/ ctx[1] ? "float-right" : ""}`) + " svelte-3cxpfz"))) { attr(div, "class", div_class_value); } }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(link); } }; } function instance$v($$self, $$props, $$invalidate) { let { text } = $$props; let { floatRight } = $$props; let { onClick } = $$props; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('floatRight' in $$props) $$invalidate(1, floatRight = $$props.floatRight); if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick); }; return [text, floatRight, onClick]; } class EventLink extends SvelteComponent { constructor(options) { super(); init(this, options, instance$v, create_fragment$v, safe_not_equal, { text: 0, floatRight: 1, onClick: 2 }); } } const eventLinkFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.EVENT_LINK, create: (form, formState, formActions, elementConfig) => ({ component: EventLink, props: { text: elementConfig.text, floatRight: elementConfig.floatRight, onClick: () => { console.log({ sectionId: formState.currentSection.type, buttonType: 'EVENT_LINK' }); logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'EVENT_LINK' }); formActions.onEvent(elementConfig.event); } } }) }; /* src/components/elements/email/ReadOnlyEmailAddress.svelte generated by Svelte v4.2.12 */ function create_if_block$o(ctx) { let link; let current; link = new Link({ props: { text: /*updateLabel*/ ctx[2] } }); link.$on("linkClick", function () { if (is_function(/*onUpdate*/ ctx[4])) /*onUpdate*/ ctx[4].apply(this, arguments); }); return { c() { create_component(link.$$.fragment); }, m(target, anchor) { mount_component(link, target, anchor); current = true; }, p(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*updateLabel*/ 4) link_changes.text = /*updateLabel*/ ctx[2]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { destroy_component(link, detaching); } }; } function create_fragment$u(ctx) { let div0; let label_1; let t0; let div1; let input; let t1; let current; label_1 = new Label({ props: { forInput: /*id*/ ctx[5], label: /*label*/ ctx[0] } }); let if_block = /*updateEnabled*/ ctx[3] && create_if_block$o(ctx); return { c() { div0 = element("div"); create_component(label_1.$$.fragment); t0 = space(); div1 = element("div"); input = element("input"); t1 = space(); if (if_block) if_block.c(); attr(div0, "class", "bold-label svelte-nx4w5y"); attr(input, "id", /*id*/ ctx[5]); attr(input, "type", "email"); attr(input, "name", "email"); input.value = /*emailAddress*/ ctx[1]; input.readOnly = true; attr(input, "class", "read-only-input svelte-nx4w5y"); attr(div1, "class", "zephr-form-relative-container svelte-nx4w5y"); }, m(target, anchor) { insert(target, div0, anchor); mount_component(label_1, div0, null); insert(target, t0, anchor); insert(target, div1, anchor); append(div1, input); append(div1, t1); if (if_block) if_block.m(div1, null); current = true; }, p(ctx, [dirty]) { const label_1_changes = {}; if (dirty & /*label*/ 1) label_1_changes.label = /*label*/ ctx[0]; label_1.$set(label_1_changes); if (!current || dirty & /*emailAddress*/ 2 && input.value !== /*emailAddress*/ ctx[1]) { input.value = /*emailAddress*/ ctx[1]; } if (/*updateEnabled*/ ctx[3]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*updateEnabled*/ 8) { transition_in(if_block, 1); } } else { if_block = create_if_block$o(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(div1, null); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(if_block); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(div0); detach(t0); detach(div1); } destroy_component(label_1); if (if_block) if_block.d(); } }; } function instance$u($$self, $$props, $$invalidate) { let { formKey } = $$props; let { label } = $$props; let { emailAddress } = $$props; let { updateLabel } = $$props; let { updateEnabled } = $$props; let { onUpdate } = $$props; const id = `zephr-form-read-only-email-address-${formKey}`; $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(6, formKey = $$props.formKey); if ('label' in $$props) $$invalidate(0, label = $$props.label); if ('emailAddress' in $$props) $$invalidate(1, emailAddress = $$props.emailAddress); if ('updateLabel' in $$props) $$invalidate(2, updateLabel = $$props.updateLabel); if ('updateEnabled' in $$props) $$invalidate(3, updateEnabled = $$props.updateEnabled); if ('onUpdate' in $$props) $$invalidate(4, onUpdate = $$props.onUpdate); }; return [label, emailAddress, updateLabel, updateEnabled, onUpdate, id, formKey]; } class ReadOnlyEmailAddress extends SvelteComponent { constructor(options) { super(); init(this, options, instance$u, create_fragment$u, safe_not_equal, { formKey: 6, label: 0, emailAddress: 1, updateLabel: 2, updateEnabled: 3, onUpdate: 4 }); } } const factory$8 = { matches: (sectionElement) => sectionElement.type === elementTypes.READ_ONLY_EMAIL_ADDRESS, create: (form, formState, formActions, elementConfig) => { return { component: ReadOnlyEmailAddress, props: { formKey: form.uniqueKey, emailAddress: formState.readOnlyEmail ?? '', label: elementConfig.label, updateLabel: elementConfig.updateLinkLabel, updateEnabled: elementConfig.updateLinkEnabled, onUpdate: () => formActions.jumpToPartStart('email-update') } }; } }; /* src/components/elements/password/ReadOnlyPassword.svelte generated by Svelte v4.2.12 */ function create_if_block$n(ctx) { let link; let current; link = new Link({ props: { text: /*updateLabel*/ ctx[1] } }); link.$on("linkClick", function () { if (is_function(/*onUpdate*/ ctx[3])) /*onUpdate*/ ctx[3].apply(this, arguments); }); return { c() { create_component(link.$$.fragment); }, m(target, anchor) { mount_component(link, target, anchor); current = true; }, p(new_ctx, dirty) { ctx = new_ctx; const link_changes = {}; if (dirty & /*updateLabel*/ 2) link_changes.text = /*updateLabel*/ ctx[1]; link.$set(link_changes); }, i(local) { if (current) return; transition_in(link.$$.fragment, local); current = true; }, o(local) { transition_out(link.$$.fragment, local); current = false; }, d(detaching) { destroy_component(link, detaching); } }; } function create_fragment$t(ctx) { let div0; let label_1; let t0; let div1; let input; let t1; let current; label_1 = new Label({ props: { forInput: /*id*/ ctx[4], label: /*label*/ ctx[0] } }); let if_block = /*updateEnabled*/ ctx[2] && create_if_block$n(ctx); return { c() { div0 = element("div"); create_component(label_1.$$.fragment); t0 = space(); div1 = element("div"); input = element("input"); t1 = space(); if (if_block) if_block.c(); attr(div0, "class", "bold-label svelte-nx4w5y"); attr(input, "id", /*id*/ ctx[4]); attr(input, "type", "password"); input.value = "••••••••••••••••"; input.readOnly = true; attr(input, "class", "read-only-input svelte-nx4w5y"); attr(div1, "class", "zephr-form-relative-container svelte-nx4w5y"); }, m(target, anchor) { insert(target, div0, anchor); mount_component(label_1, div0, null); insert(target, t0, anchor); insert(target, div1, anchor); append(div1, input); append(div1, t1); if (if_block) if_block.m(div1, null); current = true; }, p(ctx, [dirty]) { const label_1_changes = {}; if (dirty & /*label*/ 1) label_1_changes.label = /*label*/ ctx[0]; label_1.$set(label_1_changes); if (/*updateEnabled*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*updateEnabled*/ 4) { transition_in(if_block, 1); } } else { if_block = create_if_block$n(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(div1, null); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); transition_in(if_block); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(div0); detach(t0); detach(div1); } destroy_component(label_1); if (if_block) if_block.d(); } }; } function instance$t($$self, $$props, $$invalidate) { let { formKey } = $$props; let { label } = $$props; let { updateLabel } = $$props; let { updateEnabled } = $$props; let { onUpdate } = $$props; const id = `zephr-form-read-only-password-${formKey}`; $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(5, formKey = $$props.formKey); if ('label' in $$props) $$invalidate(0, label = $$props.label); if ('updateLabel' in $$props) $$invalidate(1, updateLabel = $$props.updateLabel); if ('updateEnabled' in $$props) $$invalidate(2, updateEnabled = $$props.updateEnabled); if ('onUpdate' in $$props) $$invalidate(3, onUpdate = $$props.onUpdate); }; return [label, updateLabel, updateEnabled, onUpdate, id, formKey]; } class ReadOnlyPassword extends SvelteComponent { constructor(options) { super(); init(this, options, instance$t, create_fragment$t, safe_not_equal, { formKey: 5, label: 0, updateLabel: 1, updateEnabled: 2, onUpdate: 3 }); } } const factory$7 = { matches: (sectionElement) => sectionElement.type === elementTypes.READ_ONLY_PASSWORD, create: (form, formState, formActions, elementConfig) => { return { component: ReadOnlyPassword, props: { formKey: form.uniqueKey, label: elementConfig.label, updateLabel: elementConfig.updateLinkLabel, updateEnabled: elementConfig.updateLinkEnabled, onUpdate: () => formActions.jumpToPartStart('password-update') } }; } }; /* src/components/elements/userAttribute/ReadOnlyUserAttribute.svelte generated by Svelte v4.2.12 */ function create_else_block$1(ctx) { let div2; let div0; let t0; let t1; let div1; let t2; return { c() { div2 = element("div"); div0 = element("div"); t0 = text(/*label*/ ctx[3]); t1 = space(); div1 = element("div"); t2 = text(/*value*/ ctx[2]); attr(div0, "class", "zephr-form-ro-attribute-label"); attr(div1, "class", "zephr-form-ro-attribute-value"); attr(div2, "class", "zephr-form-ro-attribute"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div0); append(div0, t0); append(div2, t1); append(div2, div1); append(div1, t2); }, p(ctx, dirty) { if (dirty & /*label*/ 8) set_data(t0, /*label*/ ctx[3]); if (dirty & /*value*/ 4) set_data(t2, /*value*/ ctx[2]); }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div2); } } }; } // (8:0) {#if isCheckbox} function create_if_block$m(ctx) { let div; let checkbox; let current; checkbox = new Checkbox({ props: { id: `zephr-form-ro-checkbox-${/*slug*/ ctx[1]}`, name: /*slug*/ ctx[1], label: /*label*/ ctx[3], required: false, value: /*value*/ ctx[2], checked: /*value*/ ctx[2], disabled: true } }); return { c() { div = element("div"); create_component(checkbox.$$.fragment); attr(div, "class", "zephr-form-ro-attribute"); }, m(target, anchor) { insert(target, div, anchor); mount_component(checkbox, div, null); current = true; }, p(ctx, dirty) { const checkbox_changes = {}; if (dirty & /*slug*/ 2) checkbox_changes.id = `zephr-form-ro-checkbox-${/*slug*/ ctx[1]}`; if (dirty & /*slug*/ 2) checkbox_changes.name = /*slug*/ ctx[1]; if (dirty & /*label*/ 8) checkbox_changes.label = /*label*/ ctx[3]; if (dirty & /*value*/ 4) checkbox_changes.value = /*value*/ ctx[2]; if (dirty & /*value*/ 4) checkbox_changes.checked = /*value*/ ctx[2]; checkbox.$set(checkbox_changes); }, i(local) { if (current) return; transition_in(checkbox.$$.fragment, local); current = true; }, o(local) { transition_out(checkbox.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(checkbox); } }; } function create_fragment$s(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; const if_block_creators = [create_if_block$m, create_else_block$1]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*isCheckbox*/ ctx[0]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if_blocks[current_block_type_index].m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { let previous_block_index = current_block_type_index; current_block_type_index = select_block_type(ctx); if (current_block_type_index === previous_block_index) { if_blocks[current_block_type_index].p(ctx, dirty); } else { group_outros(); transition_out(if_blocks[previous_block_index], 1, 1, () => { if_blocks[previous_block_index] = null; }); check_outros(); if_block = if_blocks[current_block_type_index]; if (!if_block) { if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block.c(); } else { if_block.p(ctx, dirty); } transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if_blocks[current_block_type_index].d(detaching); } }; } function instance$s($$self, $$props, $$invalidate) { let { isCheckbox } = $$props; let { slug } = $$props; let { value } = $$props; let { label } = $$props; $$self.$$set = $$props => { if ('isCheckbox' in $$props) $$invalidate(0, isCheckbox = $$props.isCheckbox); if ('slug' in $$props) $$invalidate(1, slug = $$props.slug); if ('value' in $$props) $$invalidate(2, value = $$props.value); if ('label' in $$props) $$invalidate(3, label = $$props.label); }; return [isCheckbox, slug, value, label]; } class ReadOnlyUserAttribute extends SvelteComponent { constructor(options) { super(); init(this, options, instance$s, create_fragment$s, safe_not_equal, { isCheckbox: 0, slug: 1, value: 2, label: 3 }); } } const selectAttributeTypes = ['radio', 'select']; const readOnlyUserAttributeFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.READ_ONLY_USER_ATTRIBUTE, create: (form, formState, _, elementConfig) => { const attributeSchema = form.organisationConfiguration.schemaFields.find(s => s.slug === elementConfig.slug); let value = (formState.readOnlyAttributeValues ?? {})[elementConfig.slug] ?? ''; if (value && selectAttributeTypes.includes(attributeSchema?.["input-type"])) { value = (attributeSchema?.["select-options"] ?? []).find(o => o.value === value)?.label ?? value; } const isCheckbox = attributeSchema?.["input-type"] === 'checkbox'; return { component: ReadOnlyUserAttribute, props: { value, slug: elementConfig.slug, label: elementConfig.label, isCheckbox, } }; } }; /* src/components/elements/devices/DeviceSessionWrapper.svelte generated by Svelte v4.2.12 */ function create_if_block_1$g(ctx) { let span; let t; return { c() { span = element("span"); t = text(/*currentDeviceLabel*/ ctx[2]); attr(span, "class", "current-device svelte-jmotet"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty & /*currentDeviceLabel*/ 4) set_data(t, /*currentDeviceLabel*/ ctx[2]); }, d(detaching) { if (detaching) { detach(span); } } }; } // (22:4) {#if !deviceSession.requestingSession} function create_if_block$l(ctx) { let button; let current; button = new Button({ props: { disabled: false, text: /*signOutLabel*/ ctx[4], onClick: /*func*/ ctx[5] } }); return { c() { create_component(button.$$.fragment); }, m(target, anchor) { mount_component(button, target, anchor); current = true; }, p(ctx, dirty) { const button_changes = {}; if (dirty & /*signOutLabel*/ 16) button_changes.text = /*signOutLabel*/ ctx[4]; if (dirty & /*onDeviceSignOut, deviceSession*/ 3) button_changes.onClick = /*func*/ ctx[5]; button.$set(button_changes); }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { destroy_component(button, detaching); } }; } function create_fragment$r(ctx) { let div4; let div0; let t0_value = /*deviceSession*/ ctx[0].deviceName + ""; let t0; let t1; let t2; let div1; let t3; let t4; let t5_value = /*deviceSession*/ ctx[0].startDate + ""; let t5; let t6; let div2; let t7_value = /*deviceSession*/ ctx[0].browser + ""; let t7; let t8; let div3; let t9_value = /*deviceSession*/ ctx[0].country + ""; let t9; let t10; let t11; let hr; let current; let if_block0 = /*deviceSession*/ ctx[0].requestingSession && create_if_block_1$g(ctx); let if_block1 = !/*deviceSession*/ ctx[0].requestingSession && create_if_block$l(ctx); return { c() { div4 = element("div"); div0 = element("div"); t0 = text(t0_value); t1 = space(); if (if_block0) if_block0.c(); t2 = space(); div1 = element("div"); t3 = text(/*loginTimeLabel*/ ctx[3]); t4 = text(": "); t5 = text(t5_value); t6 = space(); div2 = element("div"); t7 = text(t7_value); t8 = space(); div3 = element("div"); t9 = text(t9_value); t10 = space(); if (if_block1) if_block1.c(); t11 = space(); hr = element("hr"); attr(div0, "class", "device-title svelte-jmotet"); attr(div1, "class", "login-time svelte-jmotet"); attr(div2, "class", "browser svelte-jmotet"); attr(div3, "class", "country svelte-jmotet"); attr(hr, "class", "svelte-jmotet"); attr(div4, "class", "session-container svelte-jmotet"); }, m(target, anchor) { insert(target, div4, anchor); append(div4, div0); append(div0, t0); append(div0, t1); if (if_block0) if_block0.m(div0, null); append(div4, t2); append(div4, div1); append(div1, t3); append(div1, t4); append(div1, t5); append(div4, t6); append(div4, div2); append(div2, t7); append(div4, t8); append(div4, div3); append(div3, t9); append(div4, t10); if (if_block1) if_block1.m(div4, null); append(div4, t11); append(div4, hr); current = true; }, p(ctx, [dirty]) { if ((!current || dirty & /*deviceSession*/ 1) && t0_value !== (t0_value = /*deviceSession*/ ctx[0].deviceName + "")) set_data(t0, t0_value); if (/*deviceSession*/ ctx[0].requestingSession) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$g(ctx); if_block0.c(); if_block0.m(div0, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (!current || dirty & /*loginTimeLabel*/ 8) set_data(t3, /*loginTimeLabel*/ ctx[3]); if ((!current || dirty & /*deviceSession*/ 1) && t5_value !== (t5_value = /*deviceSession*/ ctx[0].startDate + "")) set_data(t5, t5_value); if ((!current || dirty & /*deviceSession*/ 1) && t7_value !== (t7_value = /*deviceSession*/ ctx[0].browser + "")) set_data(t7, t7_value); if ((!current || dirty & /*deviceSession*/ 1) && t9_value !== (t9_value = /*deviceSession*/ ctx[0].country + "")) set_data(t9, t9_value); if (!/*deviceSession*/ ctx[0].requestingSession) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*deviceSession*/ 1) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$l(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div4, t11); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block1); current = true; }, o(local) { transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div4); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); } }; } function instance$r($$self, $$props, $$invalidate) { let { deviceSession } = $$props; let { onDeviceSignOut } = $$props; let { currentDeviceLabel } = $$props; let { loginTimeLabel } = $$props; let { signOutLabel } = $$props; const func = () => onDeviceSignOut(deviceSession.id); $$self.$$set = $$props => { if ('deviceSession' in $$props) $$invalidate(0, deviceSession = $$props.deviceSession); if ('onDeviceSignOut' in $$props) $$invalidate(1, onDeviceSignOut = $$props.onDeviceSignOut); if ('currentDeviceLabel' in $$props) $$invalidate(2, currentDeviceLabel = $$props.currentDeviceLabel); if ('loginTimeLabel' in $$props) $$invalidate(3, loginTimeLabel = $$props.loginTimeLabel); if ('signOutLabel' in $$props) $$invalidate(4, signOutLabel = $$props.signOutLabel); }; return [ deviceSession, onDeviceSignOut, currentDeviceLabel, loginTimeLabel, signOutLabel, func ]; } class DeviceSessionWrapper extends SvelteComponent { constructor(options) { super(); init(this, options, instance$r, create_fragment$r, safe_not_equal, { deviceSession: 0, onDeviceSignOut: 1, currentDeviceLabel: 2, loginTimeLabel: 3, signOutLabel: 4 }); } } /* src/components/elements/devices/DevicesSessionList.svelte generated by Svelte v4.2.12 */ function get_each_context$a(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[7] = list[i]; return child_ctx; } // (33:4) {#if devicesSessions == null} function create_if_block_1$f(ctx) { let fa; let current; fa = new Fa({ props: { icon: faSpinner, spin: true, size: "lg" } }); return { c() { create_component(fa.$$.fragment); }, m(target, anchor) { mount_component(fa, target, anchor); current = true; }, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { destroy_component(fa, detaching); } }; } // (36:4) {#if devicesSessions != null && !devicesSessions.length} function create_if_block$k(ctx) { let div; return { c() { div = element("div"); }, m(target, anchor) { insert(target, div, anchor); div.innerHTML = /*noDeviceSessionsMessage*/ ctx[1]; }, p(ctx, dirty) { if (dirty & /*noDeviceSessionsMessage*/ 2) div.innerHTML = /*noDeviceSessionsMessage*/ ctx[1]; }, d(detaching) { if (detaching) { detach(div); } } }; } // (41:4) {#each devicesSessions ?? [] as deviceSession} function create_each_block$a(ctx) { let devicesessionwrapper; let current; devicesessionwrapper = new DeviceSessionWrapper({ props: { deviceSession: /*deviceSession*/ ctx[7], currentDeviceLabel: /*currentDeviceLabel*/ ctx[3], loginTimeLabel: /*loginTimeLabel*/ ctx[4], signOutLabel: /*signOutLabel*/ ctx[5], onDeviceSignOut: /*onDeviceSignOut*/ ctx[6] } }); return { c() { create_component(devicesessionwrapper.$$.fragment); }, m(target, anchor) { mount_component(devicesessionwrapper, target, anchor); current = true; }, p(ctx, dirty) { const devicesessionwrapper_changes = {}; if (dirty & /*devicesSessions*/ 1) devicesessionwrapper_changes.deviceSession = /*deviceSession*/ ctx[7]; if (dirty & /*currentDeviceLabel*/ 8) devicesessionwrapper_changes.currentDeviceLabel = /*currentDeviceLabel*/ ctx[3]; if (dirty & /*loginTimeLabel*/ 16) devicesessionwrapper_changes.loginTimeLabel = /*loginTimeLabel*/ ctx[4]; if (dirty & /*signOutLabel*/ 32) devicesessionwrapper_changes.signOutLabel = /*signOutLabel*/ ctx[5]; if (dirty & /*onDeviceSignOut*/ 64) devicesessionwrapper_changes.onDeviceSignOut = /*onDeviceSignOut*/ ctx[6]; devicesessionwrapper.$set(devicesessionwrapper_changes); }, i(local) { if (current) return; transition_in(devicesessionwrapper.$$.fragment, local); current = true; }, o(local) { transition_out(devicesessionwrapper.$$.fragment, local); current = false; }, d(detaching) { destroy_component(devicesessionwrapper, detaching); } }; } function create_fragment$q(ctx) { let div1; let div0; let h1; let t0; let t1; let t2; let t3; let current; let if_block0 = /*devicesSessions*/ ctx[0] == null && create_if_block_1$f(); let if_block1 = /*devicesSessions*/ ctx[0] != null && !/*devicesSessions*/ ctx[0].length && create_if_block$k(ctx); let each_value = ensure_array_like(/*devicesSessions*/ ctx[0] ?? []); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { div1 = element("div"); div0 = element("div"); h1 = element("h1"); t0 = text(/*yourDevicesLabel*/ ctx[2]); t1 = space(); if (if_block0) if_block0.c(); t2 = space(); if (if_block1) if_block1.c(); t3 = space(); for (let i = 0; i { if_block0 = null; }); check_outros(); } if (/*devicesSessions*/ ctx[0] != null && !/*devicesSessions*/ ctx[0].length) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$k(ctx); if_block1.c(); if_block1.m(div1, t3); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (dirty & /*devicesSessions, currentDeviceLabel, loginTimeLabel, signOutLabel, onDeviceSignOut*/ 121) { each_value = ensure_array_like(/*devicesSessions*/ ctx[0] ?? []); let i; for (i = 0; i { if ('devicesSessions' in $$props) $$invalidate(0, devicesSessions = $$props.devicesSessions); if ('noDeviceSessionsMessage' in $$props) $$invalidate(1, noDeviceSessionsMessage = $$props.noDeviceSessionsMessage); if ('yourDevicesLabel' in $$props) $$invalidate(2, yourDevicesLabel = $$props.yourDevicesLabel); if ('currentDeviceLabel' in $$props) $$invalidate(3, currentDeviceLabel = $$props.currentDeviceLabel); if ('loginTimeLabel' in $$props) $$invalidate(4, loginTimeLabel = $$props.loginTimeLabel); if ('signOutLabel' in $$props) $$invalidate(5, signOutLabel = $$props.signOutLabel); if ('onDeviceSignOut' in $$props) $$invalidate(6, onDeviceSignOut = $$props.onDeviceSignOut); }; return [ devicesSessions, noDeviceSessionsMessage, yourDevicesLabel, currentDeviceLabel, loginTimeLabel, signOutLabel, onDeviceSignOut ]; } class DevicesSessionList extends SvelteComponent { constructor(options) { super(); init(this, options, instance$q, create_fragment$q, safe_not_equal, { devicesSessions: 0, noDeviceSessionsMessage: 1, yourDevicesLabel: 2, currentDeviceLabel: 3, loginTimeLabel: 4, signOutLabel: 5, onDeviceSignOut: 6 }); } } const loadDeviceSessions = async (form, formState, formActions) => { const availableDeviceSessions = await getAvailableDeviceSessions(form, formState, formActions); formActions.updateFormState({ availableDeviceSessions }); return availableDeviceSessions; }; const getAvailableDeviceSessions = (form, _, formActions) => { return request(`zephr/public/sessions/v1/sessions`, { method: "GET" }, formActions, null, true) .then(response => response.ok ? response.json() : []) .then(sessions => sessions .map(session => ({ tenantId: session['tenantId'], userId: session['userId'], id: session['id'], startDate: new Date(session['startDate']).toLocaleString(resolveLanguagePackLocale(form), { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true }), deviceName: session['deviceName'], browser: session['browser'], requestingSession: session['requestingSession'], city: session['city'] ?? null, country: session['country'] ?? null, geoState: session['geoState'] ?? null, ipAddress: session['ipAddress'] ?? null, }))); }; const signOutSingleDevice = async (form, formState, formActions, deviceId) => { const success = await signOutDevice(form, formState, formActions, deviceId); if (success) { console.log("Successfully signed out device."); return loadDeviceSessions(form, formState, formActions); } else { console.error("Failed to sign out device."); } }; const signOutDevice = async (form, formState, formActions, deviceId) => { try { const response = await request(`zephr/public/sessions/v1/sessions/${deviceId}`, { method: "DELETE" }, formActions, null, true); return response.status === 200; } catch (error) { console.error("Error occurred while signing out device:", error); return false; } }; const deviceSessionsFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.DEVICES_SESSIONS_LIST, create: (form, formState, formActions, elementConfig) => ({ component: DevicesSessionList, props: { yourDevicesLabel: elementConfig.yourDevicesLabel, noDeviceSessionsMessage: elementConfig.noDeviceSessionsMessage, devicesSessions: formState.availableDeviceSessions, currentDeviceLabel: elementConfig.currentDeviceLabel, loginTimeLabel: elementConfig.loginTimeLabel, signOutLabel: elementConfig.signOutLabel, onDeviceSignOut: (value) => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); logDataLayerEvent(form, 'zephr_form_device_logout', { deviceId: value }); void signOutSingleDevice(form, formState, formActions, value); } } }) }; /* src/components/elements/devices/DeviceSessionsSignOutAllWrapper.svelte generated by Svelte v4.2.12 */ function create_if_block$j(ctx) { let div; let t; let mounted; let dispose; return { c() { div = element("div"); t = text(/*text*/ ctx[2]); attr(div, "class", "sign-out-all svelte-1ogdv39"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); if (!mounted) { dispose = listen(div, "click", function () { if (is_function(/*onSignOutAllDevices*/ ctx[0])) /*onSignOutAllDevices*/ ctx[0].apply(this, arguments); }); mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*text*/ 4) set_data(t, /*text*/ ctx[2]); }, d(detaching) { if (detaching) { detach(div); } mounted = false; dispose(); } }; } function create_fragment$p(ctx) { let if_block_anchor; let if_block = !/*hidden*/ ctx[1] && create_if_block$j(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, [dirty]) { if (!/*hidden*/ ctx[1]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$j(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$p($$self, $$props, $$invalidate) { let { onSignOutAllDevices } = $$props; let { hidden } = $$props; let { text } = $$props; $$self.$$set = $$props => { if ('onSignOutAllDevices' in $$props) $$invalidate(0, onSignOutAllDevices = $$props.onSignOutAllDevices); if ('hidden' in $$props) $$invalidate(1, hidden = $$props.hidden); if ('text' in $$props) $$invalidate(2, text = $$props.text); }; return [onSignOutAllDevices, hidden, text]; } class DeviceSessionsSignOutAllWrapper extends SvelteComponent { constructor(options) { super(); init(this, options, instance$p, create_fragment$p, safe_not_equal, { onSignOutAllDevices: 0, hidden: 1, text: 2 }); } } const signOutOfAllDevices = async (form, formState, formActions) => { const success = await signOutDevices(form, formState, formActions); if (success) { console.log("Successfully signed out of all devices."); return loadDeviceSessions(form, formState, formActions); } else { console.error("Failed to sign out of all devices."); } }; const signOutDevices = async (form, _, formActions) => { try { const response = await request(`zephr/public/sessions/v1/sessions?except-current`, { method: "DELETE" }, formActions, null, true); return response.status === 200; } catch (error) { console.error("Error occurred while signing out devices:", error); return false; } }; const deviceSessionsSignOutAll = { matches: (sectionElement) => sectionElement.type === elementTypes.SIGN_OUT_ALL_OTHER_DEVICES, create: (form, formState, formActions, elementConfig) => ({ component: DeviceSessionsSignOutAllWrapper, props: { hidden: formState.availableDeviceSessions?.length { logDataLayerEvent(form, 'zephr_form_sign_out_all_devices', null); void signOutOfAllDevices(form, formState, formActions); } } }) }; /* src/components/elements/billingHistory/BillingHistory.svelte generated by Svelte v4.2.12 */ function get_each_context$9(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[5] = list[i]; return child_ctx; } // (30:10) {#if e.subtotal} function create_if_block_1$e(ctx) { let t0_value = /*e*/ ctx[5].currency + ""; let t0; let t1; let t2_value = /*e*/ ctx[5].subtotal + ""; let t2; let t3; let if_block_anchor; let if_block = /*e*/ ctx[5].taxes && create_if_block_2$9(ctx); return { c() { t0 = text(t0_value); t1 = space(); t2 = text(t2_value); t3 = space(); if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { insert(target, t0, anchor); insert(target, t1, anchor); insert(target, t2, anchor); insert(target, t3, anchor); if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); }, p(ctx, dirty) { if (dirty & /*historyItems*/ 1 && t0_value !== (t0_value = /*e*/ ctx[5].currency + "")) set_data(t0, t0_value); if (dirty & /*historyItems*/ 1 && t2_value !== (t2_value = /*e*/ ctx[5].subtotal + "")) set_data(t2, t2_value); if (/*e*/ ctx[5].taxes) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_2$9(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, d(detaching) { if (detaching) { detach(t0); detach(t1); detach(t2); detach(t3); detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (32:12) {#if e.taxes} function create_if_block_2$9(ctx) { let span; let t_value = ` ${/*e*/ ctx[5].taxes}` + ""; let t; return { c() { span = element("span"); t = text(t_value); attr(span, "class", "taxes svelte-7sscau"); }, m(target, anchor) { insert(target, span, anchor); append(span, t); }, p(ctx, dirty) { if (dirty & /*historyItems*/ 1 && t_value !== (t_value = ` ${/*e*/ ctx[5].taxes}` + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(span); } } }; } // (38:10) {#if e.total} function create_if_block$i(ctx) { let t0_value = /*e*/ ctx[5].currency + ""; let t0; let t1; let t2_value = /*e*/ ctx[5].total + ""; let t2; return { c() { t0 = text(t0_value); t1 = space(); t2 = text(t2_value); }, m(target, anchor) { insert(target, t0, anchor); insert(target, t1, anchor); insert(target, t2, anchor); }, p(ctx, dirty) { if (dirty & /*historyItems*/ 1 && t0_value !== (t0_value = /*e*/ ctx[5].currency + "")) set_data(t0, t0_value); if (dirty & /*historyItems*/ 1 && t2_value !== (t2_value = /*e*/ ctx[5].total + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(t0); detach(t1); detach(t2); } } }; } // (25:4) {#each historyItems ?? [] as e} function create_each_block$9(ctx) { let div4; let div0; let t0_value = /*e*/ ctx[5].date + ""; let t0; let t1; let div1; let t2_value = /*e*/ ctx[5].period + ""; let t2; let t3; let div2; let t4; let div3; let t5; let if_block0 = /*e*/ ctx[5].subtotal && create_if_block_1$e(ctx); let if_block1 = /*e*/ ctx[5].total && create_if_block$i(ctx); return { c() { div4 = element("div"); div0 = element("div"); t0 = text(t0_value); t1 = space(); div1 = element("div"); t2 = text(t2_value); t3 = space(); div2 = element("div"); if (if_block0) if_block0.c(); t4 = space(); div3 = element("div"); if (if_block1) if_block1.c(); t5 = space(); attr(div0, "class", "svelte-7sscau"); attr(div1, "class", "svelte-7sscau"); attr(div2, "class", "svelte-7sscau"); attr(div3, "class", "svelte-7sscau"); attr(div4, "class", "table-row svelte-7sscau"); }, m(target, anchor) { insert(target, div4, anchor); append(div4, div0); append(div0, t0); append(div4, t1); append(div4, div1); append(div1, t2); append(div4, t3); append(div4, div2); if (if_block0) if_block0.m(div2, null); append(div4, t4); append(div4, div3); if (if_block1) if_block1.m(div3, null); append(div4, t5); }, p(ctx, dirty) { if (dirty & /*historyItems*/ 1 && t0_value !== (t0_value = /*e*/ ctx[5].date + "")) set_data(t0, t0_value); if (dirty & /*historyItems*/ 1 && t2_value !== (t2_value = /*e*/ ctx[5].period + "")) set_data(t2, t2_value); if (/*e*/ ctx[5].subtotal) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$e(ctx); if_block0.c(); if_block0.m(div2, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*e*/ ctx[5].total) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$i(ctx); if_block1.c(); if_block1.m(div3, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, d(detaching) { if (detaching) { detach(div4); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); } }; } function create_fragment$o(ctx) { let div6; let div5; let div4; let div0; let t0; let t1; let div1; let t2; let t3; let div2; let t4; let t5; let div3; let t6; let t7; let each_value = ensure_array_like(/*historyItems*/ ctx[0] ?? []); let each_blocks = []; for (let i = 0; i { if ('historyItems' in $$props) $$invalidate(0, historyItems = $$props.historyItems); if ('dateLabel' in $$props) $$invalidate(1, dateLabel = $$props.dateLabel); if ('periodLabel' in $$props) $$invalidate(2, periodLabel = $$props.periodLabel); if ('subtotalLabel' in $$props) $$invalidate(3, subtotalLabel = $$props.subtotalLabel); if ('totalLabel' in $$props) $$invalidate(4, totalLabel = $$props.totalLabel); }; return [historyItems, dateLabel, periodLabel, subtotalLabel, totalLabel]; } class BillingHistory extends SvelteComponent { constructor(options) { super(); init(this, options, instance$o, create_fragment$o, safe_not_equal, { historyItems: 0, dateLabel: 1, periodLabel: 2, subtotalLabel: 3, totalLabel: 4 }); } } const billingHistoryFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.BILLING_HISTORY, create: (form, formState, __) => ({ component: BillingHistory, props: { historyItems: formState.selectedSubscription?.transactionHistory, dateLabel: resolveLanguagePackKeyTyped(form, 'forms.billing.history.date', 'Date'), periodLabel: resolveLanguagePackKeyTyped(form, 'forms.billing.history.period', 'Period'), subtotalLabel: resolveLanguagePackKeyTyped(form, 'forms.billing.history.subtotal', 'Subtotal'), totalLabel: resolveLanguagePackKeyTyped(form, 'forms.billing.history.total', 'Total'), } }) }; /* src/components/elements/buttonGroup/ButtonGroup.svelte generated by Svelte v4.2.12 */ function create_if_block$h(ctx) { let button; let t; let mounted; let dispose; return { c() { button = element("button"); t = text(/*backText*/ ctx[1]); attr(button, "class", "zephr-form-back-button svelte-5uv9ua"); attr(button, "type", "submit"); }, m(target, anchor) { insert(target, button, anchor); append(button, t); if (!mounted) { dispose = listen(button, "click", prevent_default(function () { if (is_function(/*onBack*/ ctx[3])) /*onBack*/ ctx[3].apply(this, arguments); })); mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*backText*/ 2) set_data(t, /*backText*/ ctx[1]); }, d(detaching) { if (detaching) { detach(button); } mounted = false; dispose(); } }; } function create_fragment$n(ctx) { let div; let t0; let button; let t1; let mounted; let dispose; let if_block = /*backEnabled*/ ctx[2] && create_if_block$h(ctx); return { c() { div = element("div"); if (if_block) if_block.c(); t0 = space(); button = element("button"); t1 = text(/*continueText*/ ctx[0]); attr(button, "class", "zephr-form-continue-button svelte-5uv9ua"); attr(button, "type", "submit"); attr(div, "class", "zephr-form-button-group zephr-form-max-width svelte-5uv9ua"); }, m(target, anchor) { insert(target, div, anchor); if (if_block) if_block.m(div, null); append(div, t0); append(div, button); append(button, t1); if (!mounted) { dispose = listen(button, "click", prevent_default(function () { if (is_function(/*onClick*/ ctx[4])) /*onClick*/ ctx[4].apply(this, arguments); })); mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if (/*backEnabled*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$h(ctx); if_block.c(); if_block.m(div, t0); } } else if (if_block) { if_block.d(1); if_block = null; } if (dirty & /*continueText*/ 1) set_data(t1, /*continueText*/ ctx[0]); }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } if (if_block) if_block.d(); mounted = false; dispose(); } }; } function instance$n($$self, $$props, $$invalidate) { let { continueText } = $$props; let { backText } = $$props; let { backEnabled } = $$props; let { onBack } = $$props; let { onClick } = $$props; $$self.$$set = $$props => { if ('continueText' in $$props) $$invalidate(0, continueText = $$props.continueText); if ('backText' in $$props) $$invalidate(1, backText = $$props.backText); if ('backEnabled' in $$props) $$invalidate(2, backEnabled = $$props.backEnabled); if ('onBack' in $$props) $$invalidate(3, onBack = $$props.onBack); if ('onClick' in $$props) $$invalidate(4, onClick = $$props.onClick); }; return [continueText, backText, backEnabled, onBack, onClick]; } class ButtonGroup extends SvelteComponent { constructor(options) { super(); init(this, options, instance$n, create_fragment$n, safe_not_equal, { continueText: 0, backText: 1, backEnabled: 2, onBack: 3, onClick: 4 }); } } const factory$6 = { matches: (sectionElement) => sectionElement.type === elementTypes.BUTTON_GROUP, create: (form, formState, formActions, elementConfig) => ({ component: ButtonGroup, props: { continueText: elementConfig.continueText, backText: elementConfig.backText, backEnabled: elementConfig.backEnabled, onClick: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'CONTINUE' }); if (elementConfig.isCancel) { formActions.updateFormState({ confirmCancel: true, }); } formActions.updateFormState({ isExternalReferrer: false, }); formActions.attemptCompleteSection(); }, onBack: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'BACK' }); if (elementConfig.backToURL) { window.location.pathname = elementConfig.backURL; } else if (formState.isExternalReferrer) { window.history.back(); } else { formActions.onEvent(elementConfig.event); } } } }) }; /* src/components/elements/linkButton/LinkButton.svelte generated by Svelte v4.2.12 */ function create_fragment$m(ctx) { let a; let t; let mounted; let dispose; return { c() { a = element("a"); t = text(/*text*/ ctx[0]); attr(a, "class", "zephr-form-button zephr-form-button-top-margin svelte-1uaz0r"); attr(a, "href", /*href*/ ctx[1]); }, m(target, anchor) { insert(target, a, anchor); append(a, t); if (!mounted) { dispose = listen(a, "click", function () { if (is_function(/*onClick*/ ctx[2])) /*onClick*/ ctx[2].apply(this, arguments); }); mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if (dirty & /*text*/ 1) set_data(t, /*text*/ ctx[0]); if (dirty & /*href*/ 2) { attr(a, "href", /*href*/ ctx[1]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(a); } mounted = false; dispose(); } }; } function instance$m($$self, $$props, $$invalidate) { let { text } = $$props; let { href } = $$props; let { onClick = () => { } } = $$props; $$self.$$set = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('href' in $$props) $$invalidate(1, href = $$props.href); if ('onClick' in $$props) $$invalidate(2, onClick = $$props.onClick); }; return [text, href, onClick]; } class LinkButton extends SvelteComponent { constructor(options) { super(); init(this, options, instance$m, create_fragment$m, safe_not_equal, { text: 0, href: 1, onClick: 2 }); } } const factory$5 = { matches: (sectionElement) => sectionElement.type === elementTypes.LINK_BUTTON, create: (form, formState, formActions, elementConfig) => ({ component: LinkButton, props: { text: elementConfig.text, href: elementConfig.href, onClick: () => { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'LINK_BUTTON' }); }, }, }) }; /* src/components/elements/recipientName/RecipientName.svelte generated by Svelte v4.2.12 */ function create_if_block_1$d(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*firstNameError*/ ctx[3]); attr(div, "class", "error-text svelte-hvl7z2"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*firstNameError*/ 8) set_data(t, /*firstNameError*/ ctx[3]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (71:4) {#if lastNameError} function create_if_block$g(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*lastNameError*/ ctx[4]); attr(div, "class", "error-text svelte-hvl7z2"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*lastNameError*/ 16) set_data(t, /*lastNameError*/ ctx[4]); }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$l(ctx) { let div2; let div0; let label0; let t0_value = /*config*/ ctx[0].firstNameLabel + ""; let t0; let t1; let input0; let input0_placeholder_value; let t2; let t3; let div1; let label1; let t4_value = /*config*/ ctx[0].lastNameLabel + ""; let t4; let t5; let input1; let input1_placeholder_value; let t6; let mounted; let dispose; let if_block0 = /*firstNameError*/ ctx[3] && create_if_block_1$d(ctx); let if_block1 = /*lastNameError*/ ctx[4] && create_if_block$g(ctx); return { c() { div2 = element("div"); div0 = element("div"); label0 = element("label"); t0 = text(t0_value); t1 = space(); input0 = element("input"); t2 = space(); if (if_block0) if_block0.c(); t3 = space(); div1 = element("div"); label1 = element("label"); t4 = text(t4_value); t5 = space(); input1 = element("input"); t6 = space(); if (if_block1) if_block1.c(); attr(label0, "for", "firstName"); attr(label0, "class", "svelte-hvl7z2"); attr(input0, "id", "firstName"); attr(input0, "type", "text"); input0.required = true; attr(input0, "placeholder", input0_placeholder_value = /*config*/ ctx[0].firstNamePlaceholder); attr(input0, "class", "svelte-hvl7z2"); toggle_class(input0, "error", !!/*firstNameError*/ ctx[3]); attr(div0, "class", "field svelte-hvl7z2"); attr(label1, "for", "lastName"); attr(label1, "class", "svelte-hvl7z2"); attr(input1, "id", "lastName"); attr(input1, "type", "text"); input1.required = true; attr(input1, "placeholder", input1_placeholder_value = /*config*/ ctx[0].lastNamePlaceholder); attr(input1, "class", "svelte-hvl7z2"); toggle_class(input1, "error", !!/*lastNameError*/ ctx[4]); attr(div1, "class", "field svelte-hvl7z2"); attr(div2, "class", "recipient-name-section svelte-hvl7z2"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div0); append(div0, label0); append(label0, t0); append(div0, t1); append(div0, input0); set_input_value(input0, /*firstName*/ ctx[1]); append(div0, t2); if (if_block0) if_block0.m(div0, null); append(div2, t3); append(div2, div1); append(div1, label1); append(label1, t4); append(div1, t5); append(div1, input1); set_input_value(input1, /*lastName*/ ctx[2]); append(div1, t6); if (if_block1) if_block1.m(div1, null); if (!mounted) { dispose = [ listen(input0, "input", /*input0_input_handler*/ ctx[8]), listen(input0, "input", /*updateGiftRecipient*/ ctx[5]), listen(input1, "input", /*input1_input_handler*/ ctx[9]), listen(input1, "input", /*updateGiftRecipient*/ ctx[5]) ]; mounted = true; } }, p(ctx, [dirty]) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].firstNameLabel + "")) set_data(t0, t0_value); if (dirty & /*config*/ 1 && input0_placeholder_value !== (input0_placeholder_value = /*config*/ ctx[0].firstNamePlaceholder)) { attr(input0, "placeholder", input0_placeholder_value); } if (dirty & /*firstName*/ 2 && input0.value !== /*firstName*/ ctx[1]) { set_input_value(input0, /*firstName*/ ctx[1]); } if (dirty & /*firstNameError*/ 8) { toggle_class(input0, "error", !!/*firstNameError*/ ctx[3]); } if (/*firstNameError*/ ctx[3]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$d(ctx); if_block0.c(); if_block0.m(div0, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (dirty & /*config*/ 1 && t4_value !== (t4_value = /*config*/ ctx[0].lastNameLabel + "")) set_data(t4, t4_value); if (dirty & /*config*/ 1 && input1_placeholder_value !== (input1_placeholder_value = /*config*/ ctx[0].lastNamePlaceholder)) { attr(input1, "placeholder", input1_placeholder_value); } if (dirty & /*lastName*/ 4 && input1.value !== /*lastName*/ ctx[2]) { set_input_value(input1, /*lastName*/ ctx[2]); } if (dirty & /*lastNameError*/ 16) { toggle_class(input1, "error", !!/*lastNameError*/ ctx[4]); } if (/*lastNameError*/ ctx[4]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$g(ctx); if_block1.c(); if_block1.m(div1, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div2); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); mounted = false; run_all(dispose); } }; } function instance$l($$self, $$props, $$invalidate) { let { formState } = $$props; let { formActions } = $$props; let { config } = $$props; const dispatch = createEventDispatcher(); let firstName = formState.giftRecipient?.firstName || ''; let lastName = formState.giftRecipient?.lastName || ''; let firstNameError = ''; let lastNameError = ''; // Update form state when input changes const updateGiftRecipient = () => { const updatedGiftRecipient = { ...formState.giftRecipient || {}, firstName, lastName }; formActions.updateFormState({ giftRecipient: updatedGiftRecipient }); validateForm(); }; const validateForm = () => { const hasValidFirstName = !!firstName.trim(); const hasValidLastName = !!lastName.trim(); if (!hasValidFirstName) { $$invalidate(3, firstNameError = 'First name is required'); } else { $$invalidate(3, firstNameError = ''); } if (!hasValidLastName) { $$invalidate(4, lastNameError = 'Last name is required'); } else { $$invalidate(4, lastNameError = ''); } // Dispatch event for form validity dispatch('validity', { isValid: hasValidFirstName && hasValidLastName }); }; function input0_input_handler() { firstName = this.value; $$invalidate(1, firstName); } function input1_input_handler() { lastName = this.value; $$invalidate(2, lastName); } $$self.$$set = $$props => { if ('formState' in $$props) $$invalidate(6, formState = $$props.formState); if ('formActions' in $$props) $$invalidate(7, formActions = $$props.formActions); if ('config' in $$props) $$invalidate(0, config = $$props.config); }; return [ config, firstName, lastName, firstNameError, lastNameError, updateGiftRecipient, formState, formActions, input0_input_handler, input1_input_handler ]; } class RecipientName extends SvelteComponent { constructor(options) { super(); init(this, options, instance$l, create_fragment$l, safe_not_equal, { formState: 6, formActions: 7, config: 0 }); } } const recipientNameFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.RECIPIENT_NAME, create: (form, formState, formActions, elementConfig) => { // Resolve all labels through language pack service const resolvedConfig = { firstNameLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.recipient-first-name', elementConfig.firstNameLabel), lastNameLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.recipient-last-name', elementConfig.lastNameLabel), firstNamePlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.first-name-placeholder', elementConfig.firstNamePlaceholder), lastNamePlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.last-name-placeholder', elementConfig.lastNamePlaceholder), }; // Determine if the input is valid const giftRecipient = (formState.giftRecipient || {}); const hasValidFirstName = !!giftRecipient.firstName?.trim(); const hasValidLastName = !!giftRecipient.lastName?.trim(); const isValid = hasValidFirstName && hasValidLastName; return { component: RecipientName, props: { config: resolvedConfig, form, formState, formActions, }, isValid }; } }; /* src/components/elements/recipientEmail/RecipientEmail.svelte generated by Svelte v4.2.12 */ function create_if_block$f(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*emailError*/ ctx[2]); attr(div, "class", "error-text svelte-1odylgp"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*emailError*/ 4) set_data(t, /*emailError*/ ctx[2]); }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$k(ctx) { let div1; let div0; let label; let t0_value = /*config*/ ctx[0].emailLabel + ""; let t0; let t1; let input; let input_placeholder_value; let t2; let mounted; let dispose; let if_block = /*emailError*/ ctx[2] && create_if_block$f(ctx); return { c() { div1 = element("div"); div0 = element("div"); label = element("label"); t0 = text(t0_value); t1 = space(); input = element("input"); t2 = space(); if (if_block) if_block.c(); attr(label, "for", "recipientEmail"); attr(label, "class", "svelte-1odylgp"); attr(input, "id", "recipientEmail"); attr(input, "type", "email"); input.required = true; attr(input, "placeholder", input_placeholder_value = /*config*/ ctx[0].emailPlaceholder); attr(input, "class", "svelte-1odylgp"); toggle_class(input, "error", !!/*emailError*/ ctx[2]); attr(div0, "class", "field svelte-1odylgp"); attr(div1, "class", "recipient-email-section svelte-1odylgp"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, div0); append(div0, label); append(label, t0); append(div0, t1); append(div0, input); set_input_value(input, /*recipientEmail*/ ctx[1]); append(div0, t2); if (if_block) if_block.m(div0, null); if (!mounted) { dispose = [ listen(input, "input", /*input_input_handler*/ ctx[7]), listen(input, "input", /*updateGiftRecipient*/ ctx[3]) ]; mounted = true; } }, p(ctx, [dirty]) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].emailLabel + "")) set_data(t0, t0_value); if (dirty & /*config*/ 1 && input_placeholder_value !== (input_placeholder_value = /*config*/ ctx[0].emailPlaceholder)) { attr(input, "placeholder", input_placeholder_value); } if (dirty & /*recipientEmail*/ 2 && input.value !== /*recipientEmail*/ ctx[1]) { set_input_value(input, /*recipientEmail*/ ctx[1]); } if (dirty & /*emailError*/ 4) { toggle_class(input, "error", !!/*emailError*/ ctx[2]); } if (/*emailError*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$f(ctx); if_block.c(); if_block.m(div0, null); } } else if (if_block) { if_block.d(1); if_block = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div1); } if (if_block) if_block.d(); mounted = false; run_all(dispose); } }; } function instance$k($$self, $$props, $$invalidate) { let { formState } = $$props; let { formActions } = $$props; let { config } = $$props; let { form } = $$props; const dispatch = createEventDispatcher(); let recipientEmail = formState.giftRecipient?.email || ''; let emailError = ''; // Update form state when input changes const updateGiftRecipient = () => { const updatedGiftRecipient = { ...formState.giftRecipient || {}, email: recipientEmail }; formActions.updateFormState({ giftRecipient: updatedGiftRecipient }); validateForm(); }; const validateForm = () => { const hasValidEmail = isValidEmail(recipientEmail); if (recipientEmail && !hasValidEmail) { $$invalidate(2, emailError = resolveLanguagePackKeyTyped(form, 'forms.errors.email-invalid', 'Please enter a valid email address')); } else if (!recipientEmail) { $$invalidate(2, emailError = 'Recipient email is required'); } else { $$invalidate(2, emailError = ''); } // Dispatch event for form validity dispatch('validity', { isValid: hasValidEmail }); }; function input_input_handler() { recipientEmail = this.value; $$invalidate(1, recipientEmail); } $$self.$$set = $$props => { if ('formState' in $$props) $$invalidate(4, formState = $$props.formState); if ('formActions' in $$props) $$invalidate(5, formActions = $$props.formActions); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('form' in $$props) $$invalidate(6, form = $$props.form); }; return [ config, recipientEmail, emailError, updateGiftRecipient, formState, formActions, form, input_input_handler ]; } class RecipientEmail extends SvelteComponent { constructor(options) { super(); init(this, options, instance$k, create_fragment$k, safe_not_equal, { formState: 4, formActions: 5, config: 0, form: 6 }); } } const recipientEmailFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.RECIPIENT_EMAIL, create: (form, formState, formActions, elementConfig) => { // Resolve all labels through language pack service const resolvedConfig = { emailLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.recipient-email', elementConfig.emailLabel), emailPlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.email-placeholder', elementConfig.emailPlaceholder), }; // Determine if the input is valid const giftRecipient = (formState.giftRecipient || {}); const hasValidEmail = isValidEmail(giftRecipient.email); const isValid = hasValidEmail; return { component: RecipientEmail, props: { config: resolvedConfig, form, formState, formActions, }, isValid }; } }; const countries = { AF: "Afghanistan", AL: "Albania", DZ: "Algeria", AX: "Åland Islands", AS: "American Samoa", AD: "Andorra", AO: "Angola", AI: "Anguilla", AQ: "Antarctica", AG: "Antigua and Barbuda", AR: "Argentina", AM: "Armenia", AW: "Aruba", AU: "Australia", AT: "Austria", AZ: "Azerbaijan", BS: "Bahamas (the)", BH: "Bahrain", BD: "Bangladesh", BB: "Barbados", BY: "Belarus", BE: "Belgium", BZ: "Belize", BJ: "Benin", BM: "Bermuda", BT: "Bhutan", BO: "Bolivia (Plurinational State of)", BQ: "Bonaire, Sint Eustatius and Saba", BA: "Bosnia and Herzegovina", BW: "Botswana", BV: "Bouvet Island", BR: "Brazil", IO: "British Indian Ocean Territory (the)", BN: "Brunei Darussalam", BG: "Bulgaria", BF: "Burkina Faso", BI: "Burundi", CV: "Cabo Verde", KH: "Cambodia", CM: "Cameroon", CA: "Canada", KY: "Cayman Islands (the)", CF: "Central African Republic (the)", TD: "Chad", CL: "Chile", CN: "China", CX: "Christmas Island", CC: "Cocos (Keeling) Islands (the)", CO: "Colombia", KM: "Comoros (the)", CD: "Congo (the Democratic Republic of the)", CG: "Congo (the)", CK: "Cook Islands (the)", CR: "Costa Rica", CI: "Côte d'Ivoire", HR: "Croatia", CU: "Cuba", CW: "Curaçao", CY: "Cyprus", CZ: "Czechia", DK: "Denmark", DJ: "Djibouti", DM: "Dominica", DO: "Dominican Republic (the)", EC: "Ecuador", EG: "Egypt", SV: "El Salvador", GQ: "Equatorial Guinea", ER: "Eritrea", EE: "Estonia", SZ: "Eswatini", ET: "Ethiopia", FK: "Falkland Islands (the) [Malvinas]", FO: "Faroe Islands (the)", FJ: "Fiji", FI: "Finland", FR: "France", GF: "French Guiana", PF: "French Polynesia", TF: "French Southern Territories (the)", GA: "Gabon", GM: "Gambia (the)", GE: "Georgia", DE: "Germany", GH: "Ghana", GI: "Gibraltar", GR: "Greece", GL: "Greenland", GD: "Grenada", GP: "Guadeloupe", GU: "Guam", GT: "Guatemala", GG: "Guernsey", GN: "Guinea", GW: "Guinea-Bissau", GY: "Guyana", HT: "Haiti", HM: "Heard Island and McDonald Islands", VA: "Holy See (the)", HN: "Honduras", HK: "Hong Kong", HU: "Hungary", IS: "Iceland", IN: "India", ID: "Indonesia", IR: "Iran (Islamic Republic of)", IQ: "Iraq", IE: "Ireland", IM: "Isle of Man", IL: "Israel", IT: "Italy", JM: "Jamaica", JP: "Japan", JE: "Jersey", JO: "Jordan", KZ: "Kazakhstan", KE: "Kenya", KI: "Kiribati", KP: "Korea (the Democratic People's Republic of)", KR: "Korea (the Republic of)", KW: "Kuwait", KG: "Kyrgyzstan", LA: "Lao People's Democratic Republic (the)", LV: "Latvia", LB: "Lebanon", LS: "Lesotho", LR: "Liberia", LY: "Libya", LI: "Liechtenstein", LT: "Lithuania", LU: "Luxembourg", MO: "Macao", MG: "Madagascar", MW: "Malawi", MY: "Malaysia", MV: "Maldives", ML: "Mali", MT: "Malta", MH: "Marshall Islands (the)", MQ: "Martinique", MR: "Mauritania", MU: "Mauritius", YT: "Mayotte", MX: "Mexico", FM: "Micronesia (Federated States of)", MD: "Moldova (the Republic of)", MC: "Monaco", MN: "Mongolia", ME: "Montenegro", MS: "Montserrat", MA: "Morocco", MZ: "Mozambique", MM: "Myanmar", NA: "Namibia", NR: "Nauru", NP: "Nepal", NL: "Netherlands (the)", NC: "New Caledonia", NZ: "New Zealand", NI: "Nicaragua", NE: "Niger (the)", NG: "Nigeria", NU: "Niue", NF: "Norfolk Island", MK: "North Macedonia", MP: "Northern Mariana Islands (the)", NO: "Norway", OM: "Oman", PK: "Pakistan", PW: "Palau", PS: "Palestine, State of", PA: "Panama", PG: "Papua New Guinea", PY: "Paraguay", PE: "Peru", PH: "Philippines (the)", PN: "Pitcairn", PL: "Poland", PT: "Portugal", PR: "Puerto Rico", QA: "Qatar", RE: "Réunion", RO: "Romania", RU: "Russian Federation (the)", RW: "Rwanda", BL: "Saint Barthélemy", SH: "Saint Helena, Ascension and Tristan da Cunha", KN: "Saint Kitts and Nevis", LC: "Saint Lucia", MF: "Saint Martin (French part)", PM: "Saint Pierre and Miquelon", VC: "Saint Vincent and the Grenadines", WS: "Samoa", SM: "San Marino", ST: "Sao Tome and Principe", SA: "Saudi Arabia", SN: "Senegal", RS: "Serbia", SC: "Seychelles", SL: "Sierra Leone", SG: "Singapore", SX: "Sint Maarten (Dutch part)", SK: "Slovakia", SI: "Slovenia", SB: "Solomon Islands", SO: "Somalia", ZA: "South Africa", GS: "South Georgia and the South Sandwich Islands", SS: "South Sudan", ES: "Spain", LK: "Sri Lanka", SD: "Sudan (the)", SR: "Suriname", SJ: "Svalbard and Jan Mayen", SE: "Sweden", CH: "Switzerland", SY: "Syrian Arab Republic", TW: "Taiwan (Province of China)", TJ: "Tajikistan", TZ: "Tanzania, United Republic of", TH: "Thailand", TL: "Timor-Leste", TG: "Togo", TK: "Tokelau", TO: "Tonga", TT: "Trinidad and Tobago", TN: "Tunisia", TR: "Turkey", TM: "Turkmenistan", TC: "Turks and Caicos Islands (the)", TV: "Tuvalu", UG: "Uganda", UA: "Ukraine", AE: "United Arab Emirates (the)", GB: "United Kingdom of Great Britain and Northern Ireland (the)", US: "United States of America (the)", UM: "United States Minor Outlying Islands (the)", UY: "Uruguay", UZ: "Uzbekistan", VU: "Vanuatu", VE: "Venezuela (Bolivarian Republic of)", VN: "Viet Nam", VG: "Virgin Islands (British)", VI: "Virgin Islands (U.S.)", WF: "Wallis and Futuna", EH: "Western Sahara", YE: "Yemen", ZM: "Zambia", ZW: "Zimbabwe", }; const statesForUS = { AK: "Alaska", AL: "Alabama", AR: "Arkansas", AZ: "Arizona", CA: "California", CO: "Colorado", CT: "Connecticut", DC: "District of Columbia", DE: "Delaware", FL: "Florida", GA: "Georgia", GU: "Guam", HI: "Hawaii", IA: "Iowa", ID: "Idaho", IL: "Illinois", IN: "Indiana", KS: "Kansas", KY: "Kentucky", LA: "Louisiana", MA: "Massachusetts", MD: "Maryland", ME: "Maine", MI: "Michigan", MN: "Minnesota", MO: "Missouri", MS: "Mississippi", MT: "Montana", NC: "North Carolina", ND: "North Dakota", NE: "Nebraska", NH: "New Hampshire", NJ: "New Jersey", NM: "New Mexico", NV: "Nevada", NY: "New York", OH: "Ohio", OK: "Oklahoma", OR: "Oregon", PA: "Pennsylvania", PR: "Puerto Rico", RI: "Rhode Island", SC: "South Carolina", SD: "South Dakota", TN: "Tennessee", TX: "Texas", UT: "Utah", VA: "Virginia", VI: "Virgin Islands", VT: "Vermont", WA: "Washington", WI: "Wisconsin", WV: "West Virginia", WY: "Wyoming" }; const provincesForCanada = { AB: "Alberta", BC: "British Columbia", MB: "Manitoba", NB: "New Brunswick", NL: "Newfoundland and Labrador", NT: "Northwest Territories", NS: "Nova Scotia", NU: "Nunavut", ON: "Ontario", PE: "Prince Edward Island", QC: "Quebec", SK: "Saskatchewan", YT: "Yukon" }; /* src/components/elements/billingCountry/BillingCountry.svelte generated by Svelte v4.2.12 */ function get_each_context$8(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[14] = list[i]; return child_ctx; } // (55:4) {#each countryOptions as option} function create_each_block$8(ctx) { let option_1; let t0_value = /*option*/ ctx[14].label + ""; let t0; let t1; let option_1_value_value; let option_1_selected_value; return { c() { option_1 = element("option"); t0 = text(t0_value); t1 = space(); option_1.__value = option_1_value_value = /*option*/ ctx[14].value; set_input_value(option_1, option_1.__value); option_1.selected = option_1_selected_value = /*value*/ ctx[1] === /*option*/ ctx[14].value; }, m(target, anchor) { insert(target, option_1, anchor); append(option_1, t0); append(option_1, t1); }, p(ctx, dirty) { if (dirty & /*countryOptions*/ 64 && t0_value !== (t0_value = /*option*/ ctx[14].label + "")) set_data(t0, t0_value); if (dirty & /*countryOptions*/ 64 && option_1_value_value !== (option_1_value_value = /*option*/ ctx[14].value)) { option_1.__value = option_1_value_value; set_input_value(option_1, option_1.__value); } if (dirty & /*value, countryOptions*/ 66 && option_1_selected_value !== (option_1_selected_value = /*value*/ ctx[1] === /*option*/ ctx[14].value)) { option_1.selected = option_1_selected_value; } }, d(detaching) { if (detaching) { detach(option_1); } } }; } // (34:0) function create_default_slot$3(ctx) { let select; let option_1; let t; let select_required_value; let select_value_value; let select_disabled_value; let mounted; let dispose; let each_value = ensure_array_like(/*countryOptions*/ ctx[6]); let each_blocks = []; for (let i = 0; i { const target = e.target; onChange(target.value); }; // Trigger onChange when component mounts with a default value // This ensures validation is registered properly onMount(() => { if (value && value !== "") { onChange(value); } }); $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(12, formKey = $$props.formKey); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('value' in $$props) $$invalidate(1, value = $$props.value); if ('error' in $$props) $$invalidate(2, error = $$props.error); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); if ('onChange' in $$props) $$invalidate(13, onChange = $$props.onChange); if ('onFocus' in $$props) $$invalidate(4, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(5, onBlur = $$props.onBlur); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*error*/ 4) { $$invalidate(9, hasError = !!error); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(8, label = config.label || "Country"); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(7, placeholder = config.placeholder || "Select your country"); } }; $$invalidate(6, countryOptions = Object.entries(countries).map(([code, name]) => ({ value: code, label: name }))); return [ config, value, error, isPaymentForm, onFocus, onBlur, countryOptions, placeholder, label, hasError, id, handleChange, formKey, onChange ]; } class BillingCountry extends SvelteComponent { constructor(options) { super(); init(this, options, instance$j, create_fragment$j, safe_not_equal, { formKey: 12, config: 0, value: 1, error: 2, isPaymentForm: 3, onChange: 13, onFocus: 4, onBlur: 5 }); } } /* src/components/elements/billingState/BillingState.svelte generated by Svelte v4.2.12 */ function get_each_context$7(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[16] = list[i]; return child_ctx; } // (44:0) {#if shouldShow} function create_if_block$d(ctx) { let label_1; let t; let if_block_anchor; let current; label_1 = new Label({ props: { forInput: /*id*/ ctx[11], label: /*label*/ ctx[9] + (/*config*/ ctx[0].required ? "*" : ""), isPaymentForm: /*isPaymentForm*/ ctx[3], $$slots: { default: [create_default_slot$2] }, $$scope: { ctx } } }); let if_block = /*hasError*/ ctx[10] && create_if_block_1$c(ctx); return { c() { create_component(label_1.$$.fragment); t = space(); if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { mount_component(label_1, target, anchor); insert(target, t, anchor); if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { const label_1_changes = {}; if (dirty & /*label, config*/ 513) label_1_changes.label = /*label*/ ctx[9] + (/*config*/ ctx[0].required ? "*" : ""); if (dirty & /*isPaymentForm*/ 8) label_1_changes.isPaymentForm = /*isPaymentForm*/ ctx[3]; if (dirty & /*$$scope, config, value, isPaymentForm, hasError, onFocus, onBlur, stateOptions, placeholder*/ 525755) { label_1_changes.$$scope = { dirty, ctx }; } label_1.$set(label_1_changes); if (/*hasError*/ ctx[10]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_1$c(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, i(local) { if (current) return; transition_in(label_1.$$.fragment, local); current = true; }, o(local) { transition_out(label_1.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(t); detach(if_block_anchor); } destroy_component(label_1, detaching); if (if_block) if_block.d(detaching); } }; } // (66:6) {#each stateOptions as option} function create_each_block$7(ctx) { let option_1; let t0_value = /*option*/ ctx[16].label + ""; let t0; let t1; let option_1_value_value; let option_1_selected_value; return { c() { option_1 = element("option"); t0 = text(t0_value); t1 = space(); option_1.__value = option_1_value_value = /*option*/ ctx[16].value; set_input_value(option_1, option_1.__value); option_1.selected = option_1_selected_value = /*value*/ ctx[1] === /*option*/ ctx[16].value; }, m(target, anchor) { insert(target, option_1, anchor); append(option_1, t0); append(option_1, t1); }, p(ctx, dirty) { if (dirty & /*stateOptions*/ 128 && t0_value !== (t0_value = /*option*/ ctx[16].label + "")) set_data(t0, t0_value); if (dirty & /*stateOptions*/ 128 && option_1_value_value !== (option_1_value_value = /*option*/ ctx[16].value)) { option_1.__value = option_1_value_value; set_input_value(option_1, option_1.__value); } if (dirty & /*value, stateOptions*/ 130 && option_1_selected_value !== (option_1_selected_value = /*value*/ ctx[1] === /*option*/ ctx[16].value)) { option_1.selected = option_1_selected_value; } }, d(detaching) { if (detaching) { detach(option_1); } } }; } // (45:2) function create_default_slot$2(ctx) { let select; let option_1; let t; let select_required_value; let select_value_value; let select_disabled_value; let mounted; let dispose; let each_value = ensure_array_like(/*stateOptions*/ ctx[7]); let each_blocks = []; for (let i = 0; i { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$i($$self, $$props, $$invalidate) { let hasError; let label; let placeholder; let shouldShow; let stateOptions; let { formKey } = $$props; let { config } = $$props; let { value } = $$props; let { error = "" } = $$props; let { isPaymentForm = false } = $$props; let { billingCountry } = $$props; let { onChange } = $$props; let { onFocus } = $$props; let { onBlur } = $$props; const id = `zephr-form-billing-state-${formKey}`; const handleChange = e => { const target = e.target; onChange(target.value); }; $$self.$$set = $$props => { if ('formKey' in $$props) $$invalidate(13, formKey = $$props.formKey); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('value' in $$props) $$invalidate(1, value = $$props.value); if ('error' in $$props) $$invalidate(2, error = $$props.error); if ('isPaymentForm' in $$props) $$invalidate(3, isPaymentForm = $$props.isPaymentForm); if ('billingCountry' in $$props) $$invalidate(14, billingCountry = $$props.billingCountry); if ('onChange' in $$props) $$invalidate(15, onChange = $$props.onChange); if ('onFocus' in $$props) $$invalidate(4, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(5, onBlur = $$props.onBlur); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*error*/ 4) { $$invalidate(10, hasError = !!error); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(9, label = config.label || "State/Province"); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(8, placeholder = config.placeholder || "Select your state/province"); } if ($$self.$$.dirty & /*billingCountry*/ 16384) { // Only show when country is US or Canada $$invalidate(6, shouldShow = billingCountry === "US" || billingCountry === "CA"); } if ($$self.$$.dirty & /*billingCountry*/ 16384) { // Get appropriate state/province options based on country $$invalidate(7, stateOptions = (() => { if (billingCountry === "US") { return Object.entries(statesForUS).map(([code, name]) => ({ value: code, label: name })); } else if (billingCountry === "CA") { return Object.entries(provincesForCanada).map(([code, name]) => ({ value: code, label: name })); } return []; })()); } if ($$self.$$.dirty & /*shouldShow, value, onChange*/ 32834) { // Clear value when country changes to non-US/CA if (!shouldShow && value) { onChange(""); } } }; return [ config, value, error, isPaymentForm, onFocus, onBlur, shouldShow, stateOptions, placeholder, label, hasError, id, handleChange, formKey, billingCountry, onChange ]; } class BillingState extends SvelteComponent { constructor(options) { super(); init(this, options, instance$i, create_fragment$i, safe_not_equal, { formKey: 13, config: 0, value: 1, error: 2, isPaymentForm: 3, billingCountry: 14, onChange: 15, onFocus: 4, onBlur: 5 }); } } /* src/components/elements/recipientAddress/RecipientAddress.svelte generated by Svelte v4.2.12 */ function create_if_block$c(ctx) { let div1; let label; let t0_value = /*config*/ ctx[0].label + ""; let t0; let t1; let div0; let t2; let t3; let t4; let t5; let t6; let current; let if_block0 = /*showAddress*/ ctx[3] && create_if_block_6$3(ctx); let if_block1 = /*showCity*/ ctx[5] && create_if_block_5$3(ctx); let if_block2 = /*showCountry*/ ctx[7] && create_if_block_4$3(ctx); let if_block3 = /*showState*/ ctx[6] && create_if_block_3$4(ctx); let if_block4 = /*showPostalCode*/ ctx[4] && create_if_block_2$8(ctx); let if_block5 = /*addressError*/ ctx[1] && create_if_block_1$b(ctx); return { c() { div1 = element("div"); label = element("label"); t0 = text(t0_value); t1 = space(); div0 = element("div"); if (if_block0) if_block0.c(); t2 = space(); if (if_block1) if_block1.c(); t3 = space(); if (if_block2) if_block2.c(); t4 = space(); if (if_block3) if_block3.c(); t5 = space(); if (if_block4) if_block4.c(); t6 = space(); if (if_block5) if_block5.c(); attr(label, "class", "address-main-label svelte-1yybexv"); attr(div0, "class", "address-fields svelte-1yybexv"); attr(div1, "class", "recipient-address-section svelte-1yybexv"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, label); append(label, t0); append(div1, t1); append(div1, div0); if (if_block0) if_block0.m(div0, null); append(div0, t2); if (if_block1) if_block1.m(div0, null); append(div0, t3); if (if_block2) if_block2.m(div0, null); append(div0, t4); if (if_block3) if_block3.m(div0, null); append(div0, t5); if (if_block4) if_block4.m(div0, null); append(div1, t6); if (if_block5) if_block5.m(div1, null); current = true; }, p(ctx, dirty) { if ((!current || dirty & /*config*/ 1) && t0_value !== (t0_value = /*config*/ ctx[0].label + "")) set_data(t0, t0_value); if (/*showAddress*/ ctx[3]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_6$3(ctx); if_block0.c(); if_block0.m(div0, t2); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*showCity*/ ctx[5]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_5$3(ctx); if_block1.c(); if_block1.m(div0, t3); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (/*showCountry*/ ctx[7]) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty & /*showCountry*/ 128) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_4$3(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(div0, t4); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } if (/*showState*/ ctx[6]) { if (if_block3) { if_block3.p(ctx, dirty); if (dirty & /*showState*/ 64) { transition_in(if_block3, 1); } } else { if_block3 = create_if_block_3$4(ctx); if_block3.c(); transition_in(if_block3, 1); if_block3.m(div0, t5); } } else if (if_block3) { group_outros(); transition_out(if_block3, 1, 1, () => { if_block3 = null; }); check_outros(); } if (/*showPostalCode*/ ctx[4]) { if (if_block4) { if_block4.p(ctx, dirty); } else { if_block4 = create_if_block_2$8(ctx); if_block4.c(); if_block4.m(div0, null); } } else if (if_block4) { if_block4.d(1); if_block4 = null; } if (/*addressError*/ ctx[1]) { if (if_block5) { if_block5.p(ctx, dirty); } else { if_block5 = create_if_block_1$b(ctx); if_block5.c(); if_block5.m(div1, null); } } else if (if_block5) { if_block5.d(1); if_block5 = null; } }, i(local) { if (current) return; transition_in(if_block2); transition_in(if_block3); current = true; }, o(local) { transition_out(if_block2); transition_out(if_block3); current = false; }, d(detaching) { if (detaching) { detach(div1); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); if (if_block3) if_block3.d(); if (if_block4) if_block4.d(); if (if_block5) if_block5.d(); } }; } // (82:6) {#if showAddress} function create_if_block_6$3(ctx) { let div0; let label0; let t0_value = /*config*/ ctx[0].addressLine1Label + ""; let t0; let t1; let input0; let input0_placeholder_value; let t2; let div1; let label1; let t3_value = /*config*/ ctx[0].addressLine2Label + ""; let t3; let t4; let input1; let input1_placeholder_value; let mounted; let dispose; return { c() { div0 = element("div"); label0 = element("label"); t0 = text(t0_value); t1 = space(); input0 = element("input"); t2 = space(); div1 = element("div"); label1 = element("label"); t3 = text(t3_value); t4 = space(); input1 = element("input"); attr(label0, "for", "addressLine1"); attr(label0, "class", "svelte-1yybexv"); attr(input0, "id", "addressLine1"); attr(input0, "type", "text"); input0.required = /*showAddress*/ ctx[3]; attr(input0, "placeholder", input0_placeholder_value = /*config*/ ctx[0].addressLine1Placeholder); attr(input0, "class", "svelte-1yybexv"); attr(div0, "class", "field svelte-1yybexv"); attr(label1, "for", "addressLine2"); attr(label1, "class", "svelte-1yybexv"); attr(input1, "id", "addressLine2"); attr(input1, "type", "text"); attr(input1, "placeholder", input1_placeholder_value = /*config*/ ctx[0].addressLine2Placeholder); attr(input1, "class", "svelte-1yybexv"); attr(div1, "class", "field svelte-1yybexv"); }, m(target, anchor) { insert(target, div0, anchor); append(div0, label0); append(label0, t0); append(div0, t1); append(div0, input0); set_input_value(input0, /*recipientAddress*/ ctx[2].addressLine1); insert(target, t2, anchor); insert(target, div1, anchor); append(div1, label1); append(label1, t3); append(div1, t4); append(div1, input1); set_input_value(input1, /*recipientAddress*/ ctx[2].addressLine2); if (!mounted) { dispose = [ listen(input0, "input", /*input0_input_handler*/ ctx[13]), listen(input0, "input", /*updateGiftRecipient*/ ctx[9]), listen(input1, "input", /*input1_input_handler*/ ctx[14]), listen(input1, "input", /*updateGiftRecipient*/ ctx[9]) ]; mounted = true; } }, p(ctx, dirty) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].addressLine1Label + "")) set_data(t0, t0_value); if (dirty & /*showAddress*/ 8) { input0.required = /*showAddress*/ ctx[3]; } if (dirty & /*config*/ 1 && input0_placeholder_value !== (input0_placeholder_value = /*config*/ ctx[0].addressLine1Placeholder)) { attr(input0, "placeholder", input0_placeholder_value); } if (dirty & /*recipientAddress*/ 4 && input0.value !== /*recipientAddress*/ ctx[2].addressLine1) { set_input_value(input0, /*recipientAddress*/ ctx[2].addressLine1); } if (dirty & /*config*/ 1 && t3_value !== (t3_value = /*config*/ ctx[0].addressLine2Label + "")) set_data(t3, t3_value); if (dirty & /*config*/ 1 && input1_placeholder_value !== (input1_placeholder_value = /*config*/ ctx[0].addressLine2Placeholder)) { attr(input1, "placeholder", input1_placeholder_value); } if (dirty & /*recipientAddress*/ 4 && input1.value !== /*recipientAddress*/ ctx[2].addressLine2) { set_input_value(input1, /*recipientAddress*/ ctx[2].addressLine2); } }, d(detaching) { if (detaching) { detach(div0); detach(t2); detach(div1); } mounted = false; run_all(dispose); } }; } // (107:6) {#if showCity} function create_if_block_5$3(ctx) { let div; let label; let t0_value = /*config*/ ctx[0].cityLabel + ""; let t0; let t1; let input; let input_placeholder_value; let mounted; let dispose; return { c() { div = element("div"); label = element("label"); t0 = text(t0_value); t1 = space(); input = element("input"); attr(label, "for", "city"); attr(label, "class", "svelte-1yybexv"); attr(input, "id", "city"); attr(input, "type", "text"); input.required = /*showCity*/ ctx[5]; attr(input, "placeholder", input_placeholder_value = /*config*/ ctx[0].cityPlaceholder); attr(input, "class", "svelte-1yybexv"); attr(div, "class", "field svelte-1yybexv"); }, m(target, anchor) { insert(target, div, anchor); append(div, label); append(label, t0); append(div, t1); append(div, input); set_input_value(input, /*recipientAddress*/ ctx[2].city); if (!mounted) { dispose = [ listen(input, "input", /*input_input_handler*/ ctx[15]), listen(input, "input", /*updateGiftRecipient*/ ctx[9]) ]; mounted = true; } }, p(ctx, dirty) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].cityLabel + "")) set_data(t0, t0_value); if (dirty & /*showCity*/ 32) { input.required = /*showCity*/ ctx[5]; } if (dirty & /*config*/ 1 && input_placeholder_value !== (input_placeholder_value = /*config*/ ctx[0].cityPlaceholder)) { attr(input, "placeholder", input_placeholder_value); } if (dirty & /*recipientAddress*/ 4 && input.value !== /*recipientAddress*/ ctx[2].city) { set_input_value(input, /*recipientAddress*/ ctx[2].city); } }, d(detaching) { if (detaching) { detach(div); } mounted = false; run_all(dispose); } }; } // (121:6) {#if showCountry} function create_if_block_4$3(ctx) { let div; let billingcountry; let current; billingcountry = new BillingCountry({ props: { formKey: "gift-recipient", config: { label: /*config*/ ctx[0].countryLabel, placeholder: /*config*/ ctx[0].countryPlaceholder, required: /*showCountry*/ ctx[7] }, value: /*recipientAddress*/ ctx[2].country, error: "", isPaymentForm: false, onChange: /*func*/ ctx[16], onFocus: func_1, onBlur: func_2 } }); return { c() { div = element("div"); create_component(billingcountry.$$.fragment); attr(div, "class", "field svelte-1yybexv"); }, m(target, anchor) { insert(target, div, anchor); mount_component(billingcountry, div, null); current = true; }, p(ctx, dirty) { const billingcountry_changes = {}; if (dirty & /*config, showCountry*/ 129) billingcountry_changes.config = { label: /*config*/ ctx[0].countryLabel, placeholder: /*config*/ ctx[0].countryPlaceholder, required: /*showCountry*/ ctx[7] }; if (dirty & /*recipientAddress*/ 4) billingcountry_changes.value = /*recipientAddress*/ ctx[2].country; if (dirty & /*recipientAddress*/ 4) billingcountry_changes.onChange = /*func*/ ctx[16]; billingcountry.$set(billingcountry_changes); }, i(local) { if (current) return; transition_in(billingcountry.$$.fragment, local); current = true; }, o(local) { transition_out(billingcountry.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(billingcountry); } }; } // (143:6) {#if showState} function create_if_block_3$4(ctx) { let div; let billingstate; let current; billingstate = new BillingState({ props: { formKey: "gift-recipient", config: { label: /*config*/ ctx[0].stateLabel, placeholder: /*config*/ ctx[0].statePlaceholder, required: /*showState*/ ctx[6] && (/*recipientAddress*/ ctx[2].country === 'US' || /*recipientAddress*/ ctx[2].country === 'CA') }, value: /*recipientAddress*/ ctx[2].state, error: "", isPaymentForm: false, billingCountry: /*recipientAddress*/ ctx[2].country, onChange: /*func_3*/ ctx[17], onFocus: func_4, onBlur: func_5 } }); return { c() { div = element("div"); create_component(billingstate.$$.fragment); attr(div, "class", "field svelte-1yybexv"); }, m(target, anchor) { insert(target, div, anchor); mount_component(billingstate, div, null); current = true; }, p(ctx, dirty) { const billingstate_changes = {}; if (dirty & /*config, showState, recipientAddress*/ 69) billingstate_changes.config = { label: /*config*/ ctx[0].stateLabel, placeholder: /*config*/ ctx[0].statePlaceholder, required: /*showState*/ ctx[6] && (/*recipientAddress*/ ctx[2].country === 'US' || /*recipientAddress*/ ctx[2].country === 'CA') }; if (dirty & /*recipientAddress*/ 4) billingstate_changes.value = /*recipientAddress*/ ctx[2].state; if (dirty & /*recipientAddress*/ 4) billingstate_changes.billingCountry = /*recipientAddress*/ ctx[2].country; if (dirty & /*recipientAddress*/ 4) billingstate_changes.onChange = /*func_3*/ ctx[17]; billingstate.$set(billingstate_changes); }, i(local) { if (current) return; transition_in(billingstate.$$.fragment, local); current = true; }, o(local) { transition_out(billingstate.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(billingstate); } }; } // (166:6) {#if showPostalCode} function create_if_block_2$8(ctx) { let div; let label; let t0_value = /*config*/ ctx[0].postalCodeLabel + ""; let t0; let t1; let input; let input_placeholder_value; let mounted; let dispose; return { c() { div = element("div"); label = element("label"); t0 = text(t0_value); t1 = space(); input = element("input"); attr(label, "for", "postalCode"); attr(label, "class", "svelte-1yybexv"); attr(input, "id", "postalCode"); attr(input, "type", "text"); input.required = /*showPostalCode*/ ctx[4]; attr(input, "placeholder", input_placeholder_value = /*config*/ ctx[0].postalCodePlaceholder); attr(input, "class", "svelte-1yybexv"); attr(div, "class", "field svelte-1yybexv"); }, m(target, anchor) { insert(target, div, anchor); append(div, label); append(label, t0); append(div, t1); append(div, input); set_input_value(input, /*recipientAddress*/ ctx[2].postalCode); if (!mounted) { dispose = [ listen(input, "input", /*input_input_handler_1*/ ctx[18]), listen(input, "input", /*updateGiftRecipient*/ ctx[9]) ]; mounted = true; } }, p(ctx, dirty) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].postalCodeLabel + "")) set_data(t0, t0_value); if (dirty & /*showPostalCode*/ 16) { input.required = /*showPostalCode*/ ctx[4]; } if (dirty & /*config*/ 1 && input_placeholder_value !== (input_placeholder_value = /*config*/ ctx[0].postalCodePlaceholder)) { attr(input, "placeholder", input_placeholder_value); } if (dirty & /*recipientAddress*/ 4 && input.value !== /*recipientAddress*/ ctx[2].postalCode) { set_input_value(input, /*recipientAddress*/ ctx[2].postalCode); } }, d(detaching) { if (detaching) { detach(div); } mounted = false; run_all(dispose); } }; } // (180:4) {#if addressError} function create_if_block_1$b(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*addressError*/ ctx[1]); attr(div, "class", "error-text svelte-1yybexv"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*addressError*/ 2) set_data(t, /*addressError*/ ctx[1]); }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$h(ctx) { let if_block_anchor; let current; let if_block = /*showAnyAddress*/ ctx[8] && create_if_block$c(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { if (/*showAnyAddress*/ ctx[8]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*showAnyAddress*/ 256) { transition_in(if_block, 1); } } else { if_block = create_if_block$c(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } const func_1 = () => { }; const func_2 = () => { }; const func_4 = () => { }; const func_5 = () => { }; function instance$h($$self, $$props, $$invalidate) { let showAddress; let showPostalCode; let showCountry; let showState; let showCity; let showAnyAddress; let { formState } = $$props; let { formActions } = $$props; let { config } = $$props; let { form } = $$props; const dispatch = createEventDispatcher(); let addressError = ''; const defaultCountry = formConfigAs(form).defaultCountry || ''; // Initialize recipient address fields let recipientAddress = { addressLine1: formState.giftRecipient?.recipientAddress?.addressLine1 || '', addressLine2: formState.giftRecipient?.recipientAddress?.addressLine2 || '', city: formState.giftRecipient?.recipientAddress?.city || '', state: formState.giftRecipient?.recipientAddress?.state || '', country: formState.giftRecipient?.recipientAddress?.country || defaultCountry, postalCode: formState.giftRecipient?.recipientAddress?.postalCode || '' }; // Update form state when inputs change const updateGiftRecipient = () => { const updatedGiftRecipient = { ...formState.giftRecipient || {}, recipientAddress }; formActions.updateFormState({ giftRecipient: updatedGiftRecipient }); validateForm(); }; const validateForm = () => { let isValid = true; let errorMessage = ''; // Validate country if shown if (showCountry && !recipientAddress.country.trim()) { isValid = false; errorMessage = config.countryRequiredError; } // Validate state if shown and country requires it if (showState && (recipientAddress.country === 'US' || recipientAddress.country === 'CA') && !recipientAddress.state.trim()) { isValid = false; errorMessage = config.stateRequiredError; } // Validate city if shown if (showCity && !recipientAddress.city.trim()) { isValid = false; errorMessage = config.cityRequiredError; } // Validate postal code if shown if (showPostalCode && !errorMessage) { if (!recipientAddress.postalCode.trim()) { isValid = false; errorMessage = config.postalCodeRequiredError; } } // Validate street address if shown if (showAddress && !errorMessage) { if (!recipientAddress.addressLine1.trim()) { isValid = false; errorMessage = config.addressRequiredError; } } $$invalidate(1, addressError = errorMessage); // Dispatch event for form validity dispatch('validity', { isValid }); }; function input0_input_handler() { recipientAddress.addressLine1 = this.value; $$invalidate(2, recipientAddress); } function input1_input_handler() { recipientAddress.addressLine2 = this.value; $$invalidate(2, recipientAddress); } function input_input_handler() { recipientAddress.city = this.value; $$invalidate(2, recipientAddress); } const func = value => { $$invalidate(2, recipientAddress.country = value, recipientAddress); updateGiftRecipient(); }; const func_3 = value => { $$invalidate(2, recipientAddress.state = value, recipientAddress); updateGiftRecipient(); }; function input_input_handler_1() { recipientAddress.postalCode = this.value; $$invalidate(2, recipientAddress); } $$self.$$set = $$props => { if ('formState' in $$props) $$invalidate(10, formState = $$props.formState); if ('formActions' in $$props) $$invalidate(11, formActions = $$props.formActions); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('form' in $$props) $$invalidate(12, form = $$props.form); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*config*/ 1) { // Use config values directly - they are reactive props $$invalidate(3, showAddress = config?.showAddress ?? false); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(4, showPostalCode = config?.showPostalCode ?? false); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(7, showCountry = config?.showCountry ?? false); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(6, showState = config?.showState ?? false); } if ($$self.$$.dirty & /*config*/ 1) { $$invalidate(5, showCity = config?.showCity ?? false); } }; $$invalidate(8, showAnyAddress = true); return [ config, addressError, recipientAddress, showAddress, showPostalCode, showCity, showState, showCountry, showAnyAddress, updateGiftRecipient, formState, formActions, form, input0_input_handler, input1_input_handler, input_input_handler, func, func_3, input_input_handler_1 ]; } class RecipientAddress extends SvelteComponent { constructor(options) { super(); init(this, options, instance$h, create_fragment$h, safe_not_equal, { formState: 10, formActions: 11, config: 0, form: 12 }); } } const recipientAddressFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.RECIPIENT_ADDRESS, create: (form, formState, formActions, elementConfig) => { // Determine if address is required from form configuration const typeConfiguration = formConfigAs(form); const requires_address = typeConfiguration.requires_address; // If requires_address is false, don't render the component at all if (requires_address === false) { return { component: null, props: {}, isValid: true }; } // Resolve all labels and error messages through language pack service const resolvedConfig = { label: resolveLanguagePackKeyTyped(form, 'forms.gift.recipient-address', elementConfig.label), addressLine1Label: resolveLanguagePackKeyTyped(form, 'forms.gift.address-line1', elementConfig.addressLine1Label), addressLine2Label: resolveLanguagePackKeyTyped(form, 'forms.gift.address-line2', elementConfig.addressLine2Label), cityLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.city', elementConfig.cityLabel), stateLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.state', elementConfig.stateLabel), countryLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.country', elementConfig.countryLabel), postalCodeLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.postal-code', elementConfig.postalCodeLabel), addressRequiredError: resolveLanguagePackKeyTyped(form, 'forms.gift.address-required', elementConfig.addressRequiredError), countryRequiredError: resolveLanguagePackKeyTyped(form, 'forms.gift.country-required', elementConfig.countryRequiredError), stateRequiredError: resolveLanguagePackKeyTyped(form, 'forms.gift.state-required', elementConfig.stateRequiredError), cityRequiredError: resolveLanguagePackKeyTyped(form, 'forms.gift.city-required', elementConfig.cityRequiredError), postalCodeRequiredError: resolveLanguagePackKeyTyped(form, 'forms.gift.postal-code-required', elementConfig.postalCodeRequiredError), addressLine1Placeholder: resolveLanguagePackKeyTyped(form, 'forms.gift.address-line1-placeholder', elementConfig.addressLine1Placeholder), addressLine2Placeholder: resolveLanguagePackKeyTyped(form, 'forms.gift.address-line2-placeholder', elementConfig.addressLine2Placeholder), cityPlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.city-placeholder', elementConfig.cityPlaceholder), statePlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.state-placeholder', elementConfig.statePlaceholder), countryPlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.country-placeholder', elementConfig.countryPlaceholder), postalCodePlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.postal-code-placeholder', elementConfig.postalCodePlaceholder), // Field visibility controls - pass through from element config showAddress: elementConfig.showAddress, showPostalCode: elementConfig.showPostalCode, showCountry: elementConfig.showCountry, showState: elementConfig.showState, showCity: elementConfig.showCity, }; // Determine if the input is valid based on granular field requirements const giftRecipient = (formState.giftRecipient || {}); const recipientAddress = giftRecipient.recipientAddress || {}; let isValid = true; // Calculate which fields are shown (same logic as component) const showAddress = elementConfig.showAddress ?? false; const showPostalCode = elementConfig.showPostalCode ?? false; const showCountry = elementConfig.showCountry ?? false; const showState = elementConfig.showState ?? false; const showCity = elementConfig.showCity ?? false; // Validate address if required if (showAddress && !recipientAddress.addressLine1?.trim()) { isValid = false; } // Validate postal code if required if (showPostalCode && !recipientAddress.postalCode?.trim()) { isValid = false; } // Validate country if required if (showCountry && !recipientAddress.country?.trim()) { isValid = false; } // Validate state if required (only for US/CA when showState is enabled) if (showState && (recipientAddress.country === 'US' || recipientAddress.country === 'CA') && !recipientAddress.state?.trim()) { isValid = false; } // Validate city if required if (showCity && !recipientAddress.city?.trim()) { isValid = false; } return { component: RecipientAddress, props: { config: resolvedConfig, form, formState, formActions, }, isValid }; } }; /* src/components/elements/recipientMessage/RecipientMessage.svelte generated by Svelte v4.2.12 */ function create_fragment$g(ctx) { let div1; let div0; let label; let t0_value = /*config*/ ctx[0].messageLabel + ""; let t0; let t1; let textarea; let textarea_placeholder_value; let mounted; let dispose; return { c() { div1 = element("div"); div0 = element("div"); label = element("label"); t0 = text(t0_value); t1 = space(); textarea = element("textarea"); attr(label, "for", "customMessage"); attr(label, "class", "svelte-h6tpk7"); attr(textarea, "id", "customMessage"); attr(textarea, "placeholder", textarea_placeholder_value = /*config*/ ctx[0].messagePlaceholder); attr(textarea, "class", "svelte-h6tpk7"); attr(div0, "class", "field svelte-h6tpk7"); attr(div1, "class", "recipient-message-section svelte-h6tpk7"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, div0); append(div0, label); append(label, t0); append(div0, t1); append(div0, textarea); set_input_value(textarea, /*customMessage*/ ctx[1]); if (!mounted) { dispose = [ listen(textarea, "input", /*textarea_input_handler*/ ctx[5]), listen(textarea, "input", /*updateGiftRecipient*/ ctx[2]) ]; mounted = true; } }, p(ctx, [dirty]) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].messageLabel + "")) set_data(t0, t0_value); if (dirty & /*config*/ 1 && textarea_placeholder_value !== (textarea_placeholder_value = /*config*/ ctx[0].messagePlaceholder)) { attr(textarea, "placeholder", textarea_placeholder_value); } if (dirty & /*customMessage*/ 2) { set_input_value(textarea, /*customMessage*/ ctx[1]); } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div1); } mounted = false; run_all(dispose); } }; } function instance$g($$self, $$props, $$invalidate) { let { formState } = $$props; let { formActions } = $$props; let { config } = $$props; const dispatch = createEventDispatcher(); let customMessage = formState.giftRecipient?.customMessage || ''; // Update form state when input changes const updateGiftRecipient = () => { const updatedGiftRecipient = { ...formState.giftRecipient || {}, customMessage }; formActions.updateFormState({ giftRecipient: updatedGiftRecipient }); }; // Initial validation onMount(() => { // Message is always valid as it's optional dispatch('validity', { isValid: true }); }); function textarea_input_handler() { customMessage = this.value; $$invalidate(1, customMessage); } $$self.$$set = $$props => { if ('formState' in $$props) $$invalidate(3, formState = $$props.formState); if ('formActions' in $$props) $$invalidate(4, formActions = $$props.formActions); if ('config' in $$props) $$invalidate(0, config = $$props.config); }; return [ config, customMessage, updateGiftRecipient, formState, formActions, textarea_input_handler ]; } class RecipientMessage extends SvelteComponent { constructor(options) { super(); init(this, options, instance$g, create_fragment$g, safe_not_equal, { formState: 3, formActions: 4, config: 0 }); } } const recipientMessageFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.RECIPIENT_MESSAGE, create: (form, formState, formActions, elementConfig) => { // Resolve all labels through language pack service const resolvedConfig = { messageLabel: resolveLanguagePackKeyTyped(form, 'forms.gift.custom-message', elementConfig.messageLabel), messagePlaceholder: resolveLanguagePackKeyTyped(form, 'forms.gift.message-placeholder', elementConfig.messagePlaceholder), }; // Message is always valid as it's optional const isValid = true; return { component: RecipientMessage, props: { config: resolvedConfig, form, formState, formActions, }, isValid }; } }; /* src/components/elements/giftCode/GiftCode.svelte generated by Svelte v4.2.12 */ function create_if_block_1$a(ctx) { let label_1; let t0; let t1; let if_block = /*required*/ ctx[3] && create_if_block_2$7(); return { c() { label_1 = element("label"); t0 = text(/*label*/ ctx[1]); t1 = space(); if (if_block) if_block.c(); attr(label_1, "for", "zephr-form-gift-code"); attr(label_1, "class", "svelte-764k6k"); }, m(target, anchor) { insert(target, label_1, anchor); append(label_1, t0); append(label_1, t1); if (if_block) if_block.m(label_1, null); }, p(ctx, dirty) { if (dirty & /*label*/ 2) set_data(t0, /*label*/ ctx[1]); if (/*required*/ ctx[3]) { if (if_block) ; else { if_block = create_if_block_2$7(); if_block.c(); if_block.m(label_1, null); } } else if (if_block) { if_block.d(1); if_block = null; } }, d(detaching) { if (detaching) { detach(label_1); } if (if_block) if_block.d(); } }; } // (22:6) {#if required} function create_if_block_2$7(ctx) { let span; return { c() { span = element("span"); span.textContent = "*"; attr(span, "class", "required svelte-764k6k"); }, m(target, anchor) { insert(target, span, anchor); }, d(detaching) { if (detaching) { detach(span); } } }; } // (40:2) {#if errorMessage} function create_if_block$b(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*errorMessage*/ ctx[7]); attr(div, "class", "error-message svelte-764k6k"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errorMessage*/ 128) set_data(t, /*errorMessage*/ ctx[7]); }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$f(ctx) { let div; let t0; let input; let t1; let mounted; let dispose; let if_block0 = /*label*/ ctx[1] && create_if_block_1$a(ctx); let if_block1 = /*errorMessage*/ ctx[7] && create_if_block$b(ctx); return { c() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); input = element("input"); t1 = space(); if (if_block1) if_block1.c(); attr(input, "id", "zephr-form-gift-code"); attr(input, "type", "text"); attr(input, "placeholder", /*placeholder*/ ctx[2]); input.disabled = /*disabled*/ ctx[4]; input.required = /*required*/ ctx[3]; input.value = /*value*/ ctx[0]; attr(input, "maxlength", "16"); attr(input, "class", "svelte-764k6k"); toggle_class(input, "error", !!/*errorMessage*/ ctx[7]); attr(div, "class", "zephr-form-input-wrapper svelte-764k6k"); }, m(target, anchor) { insert(target, div, anchor); if (if_block0) if_block0.m(div, null); append(div, t0); append(div, input); append(div, t1); if (if_block1) if_block1.m(div, null); if (!mounted) { dispose = [ listen(input, "input", /*handleChange*/ ctx[8]), listen(input, "focus", function () { if (is_function(/*onFocus*/ ctx[5])) /*onFocus*/ ctx[5].apply(this, arguments); }), listen(input, "blur", function () { if (is_function(/*onBlur*/ ctx[6])) /*onBlur*/ ctx[6].apply(this, arguments); }) ]; mounted = true; } }, p(new_ctx, [dirty]) { ctx = new_ctx; if (/*label*/ ctx[1]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_1$a(ctx); if_block0.c(); if_block0.m(div, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (dirty & /*placeholder*/ 4) { attr(input, "placeholder", /*placeholder*/ ctx[2]); } if (dirty & /*disabled*/ 16) { input.disabled = /*disabled*/ ctx[4]; } if (dirty & /*required*/ 8) { input.required = /*required*/ ctx[3]; } if (dirty & /*value*/ 1 && input.value !== /*value*/ ctx[0]) { input.value = /*value*/ ctx[0]; } if (dirty & /*errorMessage*/ 128) { toggle_class(input, "error", !!/*errorMessage*/ ctx[7]); } if (/*errorMessage*/ ctx[7]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$b(ctx); if_block1.c(); if_block1.m(div, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); mounted = false; run_all(dispose); } }; } function instance$f($$self, $$props, $$invalidate) { let errorMessage; let { value = "" } = $$props; let { label = "" } = $$props; let { placeholder = "" } = $$props; let { required = false } = $$props; let { disabled = false } = $$props; let { hasError = false } = $$props; let { error = false } = $$props; let { onChange = _value => { } } = $$props; let { onFocus = () => { } } = $$props; let { onBlur = () => { } } = $$props; const handleChange = event => { const newValue = event.target.value; onChange(newValue); }; $$self.$$set = $$props => { if ('value' in $$props) $$invalidate(0, value = $$props.value); if ('label' in $$props) $$invalidate(1, label = $$props.label); if ('placeholder' in $$props) $$invalidate(2, placeholder = $$props.placeholder); if ('required' in $$props) $$invalidate(3, required = $$props.required); if ('disabled' in $$props) $$invalidate(4, disabled = $$props.disabled); if ('hasError' in $$props) $$invalidate(9, hasError = $$props.hasError); if ('error' in $$props) $$invalidate(10, error = $$props.error); if ('onChange' in $$props) $$invalidate(11, onChange = $$props.onChange); if ('onFocus' in $$props) $$invalidate(5, onFocus = $$props.onFocus); if ('onBlur' in $$props) $$invalidate(6, onBlur = $$props.onBlur); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*hasError, error*/ 1536) { $$invalidate(7, errorMessage = hasError || error); } }; return [ value, label, placeholder, required, disabled, onFocus, onBlur, errorMessage, handleChange, hasError, error, onChange ]; } class GiftCode extends SvelteComponent { constructor(options) { super(); init(this, options, instance$f, create_fragment$f, safe_not_equal, { value: 0, label: 1, placeholder: 2, required: 3, disabled: 4, hasError: 9, error: 10, onChange: 11, onFocus: 5, onBlur: 6 }); } } const factory$4 = { matches: (sectionElement) => sectionElement.type === elementTypes.GIFT_CODE, create: (form, formState, formActions, config) => { const { disabled, label, placeholder, required } = config; const error = serverErrorForElement(elementTypes.GIFT_CODE, formState); const onChange = (value) => { formActions.updateFormState({ giftCode: value, giftCodeError: undefined, }); logDataLayerEvent(form, 'zephr_form_input_change', { field: 'gift-code', inputName: `zephr-form-gift-code-${form.uniqueKey}`, sectionId: formState.currentSection.type, }); }; const onFocus = () => logDataLayerEvent(form, 'zephr_form_input_focus', { field: 'gift-code', inputName: `zephr-form-gift-code-${form.uniqueKey}`, sectionId: formState.currentSection.type, }); const onBlur = () => logDataLayerEvent(form, 'zephr_form_input_blur', { field: 'gift-code', inputName: `zephr-form-gift-code-${form.uniqueKey}`, sectionId: formState.currentSection.type, }); const giftCode = formState.giftCode || ''; const isValid = (!required || !!giftCode) && giftCode.length === 16; const errorMessage = error ? resolveErrorLanguagePackKey(form, error) : formState.giftCodeError; return { component: GiftCode, props: { hasError: errorMessage, label, placeholder, required, disabled, onChange, onFocus, onBlur, value: formState.giftCode || '', }, isValid, }; }, }; /* src/components/elements/giftSubscriptionsList/GiftSubscriptionsListBoxItem.svelte generated by Svelte v4.2.12 */ function get_each_context$6(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[35] = list[i]; return child_ctx; } // (79:74) function create_if_block_18(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*expiredBannerText*/ ctx[9]); attr(div, "class", "zephr-banner-top svelte-srvimy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty[0] & /*expiredBannerText*/ 512) set_data(t, /*expiredBannerText*/ ctx[9]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (75:78) function create_if_block_17(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*suspendedBannerText*/ ctx[8]); attr(div, "class", "zephr-banner-top svelte-srvimy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty[0] & /*suspendedBannerText*/ 256) set_data(t, /*suspendedBannerText*/ ctx[8]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (71:125) function create_if_block_16(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*cancelledBannerText*/ ctx[7]); attr(div, "class", "zephr-banner-top svelte-srvimy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty[0] & /*cancelledBannerText*/ 128) set_data(t, /*cancelledBannerText*/ ctx[7]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (67:72) function create_if_block_15(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*activeBannerText*/ ctx[6]); attr(div, "class", "zephr-banner-top svelte-srvimy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty[0] & /*activeBannerText*/ 64) set_data(t, /*activeBannerText*/ ctx[6]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (63:39) function create_if_block_14(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*redeemedBannerText*/ ctx[5]); attr(div, "class", "zephr-banner-top svelte-srvimy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty[0] & /*redeemedBannerText*/ 32) set_data(t, /*redeemedBannerText*/ ctx[5]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (59:2) {#if gift.status === 'PENDING'} function create_if_block_13(ctx) { let div; let t0; let t1; let t2_value = /*gift*/ ctx[0].subscriptionStartDate + ""; let t2; return { c() { div = element("div"); t0 = text(/*pendingBannerText*/ ctx[4]); t1 = space(); t2 = text(t2_value); attr(div, "class", "zephr-banner-top svelte-srvimy"); }, m(target, anchor) { insert(target, div, anchor); append(div, t0); append(div, t1); append(div, t2); }, p(ctx, dirty) { if (dirty[0] & /*pendingBannerText*/ 16) set_data(t0, /*pendingBannerText*/ ctx[4]); if (dirty[0] & /*gift*/ 1 && t2_value !== (t2_value = /*gift*/ ctx[0].subscriptionStartDate + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (87:6) {#if element === 'subscription_information' && !elementsHide.subscriptionInformation} function create_if_block_8(ctx) { let t0; let t1; let t2; let if_block3_anchor; let if_block0 = (/*gift*/ ctx[0].recipientFirstName || /*gift*/ ctx[0].recipientLastName || /*gift*/ ctx[0].is_recipient) && create_if_block_12(ctx); let if_block1 = /*gift*/ ctx[0].subscriptionType && create_if_block_11(ctx); let if_block2 = /*gift*/ ctx[0].subscriptionStartDate && create_if_block_10(ctx); let if_block3 = /*gift*/ ctx[0].subscriptionEndDate && create_if_block_9(ctx); return { c() { if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); t2 = space(); if (if_block3) if_block3.c(); if_block3_anchor = empty(); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert(target, t0, anchor); if (if_block1) if_block1.m(target, anchor); insert(target, t1, anchor); if (if_block2) if_block2.m(target, anchor); insert(target, t2, anchor); if (if_block3) if_block3.m(target, anchor); insert(target, if_block3_anchor, anchor); }, p(ctx, dirty) { if (/*gift*/ ctx[0].recipientFirstName || /*gift*/ ctx[0].recipientLastName || /*gift*/ ctx[0].is_recipient) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_12(ctx); if_block0.c(); if_block0.m(t0.parentNode, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*gift*/ ctx[0].subscriptionType) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_11(ctx); if_block1.c(); if_block1.m(t1.parentNode, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (/*gift*/ ctx[0].subscriptionStartDate) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block_10(ctx); if_block2.c(); if_block2.m(t2.parentNode, t2); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } if (/*gift*/ ctx[0].subscriptionEndDate) { if (if_block3) { if_block3.p(ctx, dirty); } else { if_block3 = create_if_block_9(ctx); if_block3.c(); if_block3.m(if_block3_anchor.parentNode, if_block3_anchor); } } else if (if_block3) { if_block3.d(1); if_block3 = null; } }, d(detaching) { if (detaching) { detach(t0); detach(t1); detach(t2); detach(if_block3_anchor); } if (if_block0) if_block0.d(detaching); if (if_block1) if_block1.d(detaching); if (if_block2) if_block2.d(detaching); if (if_block3) if_block3.d(detaching); } }; } // (88:8) {#if gift.recipientFirstName || gift.recipientLastName || gift.is_recipient} function create_if_block_12(ctx) { let div2; let span; let t0; let t1; let div0; let t2_value = (/*gift*/ ctx[0].recipientFirstName || '') + ""; let t2; let t3; let t4_value = (/*gift*/ ctx[0].recipientLastName || '') + ""; let t4; let t5; let div1; let t6_value = /*getStatusText*/ ctx[23](/*gift*/ ctx[0].status) + ""; let t6; return { c() { div2 = element("div"); span = element("span"); t0 = text(/*giftRecipientText*/ ctx[1]); t1 = space(); div0 = element("div"); t2 = text(t2_value); t3 = space(); t4 = text(t4_value); t5 = space(); div1 = element("div"); t6 = text(t6_value); attr(span, "class", "svelte-srvimy"); attr(div0, "class", "zephr-box-item-information svelte-srvimy"); attr(div1, "class", "zephr-status-pill svelte-srvimy"); attr(div2, "class", "zephr-section zephr-header-section svelte-srvimy"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, span); append(span, t0); append(div2, t1); append(div2, div0); append(div0, t2); append(div0, t3); append(div0, t4); append(div2, t5); append(div2, div1); append(div1, t6); }, p(ctx, dirty) { if (dirty[0] & /*giftRecipientText*/ 2) set_data(t0, /*giftRecipientText*/ ctx[1]); if (dirty[0] & /*gift*/ 1 && t2_value !== (t2_value = (/*gift*/ ctx[0].recipientFirstName || '') + "")) set_data(t2, t2_value); if (dirty[0] & /*gift*/ 1 && t4_value !== (t4_value = (/*gift*/ ctx[0].recipientLastName || '') + "")) set_data(t4, t4_value); if (dirty[0] & /*gift*/ 1 && t6_value !== (t6_value = /*getStatusText*/ ctx[23](/*gift*/ ctx[0].status) + "")) set_data(t6, t6_value); }, d(detaching) { if (detaching) { detach(div2); } } }; } // (100:8) {#if gift.subscriptionType} function create_if_block_11(ctx) { let div1; let span; let t0; let t1; let div0; let t2_value = /*gift*/ ctx[0].subscriptionType + ""; let t2; return { c() { div1 = element("div"); span = element("span"); t0 = text(/*subscriptionTypeText*/ ctx[15]); t1 = space(); div0 = element("div"); t2 = text(t2_value); attr(span, "class", "svelte-srvimy"); attr(div0, "class", ""); attr(div1, "class", "zephr-section svelte-srvimy"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, span); append(span, t0); append(div1, t1); append(div1, div0); append(div0, t2); }, p(ctx, dirty) { if (dirty[0] & /*subscriptionTypeText*/ 32768) set_data(t0, /*subscriptionTypeText*/ ctx[15]); if (dirty[0] & /*gift*/ 1 && t2_value !== (t2_value = /*gift*/ ctx[0].subscriptionType + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); } } }; } // (109:8) {#if gift.subscriptionStartDate} function create_if_block_10(ctx) { let div1; let span; let t0; let t1; let div0; let t2_value = /*gift*/ ctx[0].subscriptionStartDate + ""; let t2; return { c() { div1 = element("div"); span = element("span"); t0 = text(/*startDateText*/ ctx[2]); t1 = space(); div0 = element("div"); t2 = text(t2_value); attr(span, "class", "svelte-srvimy"); attr(div0, "class", ""); attr(div1, "class", "zephr-section svelte-srvimy"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, span); append(span, t0); append(div1, t1); append(div1, div0); append(div0, t2); }, p(ctx, dirty) { if (dirty[0] & /*startDateText*/ 4) set_data(t0, /*startDateText*/ ctx[2]); if (dirty[0] & /*gift*/ 1 && t2_value !== (t2_value = /*gift*/ ctx[0].subscriptionStartDate + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); } } }; } // (118:8) {#if gift.subscriptionEndDate} function create_if_block_9(ctx) { let div1; let span; let t0; let t1; let div0; let t2_value = /*gift*/ ctx[0].subscriptionEndDate + ""; let t2; return { c() { div1 = element("div"); span = element("span"); t0 = text(/*endDateText*/ ctx[3]); t1 = space(); div0 = element("div"); t2 = text(t2_value); attr(span, "class", "svelte-srvimy"); attr(div0, "class", ""); attr(div1, "class", "zephr-section svelte-srvimy"); }, m(target, anchor) { insert(target, div1, anchor); append(div1, span); append(span, t0); append(div1, t1); append(div1, div0); append(div0, t2); }, p(ctx, dirty) { if (dirty[0] & /*endDateText*/ 8) set_data(t0, /*endDateText*/ ctx[3]); if (dirty[0] & /*gift*/ 1 && t2_value !== (t2_value = /*gift*/ ctx[0].subscriptionEndDate + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) { detach(div1); } } }; } // (127:6) {#if element === 'billing_history' && !elementsHide.billingHistory} function create_if_block_6$2(ctx) { let show_if = /*canViewBillingHistory*/ ctx[25](/*gift*/ ctx[0].status) && /*billingHistoryLink*/ ctx[18]; let if_block_anchor; let current; let if_block = show_if && create_if_block_7(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (dirty[0] & /*gift, billingHistoryLink*/ 262145) show_if = /*canViewBillingHistory*/ ctx[25](/*gift*/ ctx[0].status) && /*billingHistoryLink*/ ctx[18]; if (show_if) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*gift, billingHistoryLink*/ 262145) { transition_in(if_block, 1); } } else { if_block = create_if_block_7(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (128:8) {#if canViewBillingHistory(gift.status) && billingHistoryLink} function create_if_block_7(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*billingHistoryLink*/ ctx[18], onClick: /*func*/ ctx[31] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*billingHistoryLink*/ 262144) tablink_changes.text = /*billingHistoryLink*/ ctx[18]; if (dirty[0] & /*onViewHistory, gift*/ 524289) tablink_changes.onClick = /*func*/ ctx[31]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (132:6) {#if element === 'change_payment' && !elementsHide.changePayment} function create_if_block_4$2(ctx) { let show_if = /*isActiveStatus*/ ctx[24](/*gift*/ ctx[0].status) && /*changePaymentMethodText*/ ctx[11]; let if_block_anchor; let current; let if_block = show_if && create_if_block_5$2(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (dirty[0] & /*gift, changePaymentMethodText*/ 2049) show_if = /*isActiveStatus*/ ctx[24](/*gift*/ ctx[0].status) && /*changePaymentMethodText*/ ctx[11]; if (show_if) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*gift, changePaymentMethodText*/ 2049) { transition_in(if_block, 1); } } else { if_block = create_if_block_5$2(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (133:8) {#if isActiveStatus(gift.status) && changePaymentMethodText} function create_if_block_5$2(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*changePaymentMethodText*/ ctx[11], onClick: /*func_1*/ ctx[32] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*changePaymentMethodText*/ 2048) tablink_changes.text = /*changePaymentMethodText*/ ctx[11]; if (dirty[0] & /*onChangePayment, gift*/ 1048577) tablink_changes.onClick = /*func_1*/ ctx[32]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (137:6) {#if element === 'change_subscription' && !elementsHide.changeSubscription} function create_if_block_2$6(ctx) { let show_if = /*isActiveStatus*/ ctx[24](/*gift*/ ctx[0].status) && /*changeSubscriptionText*/ ctx[12]; let if_block_anchor; let current; let if_block = show_if && create_if_block_3$3(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (dirty[0] & /*gift, changeSubscriptionText*/ 4097) show_if = /*isActiveStatus*/ ctx[24](/*gift*/ ctx[0].status) && /*changeSubscriptionText*/ ctx[12]; if (show_if) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*gift, changeSubscriptionText*/ 4097) { transition_in(if_block, 1); } } else { if_block = create_if_block_3$3(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (138:8) {#if isActiveStatus(gift.status) && changeSubscriptionText} function create_if_block_3$3(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*changeSubscriptionText*/ ctx[12], path: `${/*changeSubscriptionPath*/ ctx[10]}?subscription=${/*gift*/ ctx[0].externalId}`, logDlEvent: /*func_2*/ ctx[33] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*changeSubscriptionText*/ 4096) tablink_changes.text = /*changeSubscriptionText*/ ctx[12]; if (dirty[0] & /*changeSubscriptionPath, gift*/ 1025) tablink_changes.path = `${/*changeSubscriptionPath*/ ctx[10]}?subscription=${/*gift*/ ctx[0].externalId}`; if (dirty[0] & /*logChangeSubscription, gift*/ 2097153) tablink_changes.logDlEvent = /*func_2*/ ctx[33]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (142:6) {#if element === 'cancel_subscription' && !elementsHide.cancelSubscription} function create_if_block$a(ctx) { let show_if = /*isActiveStatus*/ ctx[24](/*gift*/ ctx[0].status) && /*cancelSubscriptionText*/ ctx[13]; let if_block_anchor; let current; let if_block = show_if && create_if_block_1$9(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { if (dirty[0] & /*gift, cancelSubscriptionText*/ 8193) show_if = /*isActiveStatus*/ ctx[24](/*gift*/ ctx[0].status) && /*cancelSubscriptionText*/ ctx[13]; if (show_if) { if (if_block) { if_block.p(ctx, dirty); if (dirty[0] & /*gift, cancelSubscriptionText*/ 8193) { transition_in(if_block, 1); } } else { if_block = create_if_block_1$9(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } // (143:8) {#if isActiveStatus(gift.status) && cancelSubscriptionText} function create_if_block_1$9(ctx) { let tablink; let current; tablink = new Tablink({ props: { text: /*cancelSubscriptionText*/ ctx[13], path: `${/*cancelSubscriptionPath*/ ctx[14]}?subscription=${/*gift*/ ctx[0].externalId}`, logDlEvent: /*func_3*/ ctx[34] } }); return { c() { create_component(tablink.$$.fragment); }, m(target, anchor) { mount_component(tablink, target, anchor); current = true; }, p(ctx, dirty) { const tablink_changes = {}; if (dirty[0] & /*cancelSubscriptionText*/ 8192) tablink_changes.text = /*cancelSubscriptionText*/ ctx[13]; if (dirty[0] & /*cancelSubscriptionPath, gift*/ 16385) tablink_changes.path = `${/*cancelSubscriptionPath*/ ctx[14]}?subscription=${/*gift*/ ctx[0].externalId}`; if (dirty[0] & /*logCancelSubscription, gift*/ 4194305) tablink_changes.logDlEvent = /*func_3*/ ctx[34]; tablink.$set(tablink_changes); }, i(local) { if (current) return; transition_in(tablink.$$.fragment, local); current = true; }, o(local) { transition_out(tablink.$$.fragment, local); current = false; }, d(detaching) { destroy_component(tablink, detaching); } }; } // (86:4) {#each elementsOrder as element} function create_each_block$6(ctx) { let t0; let t1; let t2; let t3; let if_block4_anchor; let current; let if_block0 = /*element*/ ctx[35] === 'subscription_information' && !/*elementsHide*/ ctx[16].subscriptionInformation && create_if_block_8(ctx); let if_block1 = /*element*/ ctx[35] === 'billing_history' && !/*elementsHide*/ ctx[16].billingHistory && create_if_block_6$2(ctx); let if_block2 = /*element*/ ctx[35] === 'change_payment' && !/*elementsHide*/ ctx[16].changePayment && create_if_block_4$2(ctx); let if_block3 = /*element*/ ctx[35] === 'change_subscription' && !/*elementsHide*/ ctx[16].changeSubscription && create_if_block_2$6(ctx); let if_block4 = /*element*/ ctx[35] === 'cancel_subscription' && !/*elementsHide*/ ctx[16].cancelSubscription && create_if_block$a(ctx); return { c() { if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); t2 = space(); if (if_block3) if_block3.c(); t3 = space(); if (if_block4) if_block4.c(); if_block4_anchor = empty(); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert(target, t0, anchor); if (if_block1) if_block1.m(target, anchor); insert(target, t1, anchor); if (if_block2) if_block2.m(target, anchor); insert(target, t2, anchor); if (if_block3) if_block3.m(target, anchor); insert(target, t3, anchor); if (if_block4) if_block4.m(target, anchor); insert(target, if_block4_anchor, anchor); current = true; }, p(ctx, dirty) { if (/*element*/ ctx[35] === 'subscription_information' && !/*elementsHide*/ ctx[16].subscriptionInformation) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_8(ctx); if_block0.c(); if_block0.m(t0.parentNode, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*element*/ ctx[35] === 'billing_history' && !/*elementsHide*/ ctx[16].billingHistory) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 196608) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block_6$2(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(t1.parentNode, t1); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } if (/*element*/ ctx[35] === 'change_payment' && !/*elementsHide*/ ctx[16].changePayment) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 196608) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block_4$2(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(t2.parentNode, t2); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } if (/*element*/ ctx[35] === 'change_subscription' && !/*elementsHide*/ ctx[16].changeSubscription) { if (if_block3) { if_block3.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 196608) { transition_in(if_block3, 1); } } else { if_block3 = create_if_block_2$6(ctx); if_block3.c(); transition_in(if_block3, 1); if_block3.m(t3.parentNode, t3); } } else if (if_block3) { group_outros(); transition_out(if_block3, 1, 1, () => { if_block3 = null; }); check_outros(); } if (/*element*/ ctx[35] === 'cancel_subscription' && !/*elementsHide*/ ctx[16].cancelSubscription) { if (if_block4) { if_block4.p(ctx, dirty); if (dirty[0] & /*elementsOrder, elementsHide*/ 196608) { transition_in(if_block4, 1); } } else { if_block4 = create_if_block$a(ctx); if_block4.c(); transition_in(if_block4, 1); if_block4.m(if_block4_anchor.parentNode, if_block4_anchor); } } else if (if_block4) { group_outros(); transition_out(if_block4, 1, 1, () => { if_block4 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block1); transition_in(if_block2); transition_in(if_block3); transition_in(if_block4); current = true; }, o(local) { transition_out(if_block1); transition_out(if_block2); transition_out(if_block3); transition_out(if_block4); current = false; }, d(detaching) { if (detaching) { detach(t0); detach(t1); detach(t2); detach(t3); detach(if_block4_anchor); } if (if_block0) if_block0.d(detaching); if (if_block1) if_block1.d(detaching); if (if_block2) if_block2.d(detaching); if (if_block3) if_block3.d(detaching); if (if_block4) if_block4.d(detaching); } }; } function create_fragment$e(ctx) { let div1; let show_if; let show_if_1; let show_if_2; let show_if_3; let t; let div0; let current; function select_block_type(ctx, dirty) { if (dirty[0] & /*gift, activeBannerText*/ 65) show_if = null; if (dirty[0] & /*gift, cancelledBannerText*/ 129) show_if_1 = null; if (dirty[0] & /*gift, suspendedBannerText*/ 257) show_if_2 = null; if (dirty[0] & /*gift, expiredBannerText*/ 513) show_if_3 = null; if (/*gift*/ ctx[0].status === 'PENDING') return create_if_block_13; if (/*gift*/ ctx[0].status === 'REDEEMED') return create_if_block_14; if (show_if == null) show_if = !!(/*gift*/ ctx[0].status?.toUpperCase() === 'ACTIVE' && /*activeBannerText*/ ctx[6]); if (show_if) return create_if_block_15; if (show_if_1 == null) show_if_1 = !!((/*gift*/ ctx[0].status?.toUpperCase() === 'CANCELLED' || /*gift*/ ctx[0].status?.toUpperCase() === 'CANCELED') && /*cancelledBannerText*/ ctx[7]); if (show_if_1) return create_if_block_16; if (show_if_2 == null) show_if_2 = !!(/*gift*/ ctx[0].status?.toUpperCase() === 'SUSPENDED' && /*suspendedBannerText*/ ctx[8]); if (show_if_2) return create_if_block_17; if (show_if_3 == null) show_if_3 = !!(/*gift*/ ctx[0].status?.toUpperCase() === 'EXPIRED' && /*expiredBannerText*/ ctx[9]); if (show_if_3) return create_if_block_18; } let current_block_type = select_block_type(ctx, [-1, -1]); let if_block = current_block_type && current_block_type(ctx); let each_value = ensure_array_like(/*elementsOrder*/ ctx[17]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { div1 = element("div"); if (if_block) if_block.c(); t = space(); div0 = element("div"); for (let i = 0; i { const statusUpper = status?.toUpperCase(); switch (statusUpper) { case 'ACTIVE': return activeStatusText || status; case 'PENDING': return pendingStatusText || status; case 'CANCELLED': case 'CANCELED': return cancelledStatusText || status; case 'SUSPENDED': return suspendedStatusText || status; case 'EXPIRED': return expiredStatusText || status; default: return status; } }; const isActiveStatus = status => { return status?.toUpperCase() === 'ACTIVE'; }; const canViewBillingHistory = status => { const statusUpper = status?.toUpperCase(); return ['ACTIVE', 'CANCELLED', 'CANCELED', 'EXPIRED', 'SUSPENDED'].includes(statusUpper); }; const func = () => onViewHistory(gift); const func_1 = () => onChangePayment(gift); const func_2 = () => logChangeSubscription(gift); const func_3 = () => logCancelSubscription(gift); $$self.$$set = $$props => { if ('gift' in $$props) $$invalidate(0, gift = $$props.gift); if ('giftRecipientText' in $$props) $$invalidate(1, giftRecipientText = $$props.giftRecipientText); if ('startDateText' in $$props) $$invalidate(2, startDateText = $$props.startDateText); if ('endDateText' in $$props) $$invalidate(3, endDateText = $$props.endDateText); if ('pendingBannerText' in $$props) $$invalidate(4, pendingBannerText = $$props.pendingBannerText); if ('redeemedBannerText' in $$props) $$invalidate(5, redeemedBannerText = $$props.redeemedBannerText); if ('activeBannerText' in $$props) $$invalidate(6, activeBannerText = $$props.activeBannerText); if ('cancelledBannerText' in $$props) $$invalidate(7, cancelledBannerText = $$props.cancelledBannerText); if ('suspendedBannerText' in $$props) $$invalidate(8, suspendedBannerText = $$props.suspendedBannerText); if ('expiredBannerText' in $$props) $$invalidate(9, expiredBannerText = $$props.expiredBannerText); if ('activeStatusText' in $$props) $$invalidate(26, activeStatusText = $$props.activeStatusText); if ('pendingStatusText' in $$props) $$invalidate(27, pendingStatusText = $$props.pendingStatusText); if ('cancelledStatusText' in $$props) $$invalidate(28, cancelledStatusText = $$props.cancelledStatusText); if ('suspendedStatusText' in $$props) $$invalidate(29, suspendedStatusText = $$props.suspendedStatusText); if ('expiredStatusText' in $$props) $$invalidate(30, expiredStatusText = $$props.expiredStatusText); if ('changeSubscriptionPath' in $$props) $$invalidate(10, changeSubscriptionPath = $$props.changeSubscriptionPath); if ('changePaymentMethodText' in $$props) $$invalidate(11, changePaymentMethodText = $$props.changePaymentMethodText); if ('changeSubscriptionText' in $$props) $$invalidate(12, changeSubscriptionText = $$props.changeSubscriptionText); if ('cancelSubscriptionText' in $$props) $$invalidate(13, cancelSubscriptionText = $$props.cancelSubscriptionText); if ('cancelSubscriptionPath' in $$props) $$invalidate(14, cancelSubscriptionPath = $$props.cancelSubscriptionPath); if ('subscriptionTypeText' in $$props) $$invalidate(15, subscriptionTypeText = $$props.subscriptionTypeText); if ('elementsHide' in $$props) $$invalidate(16, elementsHide = $$props.elementsHide); if ('elementsOrder' in $$props) $$invalidate(17, elementsOrder = $$props.elementsOrder); if ('billingHistoryLink' in $$props) $$invalidate(18, billingHistoryLink = $$props.billingHistoryLink); if ('onViewHistory' in $$props) $$invalidate(19, onViewHistory = $$props.onViewHistory); if ('onChangePayment' in $$props) $$invalidate(20, onChangePayment = $$props.onChangePayment); if ('logChangeSubscription' in $$props) $$invalidate(21, logChangeSubscription = $$props.logChangeSubscription); if ('logCancelSubscription' in $$props) $$invalidate(22, logCancelSubscription = $$props.logCancelSubscription); }; return [ gift, giftRecipientText, startDateText, endDateText, pendingBannerText, redeemedBannerText, activeBannerText, cancelledBannerText, suspendedBannerText, expiredBannerText, changeSubscriptionPath, changePaymentMethodText, changeSubscriptionText, cancelSubscriptionText, cancelSubscriptionPath, subscriptionTypeText, elementsHide, elementsOrder, billingHistoryLink, onViewHistory, onChangePayment, logChangeSubscription, logCancelSubscription, getStatusText, isActiveStatus, canViewBillingHistory, activeStatusText, pendingStatusText, cancelledStatusText, suspendedStatusText, expiredStatusText, func, func_1, func_2, func_3 ]; } class GiftSubscriptionsListBoxItem extends SvelteComponent { constructor(options) { super(); init( this, options, instance$e, create_fragment$e, safe_not_equal, { gift: 0, giftRecipientText: 1, startDateText: 2, endDateText: 3, pendingBannerText: 4, redeemedBannerText: 5, activeBannerText: 6, cancelledBannerText: 7, suspendedBannerText: 8, expiredBannerText: 9, activeStatusText: 26, pendingStatusText: 27, cancelledStatusText: 28, suspendedStatusText: 29, expiredStatusText: 30, changeSubscriptionPath: 10, changePaymentMethodText: 11, changeSubscriptionText: 12, cancelSubscriptionText: 13, cancelSubscriptionPath: 14, subscriptionTypeText: 15, elementsHide: 16, elementsOrder: 17, billingHistoryLink: 18, onViewHistory: 19, onChangePayment: 20, logChangeSubscription: 21, logCancelSubscription: 22 }, null, [-1, -1] ); } } /* src/components/elements/giftSubscriptionsList/GiftSubscriptionsList.svelte generated by Svelte v4.2.12 */ function get_each_context$5(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[31] = list[i]; return child_ctx; } // (46:2) {#if loading} function create_if_block_2$5(ctx) { let spinner; let current; spinner = new Spinner({}); return { c() { create_component(spinner.$$.fragment); }, m(target, anchor) { mount_component(spinner, target, anchor); current = true; }, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { destroy_component(spinner, detaching); } }; } // (50:2) {#if !loading && !gifts.length} function create_if_block_1$8(ctx) { let div; let raw_value = (/*noSubscriptionsMessage*/ ctx[1] || /*emptyMessage*/ ctx[0]) + ""; return { c() { div = element("div"); }, m(target, anchor) { insert(target, div, anchor); div.innerHTML = raw_value; }, p(ctx, dirty) { if (dirty[0] & /*noSubscriptionsMessage, emptyMessage*/ 3 && raw_value !== (raw_value = (/*noSubscriptionsMessage*/ ctx[1] || /*emptyMessage*/ ctx[0]) + "")) div.innerHTML = raw_value; }, d(detaching) { if (detaching) { detach(div); } } }; } // (56:2) {#if !loading && gifts.length > 0} function create_if_block$9(ctx) { let each_1_anchor; let current; let each_value = ensure_array_like(/*gifts*/ ctx[3]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { for (let i = 0; i 0 && create_if_block$9(ctx); return { c() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); attr(div, "class", "subscriptions-list-container svelte-ldb1rq"); }, m(target, anchor) { insert(target, div, anchor); if (if_block0) if_block0.m(div, null); append(div, t0); if (if_block1) if_block1.m(div, null); append(div, t1); if (if_block2) if_block2.m(div, null); current = true; }, p(ctx, dirty) { if (/*loading*/ ctx[2]) { if (if_block0) { if (dirty[0] & /*loading*/ 4) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_2$5(); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div, t0); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (!/*loading*/ ctx[2] && !/*gifts*/ ctx[3].length) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_1$8(ctx); if_block1.c(); if_block1.m(div, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (!/*loading*/ ctx[2] && /*gifts*/ ctx[3].length > 0) { if (if_block2) { if_block2.p(ctx, dirty); if (dirty[0] & /*loading, gifts*/ 12) { transition_in(if_block2, 1); } } else { if_block2 = create_if_block$9(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(div, null); } } else if (if_block2) { group_outros(); transition_out(if_block2, 1, 1, () => { if_block2 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block2); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block2); current = false; }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); } }; } function instance$d($$self, $$props, $$invalidate) { let { emptyMessage } = $$props; let { noSubscriptionsMessage } = $$props; let { loading } = $$props; let { gifts = [] } = $$props; let { cancelSubscriptionPath } = $$props; let { changeSubscriptionPath } = $$props; let { onChangePayment } = $$props; let { logChangeSubscription } = $$props; let { logCancelSubscription } = $$props; let { onViewHistory } = $$props; let { changePaymentMethodText } = $$props; let { changeSubscriptionText } = $$props; let { cancelSubscriptionText } = $$props; let { billingHistoryLink } = $$props; let { giftRecipientText } = $$props; let { startDateText } = $$props; let { endDateText } = $$props; let { subscriptionTypeText } = $$props; let { pendingBannerText } = $$props; let { redeemedBannerText } = $$props; let { activeBannerText } = $$props; let { cancelledBannerText } = $$props; let { suspendedBannerText } = $$props; let { expiredBannerText } = $$props; let { activeStatusText } = $$props; let { pendingStatusText } = $$props; let { cancelledStatusText } = $$props; let { suspendedStatusText } = $$props; let { expiredStatusText } = $$props; let { elementsOrder = [] } = $$props; let { elementsHide = { subscriptionInformation: undefined, changePayment: undefined, changeSubscription: undefined, cancelSubscription: undefined, billingHistory: undefined, suspendResumeSubscription: undefined, subscriptionCustomFields: undefined, updateBillToContact: undefined } } = $$props; $$self.$$set = $$props => { if ('emptyMessage' in $$props) $$invalidate(0, emptyMessage = $$props.emptyMessage); if ('noSubscriptionsMessage' in $$props) $$invalidate(1, noSubscriptionsMessage = $$props.noSubscriptionsMessage); if ('loading' in $$props) $$invalidate(2, loading = $$props.loading); if ('gifts' in $$props) $$invalidate(3, gifts = $$props.gifts); if ('cancelSubscriptionPath' in $$props) $$invalidate(4, cancelSubscriptionPath = $$props.cancelSubscriptionPath); if ('changeSubscriptionPath' in $$props) $$invalidate(5, changeSubscriptionPath = $$props.changeSubscriptionPath); if ('onChangePayment' in $$props) $$invalidate(6, onChangePayment = $$props.onChangePayment); if ('logChangeSubscription' in $$props) $$invalidate(7, logChangeSubscription = $$props.logChangeSubscription); if ('logCancelSubscription' in $$props) $$invalidate(8, logCancelSubscription = $$props.logCancelSubscription); if ('onViewHistory' in $$props) $$invalidate(9, onViewHistory = $$props.onViewHistory); if ('changePaymentMethodText' in $$props) $$invalidate(10, changePaymentMethodText = $$props.changePaymentMethodText); if ('changeSubscriptionText' in $$props) $$invalidate(11, changeSubscriptionText = $$props.changeSubscriptionText); if ('cancelSubscriptionText' in $$props) $$invalidate(12, cancelSubscriptionText = $$props.cancelSubscriptionText); if ('billingHistoryLink' in $$props) $$invalidate(13, billingHistoryLink = $$props.billingHistoryLink); if ('giftRecipientText' in $$props) $$invalidate(14, giftRecipientText = $$props.giftRecipientText); if ('startDateText' in $$props) $$invalidate(15, startDateText = $$props.startDateText); if ('endDateText' in $$props) $$invalidate(16, endDateText = $$props.endDateText); if ('subscriptionTypeText' in $$props) $$invalidate(17, subscriptionTypeText = $$props.subscriptionTypeText); if ('pendingBannerText' in $$props) $$invalidate(18, pendingBannerText = $$props.pendingBannerText); if ('redeemedBannerText' in $$props) $$invalidate(19, redeemedBannerText = $$props.redeemedBannerText); if ('activeBannerText' in $$props) $$invalidate(20, activeBannerText = $$props.activeBannerText); if ('cancelledBannerText' in $$props) $$invalidate(21, cancelledBannerText = $$props.cancelledBannerText); if ('suspendedBannerText' in $$props) $$invalidate(22, suspendedBannerText = $$props.suspendedBannerText); if ('expiredBannerText' in $$props) $$invalidate(23, expiredBannerText = $$props.expiredBannerText); if ('activeStatusText' in $$props) $$invalidate(24, activeStatusText = $$props.activeStatusText); if ('pendingStatusText' in $$props) $$invalidate(25, pendingStatusText = $$props.pendingStatusText); if ('cancelledStatusText' in $$props) $$invalidate(26, cancelledStatusText = $$props.cancelledStatusText); if ('suspendedStatusText' in $$props) $$invalidate(27, suspendedStatusText = $$props.suspendedStatusText); if ('expiredStatusText' in $$props) $$invalidate(28, expiredStatusText = $$props.expiredStatusText); if ('elementsOrder' in $$props) $$invalidate(29, elementsOrder = $$props.elementsOrder); if ('elementsHide' in $$props) $$invalidate(30, elementsHide = $$props.elementsHide); }; return [ emptyMessage, noSubscriptionsMessage, loading, gifts, cancelSubscriptionPath, changeSubscriptionPath, onChangePayment, logChangeSubscription, logCancelSubscription, onViewHistory, changePaymentMethodText, changeSubscriptionText, cancelSubscriptionText, billingHistoryLink, giftRecipientText, startDateText, endDateText, subscriptionTypeText, pendingBannerText, redeemedBannerText, activeBannerText, cancelledBannerText, suspendedBannerText, expiredBannerText, activeStatusText, pendingStatusText, cancelledStatusText, suspendedStatusText, expiredStatusText, elementsOrder, elementsHide ]; } class GiftSubscriptionsList extends SvelteComponent { constructor(options) { super(); init( this, options, instance$d, create_fragment$d, safe_not_equal, { emptyMessage: 0, noSubscriptionsMessage: 1, loading: 2, gifts: 3, cancelSubscriptionPath: 4, changeSubscriptionPath: 5, onChangePayment: 6, logChangeSubscription: 7, logCancelSubscription: 8, onViewHistory: 9, changePaymentMethodText: 10, changeSubscriptionText: 11, cancelSubscriptionText: 12, billingHistoryLink: 13, giftRecipientText: 14, startDateText: 15, endDateText: 16, subscriptionTypeText: 17, pendingBannerText: 18, redeemedBannerText: 19, activeBannerText: 20, cancelledBannerText: 21, suspendedBannerText: 22, expiredBannerText: 23, activeStatusText: 24, pendingStatusText: 25, cancelledStatusText: 26, suspendedStatusText: 27, expiredStatusText: 28, elementsOrder: 29, elementsHide: 30 }, null, [-1, -1] ); } } const giftSubscriptionsListFactory = { matches: (sectionElement, _form, _currentPart, _currentSection) => sectionElement.type === elementTypes.GIFT_SUBSCRIPTIONS_LIST, create: (form, formState, formActions, elementConfig) => { // Get all gift subscriptions from form state const giftSubscriptions = formState.giftSubscriptions || []; // filter to only show sent gifts (where user is purchaser) const activeGifts = giftSubscriptions.filter(gift => gift.is_purchaser === true); const logEditSubscription = (gift) => { logDataLayerEvent(form, 'zephr_form_subscription_change_clicked', { productId: gift.subscription_type || 'gift', planId: gift.subscription_number || gift.gift_code || '' }); }; const logCancelSubscription = (gift) => { logDataLayerEvent(form, 'zephr_form_cancel_subscription_clicked', { productId: gift.subscription_type || 'gift', planId: gift.subscription_number || gift.gift_code || '' }); }; // Create elements hide object to match SubscriptionElementsHide const elementsHide = { subscriptionInformation: elementConfig?.hideSubscriptionInformation, changePayment: elementConfig?.hideChangePayment, changeSubscription: elementConfig?.hideChangeSubscription, cancelSubscription: elementConfig?.hideCancelSubscription, suspendResumeSubscription: elementConfig?.hideSuspendResumeSubscription, billingHistory: elementConfig?.hideBillingHistory, subscriptionCustomFields: elementConfig?.hideSubscriptionCustomFields, updateBillToContact: elementConfig?.hideUpdateBillToContact }; const cancelSubscriptionPath = elementConfig.cancelSubscriptionPath || ''; const changePaymentPath = ''; // Default empty string if not available in config return { component: GiftSubscriptionsList, props: { isPastSubscriptions: elementConfig.isPastSubscriptions, billingHistoryText: elementConfig.billingHistoryText, billingHistoryLink: elementConfig.billingHistoryLink, changeSubscriptionPath: elementConfig.changeSubscriptionPath, noSubscriptionsMessage: elementConfig.noSubscriptionsMessage || elementConfig.emptyMessage, emptyMessage: elementConfig.emptyMessage, loading: !formState.giftSubscriptions || formState.loadingGiftSubscriptions, gifts: activeGifts, changePaymentPath, cancelSubscriptionPath, changePaymentMethodText: elementConfig.changePaymentMethodText, changeSubscriptionText: elementConfig.changeSubscriptionText, cancelSubscriptionText: elementConfig.cancelSubscriptionText, giftRecipientText: elementConfig.giftRecipientText, startDateText: elementConfig.startDateText, endDateText: elementConfig.endDateText, pendingBannerText: elementConfig.pendingBannerText, redeemedBannerText: elementConfig.redeemedBannerText, activeBannerText: elementConfig.activeBannerText, cancelledBannerText: elementConfig.cancelledBannerText, suspendedBannerText: elementConfig.suspendedBannerText, expiredBannerText: elementConfig.expiredBannerText, activeStatusText: elementConfig.activeStatusText, pendingStatusText: elementConfig.pendingStatusText, cancelledStatusText: elementConfig.cancelledStatusText, suspendedStatusText: elementConfig.suspendedStatusText, expiredStatusText: elementConfig.expiredStatusText, subscriptionTypeText: elementConfig.subscriptionTypeText, elementsOrder: elementConfig.elementsOrder, elementsHide, onSelectGift: (gift) => { formActions.updateFormState({ selectedGiftSubscription: gift }); formActions.jumpToPartStart('gift-details'); }, onEditSubscription: logEditSubscription, onViewHistory: (subscription) => { formActions.updateFormState({ selectedSubscription: subscription, selectedGiftSubscription: subscription }); formActions.jumpToPartStart('billing-history'); logDataLayerEvent(form, 'zephr_form_billing_history_view', null); }, onCancelSubscription: logCancelSubscription, onChangePayment: (subscription) => { formActions.updateFormState({ selectedSubscription: subscription, selectedGiftSubscription: subscription }); logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); formActions.completeSection(); }, logChangeSubscription: (subscription) => { logDataLayerEvent(form, 'zephr_form_subscription_change_clicked', { productId: subscription.productId, planId: subscription.externalId }); }, logCancelSubscription: (subscription) => { logDataLayerEvent(form, 'zephr_form_cancel_subscription_clicked', { productId: subscription.productId, planId: subscription.externalId }); }, } }; } }; /* src/components/elements/giftToggle/GiftToggle.svelte generated by Svelte v4.2.12 */ function create_fragment$c(ctx) { let div; let checkbox; let current; checkbox = new Checkbox({ props: { id: "gift-toggle-checkbox", name: "gift-toggle", label: /*config*/ ctx[0]?.label || '', value: "true", checked: /*checked*/ ctx[1], disabled: /*disabled*/ ctx[2], required: false } }); checkbox.$on("change", /*handleChange*/ ctx[3]); return { c() { div = element("div"); create_component(checkbox.$$.fragment); attr(div, "class", "zephr-form-gift-toggle svelte-93167f"); }, m(target, anchor) { insert(target, div, anchor); mount_component(checkbox, div, null); current = true; }, p(ctx, [dirty]) { const checkbox_changes = {}; if (dirty & /*config*/ 1) checkbox_changes.label = /*config*/ ctx[0]?.label || ''; if (dirty & /*checked*/ 2) checkbox_changes.checked = /*checked*/ ctx[1]; if (dirty & /*disabled*/ 4) checkbox_changes.disabled = /*disabled*/ ctx[2]; checkbox.$set(checkbox_changes); }, i(local) { if (current) return; transition_in(checkbox.$$.fragment, local); current = true; }, o(local) { transition_out(checkbox.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(checkbox); } }; } function instance$c($$self, $$props, $$invalidate) { let { config } = $$props; let { checked = false } = $$props; let { disabled = false } = $$props; let { onChange } = $$props; const handleChange = event => { const isChecked = event.detail; onChange(isChecked); }; $$self.$$set = $$props => { if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('checked' in $$props) $$invalidate(1, checked = $$props.checked); if ('disabled' in $$props) $$invalidate(2, disabled = $$props.disabled); if ('onChange' in $$props) $$invalidate(4, onChange = $$props.onChange); }; return [config, checked, disabled, handleChange, onChange]; } class GiftToggle extends SvelteComponent { constructor(options) { super(); init(this, options, instance$c, create_fragment$c, safe_not_equal, { config: 0, checked: 1, disabled: 2, onChange: 4 }); } } const giftToggleFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.GIFT_TOGGLE, create: (form, formState, formActions, elementConfig) => { // Only show if enabled if (!elementConfig.enabled) { return null; } const handleToggleChange = (isChecked) => { const previousIsGiftForm = formState.isGiftForm; formActions.updateFormState({ isGiftForm: isChecked }); if (!isChecked && previousIsGiftForm) { // When deselecting gift mode, only navigate if we're on gift-specific sections if (formState.currentSection.type === 'recipient_details' && formState.giftTogglePreviousSection) { // If on recipient details, go back to where they were before enabling gift mode formActions.jumpToSection(formState.giftTogglePreviousSection); } // If on any other section (email, password, payment), stay on current section // Clear the stored section formActions.updateFormState({ giftTogglePreviousSection: undefined }); } else if (isChecked && !previousIsGiftForm) { // When enabling gift mode, always store current section (update it each time) formActions.updateFormState({ giftTogglePreviousSection: formState.currentSection.type }); // Check if recipient details are valid before jumping const recipientDetailsElementTypes = [ elementTypes.RECIPIENT_NAME, elementTypes.RECIPIENT_EMAIL, elementTypes.RECIPIENT_ADDRESS, elementTypes.RECIPIENT_MESSAGE ]; // Check if all recipient details elements are valid const recipientDetailsValid = recipientDetailsElementTypes.every(elementType => { const elementValidity = formState.elementValidity.find(e => e.elementType === elementType && e.sectionType === 'recipient_details'); return elementValidity ? elementValidity.isValid : false; }); // Only jump to recipient details if they are not valid if (!recipientDetailsValid) { formActions.jumpToSection('recipient_details'); } // If recipient details are valid, stay on current step } logDataLayerEvent(form, 'zephr_form_input_change', { field: 'gift-toggle', inputName: 'gift-toggle-checkbox', sectionId: formState.currentSection.type, }); }; return { component: GiftToggle, props: { config: elementConfig, checked: formState.isGiftForm || false, disabled: formState.isBusy || formState.paymentProviderFormBusy || false, onChange: handleToggleChange, }, isValid: true, }; }, }; /* src/components/elements/giftFutureDateToggle/GiftFutureDateToggle.svelte generated by Svelte v4.2.12 */ function create_if_block$8(ctx) { let p; let t_value = /*config*/ ctx[0].description + ""; let t; return { c() { p = element("p"); t = text(t_value); attr(p, "class", "zephr-form-gift-future-date-toggle-description svelte-c9nudz"); }, m(target, anchor) { insert(target, p, anchor); append(p, t); }, p(ctx, dirty) { if (dirty & /*config*/ 1 && t_value !== (t_value = /*config*/ ctx[0].description + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(p); } } }; } function create_fragment$b(ctx) { let div; let checkbox; let t; let current; checkbox = new Checkbox({ props: { id: "gift-future-date-toggle-checkbox", name: "gift-future-date-toggle", label: /*config*/ ctx[0]?.label || '', value: "true", checked: /*checked*/ ctx[1], disabled: /*disabled*/ ctx[2], required: false } }); checkbox.$on("change", /*handleChange*/ ctx[3]); let if_block = /*config*/ ctx[0]?.description && create_if_block$8(ctx); return { c() { div = element("div"); create_component(checkbox.$$.fragment); t = space(); if (if_block) if_block.c(); attr(div, "class", "zephr-form-gift-future-date-toggle svelte-c9nudz"); }, m(target, anchor) { insert(target, div, anchor); mount_component(checkbox, div, null); append(div, t); if (if_block) if_block.m(div, null); current = true; }, p(ctx, [dirty]) { const checkbox_changes = {}; if (dirty & /*config*/ 1) checkbox_changes.label = /*config*/ ctx[0]?.label || ''; if (dirty & /*checked*/ 2) checkbox_changes.checked = /*checked*/ ctx[1]; if (dirty & /*disabled*/ 4) checkbox_changes.disabled = /*disabled*/ ctx[2]; checkbox.$set(checkbox_changes); if (/*config*/ ctx[0]?.description) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block$8(ctx); if_block.c(); if_block.m(div, null); } } else if (if_block) { if_block.d(1); if_block = null; } }, i(local) { if (current) return; transition_in(checkbox.$$.fragment, local); current = true; }, o(local) { transition_out(checkbox.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(checkbox); if (if_block) if_block.d(); } }; } function instance$b($$self, $$props, $$invalidate) { let { config } = $$props; let { checked = false } = $$props; let { disabled = false } = $$props; let { onChange } = $$props; const handleChange = event => { const isChecked = event.detail; onChange(isChecked); }; $$self.$$set = $$props => { if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('checked' in $$props) $$invalidate(1, checked = $$props.checked); if ('disabled' in $$props) $$invalidate(2, disabled = $$props.disabled); if ('onChange' in $$props) $$invalidate(4, onChange = $$props.onChange); }; return [config, checked, disabled, handleChange, onChange]; } class GiftFutureDateToggle extends SvelteComponent { constructor(options) { super(); init(this, options, instance$b, create_fragment$b, safe_not_equal, { config: 0, checked: 1, disabled: 2, onChange: 4 }); } } const giftFutureDateToggleFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.GIFT_FUTURE_DATE_TOGGLE, create: (form, formState, formActions, elementConfig) => { // Only show if enabled and in gift mode if (!elementConfig.enabled || !formState.isGiftForm) { return null; } const handleToggleChange = (isChecked) => { formActions.updateFormState({ giftRecipient: { ...formState.giftRecipient, futureDeliveryEnabled: isChecked, // Clear the date if toggling off futureDeliveryDate: isChecked ? formState.giftRecipient?.futureDeliveryDate || '' : '' } }); logDataLayerEvent(form, 'zephr_form_input_change', { field: 'gift-future-date-toggle', inputName: 'gift-future-date-toggle-checkbox', sectionId: formState.currentSection.type, }); }; return { component: GiftFutureDateToggle, props: { config: elementConfig, checked: formState.giftRecipient?.futureDeliveryEnabled || false, disabled: formState.isBusy || formState.paymentProviderFormBusy || false, onChange: handleToggleChange, }, isValid: true, }; }, }; /* src/components/elements/giftFutureDateInput/GiftFutureDateInput.svelte generated by Svelte v4.2.12 */ function create_if_block_1$7(ctx) { let label; let current; label = new Label({ props: { for: "gift-future-date-input", required: /*config*/ ctx[0].required || false, $$slots: { default: [create_default_slot$1] }, $$scope: { ctx } } }); return { c() { create_component(label.$$.fragment); }, m(target, anchor) { mount_component(label, target, anchor); current = true; }, p(ctx, dirty) { const label_changes = {}; if (dirty & /*config*/ 1) label_changes.required = /*config*/ ctx[0].required || false; if (dirty & /*$$scope, config*/ 513) { label_changes.$$scope = { dirty, ctx }; } label.$set(label_changes); }, i(local) { if (current) return; transition_in(label.$$.fragment, local); current = true; }, o(local) { transition_out(label.$$.fragment, local); current = false; }, d(detaching) { destroy_component(label, detaching); } }; } // (25:4) function create_default_slot$1(ctx) { let t_value = /*config*/ ctx[0].label + ""; let t; return { c() { t = text(t_value); }, m(target, anchor) { insert(target, t, anchor); }, p(ctx, dirty) { if (dirty & /*config*/ 1 && t_value !== (t_value = /*config*/ ctx[0].label + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(t); } } }; } // (47:2) {#if config?.description} function create_if_block$7(ctx) { let p; let t_value = /*config*/ ctx[0].description + ""; let t; return { c() { p = element("p"); t = text(t_value); attr(p, "class", "zephr-form-gift-future-date-input-description svelte-1vykgtl"); }, m(target, anchor) { insert(target, p, anchor); append(p, t); }, p(ctx, dirty) { if (dirty & /*config*/ 1 && t_value !== (t_value = /*config*/ ctx[0].description + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(p); } } }; } function create_fragment$a(ctx) { let div; let t0; let input; let t1; let current; let if_block0 = /*config*/ ctx[0]?.label && create_if_block_1$7(ctx); input = new Input({ props: { id: "gift-future-date-input", name: "gift-future-date", type: "date", value: /*value*/ ctx[1], disabled: /*disabled*/ ctx[2], hasError: /*hasError*/ ctx[3], errorMessage: /*errorMessage*/ ctx[4], placeholder: /*config*/ ctx[0]?.placeholder || '', required: /*config*/ ctx[0]?.required || false, min: /*minDate*/ ctx[6] } }); input.$on("change", /*handleChange*/ ctx[5]); let if_block1 = /*config*/ ctx[0]?.description && create_if_block$7(ctx); return { c() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); create_component(input.$$.fragment); t1 = space(); if (if_block1) if_block1.c(); attr(div, "class", "zephr-form-gift-future-date-input svelte-1vykgtl"); }, m(target, anchor) { insert(target, div, anchor); if (if_block0) if_block0.m(div, null); append(div, t0); mount_component(input, div, null); append(div, t1); if (if_block1) if_block1.m(div, null); current = true; }, p(ctx, [dirty]) { if (/*config*/ ctx[0]?.label) { if (if_block0) { if_block0.p(ctx, dirty); if (dirty & /*config*/ 1) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_1$7(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div, t0); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } const input_changes = {}; if (dirty & /*value*/ 2) input_changes.value = /*value*/ ctx[1]; if (dirty & /*disabled*/ 4) input_changes.disabled = /*disabled*/ ctx[2]; if (dirty & /*hasError*/ 8) input_changes.hasError = /*hasError*/ ctx[3]; if (dirty & /*errorMessage*/ 16) input_changes.errorMessage = /*errorMessage*/ ctx[4]; if (dirty & /*config*/ 1) input_changes.placeholder = /*config*/ ctx[0]?.placeholder || ''; if (dirty & /*config*/ 1) input_changes.required = /*config*/ ctx[0]?.required || false; input.$set(input_changes); if (/*config*/ ctx[0]?.description) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$7(ctx); if_block1.c(); if_block1.m(div, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, i(local) { if (current) return; transition_in(if_block0); transition_in(input.$$.fragment, local); current = true; }, o(local) { transition_out(if_block0); transition_out(input.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); destroy_component(input); if (if_block1) if_block1.d(); } }; } function instance$a($$self, $$props, $$invalidate) { let { config } = $$props; let { value = '' } = $$props; let { disabled = false } = $$props; let { hasError = false } = $$props; let { errorMessage = '' } = $$props; let { onChange } = $$props; // Calculate tomorrow's date in YYYY-MM-DD format const getTomorrowDate = () => { const tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); return tomorrow.toISOString().split('T')[0]; }; const handleChange = event => { const inputValue = event.detail; onChange(inputValue); }; // Set minimum date to tomorrow const minDate = getTomorrowDate(); $$self.$$set = $$props => { if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('value' in $$props) $$invalidate(1, value = $$props.value); if ('disabled' in $$props) $$invalidate(2, disabled = $$props.disabled); if ('hasError' in $$props) $$invalidate(3, hasError = $$props.hasError); if ('errorMessage' in $$props) $$invalidate(4, errorMessage = $$props.errorMessage); if ('onChange' in $$props) $$invalidate(7, onChange = $$props.onChange); }; return [ config, value, disabled, hasError, errorMessage, handleChange, minDate, onChange ]; } class GiftFutureDateInput extends SvelteComponent { constructor(options) { super(); init(this, options, instance$a, create_fragment$a, safe_not_equal, { config: 0, value: 1, disabled: 2, hasError: 3, errorMessage: 4, onChange: 7 }); } } const giftFutureDateInputFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.GIFT_FUTURE_DATE_INPUT, create: (form, formState, formActions, elementConfig) => { // Only show if enabled, in gift mode, and future delivery is enabled if (!elementConfig.enabled || !formState.isGiftForm || !formState.giftRecipient?.futureDeliveryEnabled) { return null; } // Validation function const validateDate = (value) => { if (!value) { return resolveLanguagePackKeyTyped(form, 'forms.errors.future-delivery-date-required', 'Please select a future delivery date'); } if (value) { const selectedDate = new Date(value); const tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setHours(0, 0, 0, 0); // Reset time for date comparison if (selectedDate { formActions.updateFormState({ giftRecipient: { ...formState.giftRecipient, futureDeliveryDate: value } }); logDataLayerEvent(form, 'zephr_form_input_change', { field: 'gift-future-date', inputName: 'gift-future-date-input', sectionId: formState.currentSection.type, }); }; const currentValue = formState.giftRecipient?.futureDeliveryDate || ''; const errorMessage = validateDate(currentValue); const isValid = !errorMessage; return { component: GiftFutureDateInput, props: { config: elementConfig, value: currentValue, disabled: formState.isBusy || formState.paymentProviderFormBusy || false, hasError: !isValid, errorMessage: errorMessage || '', onChange: handleChange, }, isValid, }; }, }; /* src/components/elements/suspendResumeSubscription/SuspendResumeSubscription.svelte generated by Svelte v4.2.12 */ function create_if_block_2$4(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*suspensionDateError*/ ctx[3]); attr(div, "class", "error-text svelte-1hog2jr"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*suspensionDateError*/ 8) set_data(t, /*suspensionDateError*/ ctx[3]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (88:6) {#if resumeDateError} function create_if_block_1$6(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*resumeDateError*/ ctx[4]); attr(div, "class", "error-text svelte-1hog2jr"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*resumeDateError*/ 16) set_data(t, /*resumeDateError*/ ctx[4]); }, d(detaching) { if (detaching) { detach(div); } } }; } // (92:4) {#if generalError} function create_if_block$6(ctx) { let div; let t; return { c() { div = element("div"); t = text(/*generalError*/ ctx[5]); attr(div, "class", "error-text svelte-1hog2jr"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*generalError*/ 32) set_data(t, /*generalError*/ ctx[5]); }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$9(ctx) { let div2; let div0; let label0; let t0_value = /*config*/ ctx[0].suspensionDateLabel + ""; let t0; let t1; let input0; let t2; let t3; let div1; let label1; let t4_value = /*config*/ ctx[0].resumeDateLabel + ""; let t4; let t5; let input1; let t6; let t7; let mounted; let dispose; let if_block0 = /*suspensionDateError*/ ctx[3] && create_if_block_2$4(ctx); let if_block1 = /*resumeDateError*/ ctx[4] && create_if_block_1$6(ctx); let if_block2 = /*generalError*/ ctx[5] && create_if_block$6(ctx); return { c() { div2 = element("div"); div0 = element("div"); label0 = element("label"); t0 = text(t0_value); t1 = space(); input0 = element("input"); t2 = space(); if (if_block0) if_block0.c(); t3 = space(); div1 = element("div"); label1 = element("label"); t4 = text(t4_value); t5 = space(); input1 = element("input"); t6 = space(); if (if_block1) if_block1.c(); t7 = space(); if (if_block2) if_block2.c(); attr(label0, "for", "suspensionDate"); attr(label0, "class", "svelte-1hog2jr"); attr(input0, "id", "suspensionDate"); attr(input0, "type", "date"); input0.required = true; attr(input0, "class", "svelte-1hog2jr"); toggle_class(input0, "error", !!/*suspensionDateError*/ ctx[3]); attr(div0, "class", "field svelte-1hog2jr"); attr(label1, "for", "resumeDate"); attr(label1, "class", "svelte-1hog2jr"); attr(input1, "id", "resumeDate"); attr(input1, "type", "date"); input1.required = true; attr(input1, "class", "svelte-1hog2jr"); toggle_class(input1, "error", !!/*resumeDateError*/ ctx[4]); attr(div1, "class", "field svelte-1hog2jr"); attr(div2, "class", "suspend-resume-subscription-section svelte-1hog2jr"); }, m(target, anchor) { insert(target, div2, anchor); append(div2, div0); append(div0, label0); append(label0, t0); append(div0, t1); append(div0, input0); set_input_value(input0, /*suspensionDate*/ ctx[1]); append(div0, t2); if (if_block0) if_block0.m(div0, null); append(div2, t3); append(div2, div1); append(div1, label1); append(label1, t4); append(div1, t5); append(div1, input1); set_input_value(input1, /*resumeDate*/ ctx[2]); append(div1, t6); if (if_block1) if_block1.m(div1, null); append(div2, t7); if (if_block2) if_block2.m(div2, null); if (!mounted) { dispose = [ listen(input0, "input", /*input0_input_handler*/ ctx[9]), listen(input0, "input", /*updateSuspendResumeSubscription*/ ctx[6]), listen(input1, "input", /*input1_input_handler*/ ctx[10]), listen(input1, "input", /*updateSuspendResumeSubscription*/ ctx[6]) ]; mounted = true; } }, p(ctx, [dirty]) { if (dirty & /*config*/ 1 && t0_value !== (t0_value = /*config*/ ctx[0].suspensionDateLabel + "")) set_data(t0, t0_value); if (dirty & /*suspensionDate*/ 2) { set_input_value(input0, /*suspensionDate*/ ctx[1]); } if (dirty & /*suspensionDateError*/ 8) { toggle_class(input0, "error", !!/*suspensionDateError*/ ctx[3]); } if (/*suspensionDateError*/ ctx[3]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_2$4(ctx); if_block0.c(); if_block0.m(div0, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (dirty & /*config*/ 1 && t4_value !== (t4_value = /*config*/ ctx[0].resumeDateLabel + "")) set_data(t4, t4_value); if (dirty & /*resumeDate*/ 4) { set_input_value(input1, /*resumeDate*/ ctx[2]); } if (dirty & /*resumeDateError*/ 16) { toggle_class(input1, "error", !!/*resumeDateError*/ ctx[4]); } if (/*resumeDateError*/ ctx[4]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_1$6(ctx); if_block1.c(); if_block1.m(div1, null); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (/*generalError*/ ctx[5]) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block$6(ctx); if_block2.c(); if_block2.m(div2, null); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div2); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); mounted = false; run_all(dispose); } }; } function instance$9($$self, $$props, $$invalidate) { let { formState } = $$props; let { formActions } = $$props; let { config } = $$props; const dispatch = createEventDispatcher(); let suspensionDate = formState.suspendResumeSubscription?.suspensionDate || ''; let resumeDate = formState.suspendResumeSubscription?.resumeDate || ''; let suspensionDateError = ''; let resumeDateError = ''; let generalError = ''; // Update form state when input changes const updateSuspendResumeSubscription = () => { const updatedSuspendResumeSubscription = { ...formState.suspendResumeSubscription || {}, suspensionDate, resumeDate }; formActions.updateFormState({ suspendResumeSubscription: updatedSuspendResumeSubscription }); validateForm(); }; const validateForm = () => { const hasValidSuspensionDate = !!suspensionDate.trim(); const hasValidResumeDate = !!resumeDate.trim(); const today = new Date(); today.setHours(0, 0, 0, 0); // Reset time to start of day for accurate comparison const suspensionDateObj = new Date(suspensionDate); const resumeDateObj = new Date(resumeDate); const isSuspensionDateInPast = hasValidSuspensionDate && suspensionDateObj { validateForm(); }); function input0_input_handler() { suspensionDate = this.value; $$invalidate(1, suspensionDate); } function input1_input_handler() { resumeDate = this.value; $$invalidate(2, resumeDate); } $$self.$$set = $$props => { if ('formState' in $$props) $$invalidate(7, formState = $$props.formState); if ('formActions' in $$props) $$invalidate(8, formActions = $$props.formActions); if ('config' in $$props) $$invalidate(0, config = $$props.config); }; return [ config, suspensionDate, resumeDate, suspensionDateError, resumeDateError, generalError, updateSuspendResumeSubscription, formState, formActions, input0_input_handler, input1_input_handler ]; } class SuspendResumeSubscription extends SvelteComponent { constructor(options) { super(); init(this, options, instance$9, create_fragment$9, safe_not_equal, { formState: 7, formActions: 8, config: 0 }); } } const suspendResumeSubscriptionFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.SUSPEND_RESUME_SUBSCRIPTION, create: (form, formState, formActions, elementConfig) => { // Resolve all labels through language pack service const resolvedConfig = { suspensionDateLabel: resolveLanguagePackKeyTyped(form, 'forms.suspend-resume-subscription.suspension-date-label', elementConfig.suspensionDateLabel), resumeDateLabel: resolveLanguagePackKeyTyped(form, 'forms.suspend-resume-subscription.resume-date-label', elementConfig.resumeDateLabel), }; // Determine if the input is valid const suspendResumeSubscription = (formState.suspendResumeSubscription || {}); const hasValidSuspensionDate = !!suspendResumeSubscription.suspensionDate?.trim(); const hasValidResumeDate = !!suspendResumeSubscription.resumeDate?.trim(); // Check if suspension date is in the past const today = new Date(); today.setHours(0, 0, 0, 0); // Reset time to start of day for accurate comparison const suspensionDateObj = new Date(suspendResumeSubscription.suspensionDate); const isSuspensionDateInPast = hasValidSuspensionDate && suspensionDateObj 0 && create_if_block_2$3(ctx); return { c() { form = element("form"); for (let i = 0; i 0) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block_2$3(ctx); if_block2.c(); if_block2.m(form, null); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } }, d(detaching) { if (detaching) { detach(form); } destroy_each(each_blocks, detaching); if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); mounted = false; dispose(); } }; } // (150:2) {#if loading} function create_if_block$5(ctx) { let div; return { c() { div = element("div"); div.textContent = "Loading custom fields..."; attr(div, "class", "loading svelte-uox0m2"); }, m(target, anchor) { insert(target, div, anchor); }, p: noop, d(detaching) { if (detaching) { detach(div); } } }; } // (158:10) {#each group.fields as field} function create_each_block_1$1(ctx) { let div; let label; let t0_value = /*field*/ ctx[34].label + ""; let t0; let label_for_value; let t1; let input; let input_id_value; let input_name_value; let input_value_value; let input_disabled_value; let mounted; let dispose; function input_handler(...args) { return /*input_handler*/ ctx[20](/*field*/ ctx[34], ...args); } return { c() { div = element("div"); label = element("label"); t0 = text(t0_value); t1 = space(); input = element("input"); attr(label, "for", label_for_value = /*field*/ ctx[34].name); attr(label, "class", "field-label svelte-uox0m2"); attr(input, "id", input_id_value = /*field*/ ctx[34].name); attr(input, "name", input_name_value = /*field*/ ctx[34].name); attr(input, "type", "text"); input.value = input_value_value = /*fieldValues*/ ctx[8][/*field*/ ctx[34].name]; input.disabled = input_disabled_value = !/*isFieldEditable*/ ctx[12](/*field*/ ctx[34].name); attr(input, "class", "field-input svelte-uox0m2"); attr(div, "class", "field-item svelte-uox0m2"); }, m(target, anchor) { insert(target, div, anchor); append(div, label); append(label, t0); append(div, t1); append(div, input); if (!mounted) { dispose = listen(input, "input", input_handler); mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; if (dirty[0] & /*activeFieldGroups*/ 512 && t0_value !== (t0_value = /*field*/ ctx[34].label + "")) set_data(t0, t0_value); if (dirty[0] & /*activeFieldGroups*/ 512 && label_for_value !== (label_for_value = /*field*/ ctx[34].name)) { attr(label, "for", label_for_value); } if (dirty[0] & /*activeFieldGroups*/ 512 && input_id_value !== (input_id_value = /*field*/ ctx[34].name)) { attr(input, "id", input_id_value); } if (dirty[0] & /*activeFieldGroups*/ 512 && input_name_value !== (input_name_value = /*field*/ ctx[34].name)) { attr(input, "name", input_name_value); } if (dirty[0] & /*fieldValues, activeFieldGroups*/ 768 && input_value_value !== (input_value_value = /*fieldValues*/ ctx[8][/*field*/ ctx[34].name]) && input.value !== input_value_value) { input.value = input_value_value; } if (dirty[0] & /*activeFieldGroups*/ 512 && input_disabled_value !== (input_disabled_value = !/*isFieldEditable*/ ctx[12](/*field*/ ctx[34].name))) { input.disabled = input_disabled_value; } }, d(detaching) { if (detaching) { detach(div); } mounted = false; dispose(); } }; } // (156:6) {#each activeFieldGroups as [_groupKey, group]} function create_each_block$4(ctx) { let div; let t; let each_value_1 = ensure_array_like(/*group*/ ctx[31].fields); let each_blocks = []; for (let i = 0; i 0} function create_if_block_2$3(ctx) { let div; let button; let t_value = (/*submitting*/ ctx[11] ? 'Updating...' : /*loading*/ ctx[5] ? 'Loading...' : /*submitButtonText*/ ctx[4]) + ""; let t; let button_disabled_value; return { c() { div = element("div"); button = element("button"); t = text(t_value); attr(button, "type", "submit"); attr(button, "class", "submit-button svelte-uox0m2"); button.disabled = button_disabled_value = /*loading*/ ctx[5] || /*submitting*/ ctx[11] || !/*hasChanges*/ ctx[10]; attr(div, "class", "form-actions svelte-uox0m2"); }, m(target, anchor) { insert(target, div, anchor); append(div, button); append(button, t); }, p(ctx, dirty) { if (dirty[0] & /*submitting, loading, submitButtonText*/ 2096 && t_value !== (t_value = (/*submitting*/ ctx[11] ? 'Updating...' : /*loading*/ ctx[5] ? 'Loading...' : /*submitButtonText*/ ctx[4]) + "")) set_data(t, t_value); if (dirty[0] & /*loading, submitting, hasChanges*/ 3104 && button_disabled_value !== (button_disabled_value = /*loading*/ ctx[5] || /*submitting*/ ctx[11] || !/*hasChanges*/ ctx[10])) { button.disabled = button_disabled_value; } }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$8(ctx) { let div; let t0; let t1; let if_block0 = /*formTitle*/ ctx[2] && create_if_block_6$1(ctx); let if_block1 = /*formDescription*/ ctx[3] && create_if_block_5$1(ctx); function select_block_type(ctx, dirty) { if (/*loading*/ ctx[5]) return create_if_block$5; if (/*customFields*/ ctx[0] && /*customFields*/ ctx[0].length > 0) return create_if_block_1$5; } let current_block_type = select_block_type(ctx); let if_block2 = current_block_type && current_block_type(ctx); return { c() { div = element("div"); if (if_block0) if_block0.c(); t0 = space(); if (if_block1) if_block1.c(); t1 = space(); if (if_block2) if_block2.c(); attr(div, "class", "subscription-custom-fields-container svelte-uox0m2"); }, m(target, anchor) { insert(target, div, anchor); if (if_block0) if_block0.m(div, null); append(div, t0); if (if_block1) if_block1.m(div, null); append(div, t1); if (if_block2) if_block2.m(div, null); }, p(ctx, dirty) { if (/*formTitle*/ ctx[2]) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_6$1(ctx); if_block0.c(); if_block0.m(div, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*formDescription*/ ctx[3]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_5$1(ctx); if_block1.c(); if_block1.m(div, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block2) { if_block2.p(ctx, dirty); } else { if (if_block2) if_block2.d(1); if_block2 = current_block_type && current_block_type(ctx); if (if_block2) { if_block2.c(); if_block2.m(div, null); } } }, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) { if_block2.d(); } } }; } function instance$8($$self, $$props, $$invalidate) { let hasChanges; let changedFields; let fieldGroups; let activeFieldGroups; let { customFields } = $$props; let { editableFieldNames } = $$props; let { formTitle } = $$props; let { formDescription } = $$props; let { submitButtonText } = $$props; let { onUpdateCustomFields } = $$props; let { loading = false } = $$props; // New props for API call states let submitting = false; let successMessage = ''; let errorMessage = ''; let fieldValues = {}; let originalFieldValues = {}; // Track original values to detect changes // Custom validation function that only validates sections with changes const validateChangedSections = () => { // Custom fields don't have validation requirements return []; }; // Initialize/reset form values when component mounts or custom fields change let lastCustomFieldsLength = 0; // eslint-disable-next-line no-inner-declarations function initializeFormValues() { // Reset/initialize field values to original values $$invalidate(8, fieldValues = {}); $$invalidate(16, originalFieldValues = {}); customFields.forEach(field => { const originalValue = field.value || ''; $$invalidate(8, fieldValues[field.name] = originalValue, fieldValues); $$invalidate(16, originalFieldValues[field.name] = originalValue, originalFieldValues); }); // Clear any messages and states $$invalidate(6, successMessage = ''); $$invalidate(7, errorMessage = ''); $$invalidate(11, submitting = false); } // Check if a field is editable const isFieldEditable = fieldName => { return editableFieldNames.includes(fieldName); }; const handleSubmit = async () => { // Validate only the sections that have changes const validationErrors = validateChangedSections(); if (validationErrors.length > 0) { $$invalidate(7, errorMessage = validationErrors.join(', ')); return; } $$invalidate(11, submitting = true); $$invalidate(6, successMessage = ''); $$invalidate(7, errorMessage = ''); try { // Only send the fields that have actually changed const changedFieldValues = {}; changedFields.forEach(fieldName => { changedFieldValues[fieldName] = fieldValues[fieldName]; }); await onUpdateCustomFields(changedFieldValues); $$invalidate(6, successMessage = 'Successfully updated subscription details!'); // Clear all input boxes after successful update Object.keys(fieldValues).forEach(fieldName => { $$invalidate(8, fieldValues[fieldName] = '', fieldValues); $$invalidate(16, originalFieldValues[fieldName] = '', originalFieldValues); }); // Clear success message after 5 seconds setTimeout( () => { $$invalidate(6, successMessage = ''); }, 5000 ); } catch(error) { $$invalidate(7, errorMessage = error.message || 'Failed to update subscription details. Please try again.'); } finally { $$invalidate(11, submitting = false); } }; const handleFieldChange = (fieldName, value) => { $$invalidate(8, fieldValues[fieldName] = value, fieldValues); }; const handleInputEvent = (fieldName, event) => { handleFieldChange(fieldName, event.target.value); }; const addressFieldNames = [ 'DeliveryAddressLine1__c', 'DeliveryAddressLine2__c', 'DeliveryCity__c', 'DeliveryPostcode__c', 'DeliveryZipcode__c', 'DeliveryState__c', 'DeliveryCountry__c' ]; addressFieldNames.some(name => isFieldEditable(name)); addressFieldNames.some(name => fieldValues[name]); const input_handler = (field, e) => handleInputEvent(field.name, e); $$self.$$set = $$props => { if ('customFields' in $$props) $$invalidate(0, customFields = $$props.customFields); if ('editableFieldNames' in $$props) $$invalidate(1, editableFieldNames = $$props.editableFieldNames); if ('formTitle' in $$props) $$invalidate(2, formTitle = $$props.formTitle); if ('formDescription' in $$props) $$invalidate(3, formDescription = $$props.formDescription); if ('submitButtonText' in $$props) $$invalidate(4, submitButtonText = $$props.submitButtonText); if ('onUpdateCustomFields' in $$props) $$invalidate(15, onUpdateCustomFields = $$props.onUpdateCustomFields); if ('loading' in $$props) $$invalidate(5, loading = $$props.loading); }; $$self.$$.update = () => { if ($$self.$$.dirty[0] & /*fieldValues, originalFieldValues*/ 65792) { // Check if any field values have been modified $$invalidate(10, hasChanges = Object.keys(fieldValues).some(key => { const current = fieldValues[key]; const original = originalFieldValues[key]; // Handle array values (multiselect) if (Array.isArray(current) && Array.isArray(original)) { return JSON.stringify(current.sort()) !== JSON.stringify(original.sort()); } // Handle regular values return current !== original; })); } if ($$self.$$.dirty[0] & /*fieldValues, originalFieldValues*/ 65792) { // Get the fields that have been changed (and thus the sections that should be validated) $$invalidate(19, changedFields = Object.keys(fieldValues).filter(key => { const current = fieldValues[key]; const original = originalFieldValues[key]; // Handle array values (multiselect) if (Array.isArray(current) && Array.isArray(original)) { return JSON.stringify(current.sort()) !== JSON.stringify(original.sort()); } // Handle regular values return current !== original; })); } if ($$self.$$.dirty[0] & /*customFields*/ 1) { // Group fields by category - include all fields for display $$invalidate(18, fieldGroups = { all: { fields: customFields || [] } }); } if ($$self.$$.dirty[0] & /*fieldGroups*/ 262144) { // Get only field groups that have fields $$invalidate(9, activeFieldGroups = Object.entries(fieldGroups).filter(([_key, group]) => group.fields.length > 0)); } if ($$self.$$.dirty[0] & /*activeFieldGroups, changedFields*/ 524800) { // Get the sections that have changes and need validation activeFieldGroups.filter(([_groupKey, group]) => { return group.fields.some(field => changedFields.includes(field.name)); }); } if ($$self.$$.dirty[0] & /*hasChanges, successMessage, errorMessage*/ 1216) { // Clear messages when user starts making changes if (hasChanges && (successMessage || errorMessage)) { $$invalidate(6, successMessage = ''); $$invalidate(7, errorMessage = ''); } } if ($$self.$$.dirty[0] & /*customFields, lastCustomFieldsLength*/ 131073) { if (customFields && customFields.length !== lastCustomFieldsLength) { initializeFormValues(); $$invalidate(17, lastCustomFieldsLength = customFields.length); } } }; return [ customFields, editableFieldNames, formTitle, formDescription, submitButtonText, loading, successMessage, errorMessage, fieldValues, activeFieldGroups, hasChanges, submitting, isFieldEditable, handleSubmit, handleInputEvent, onUpdateCustomFields, originalFieldValues, lastCustomFieldsLength, fieldGroups, changedFields, input_handler ]; } class SubscriptionCustomFieldsList extends SvelteComponent { constructor(options) { super(); init( this, options, instance$8, create_fragment$8, safe_not_equal, { customFields: 0, editableFieldNames: 1, formTitle: 2, formDescription: 3, submitButtonText: 4, onUpdateCustomFields: 15, loading: 5 }, null, [-1, -1] ); } } const subscriptionCustomFieldsListFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.SUBSCRIPTION_CUSTOM_FIELDS_LIST, create: (form, formState, formActions, elementConfig) => { // Get the selected subscription's custom fields data const selectedSubscription = formState.selectedSubscription || formState.existingSubscriptions?.[0]; // Create custom fields array from field definitions and subscription data // Include all field definitions so both read-only and editable fields are available const customFields = (elementConfig.customFieldDefinitions || []).map(fieldDef => ({ ...fieldDef, value: selectedSubscription?.[fieldDef.name] || '' })); return { component: SubscriptionCustomFieldsList, props: { customFields, editableFieldNames: elementConfig.enabledCustomFields || [], formTitle: elementConfig.formTitle || 'Update Subscription Details', formDescription: elementConfig.formDescription || 'Update your subscription information below', submitButtonText: elementConfig.submitButtonText || 'Update Details', loading: formState.loadingSubscriptionCustomFields || false, onBack: () => { // Navigate back to the main subscription list formActions.jumpToPartStart(partTypes.LIST_SUBSCRIPTIONS.type); }, onUpdateCustomFields: async (fieldValues) => { // Check if we have a selected subscription with ID if (!selectedSubscription?.externalId) { throw new Error('No subscription selected for update'); } // Check if we have accountId for ownership verification if (!selectedSubscription?.accountId) { throw new Error('Subscription account information is missing. Please try again.'); } const subscriptionId = selectedSubscription.externalId; const accountId = selectedSubscription.accountId; // Set loading state formActions.updateFormState({ loadingSubscriptionCustomFields: true }); // Handle preview mode with mock API response if (form.environment?.previewMode) { // Simulate API delay await new Promise(resolve => setTimeout(resolve, 1000)); // Update form state with the new values formActions.updateFormState({ selectedSubscription: { ...selectedSubscription, ...fieldValues }, loadingSubscriptionCustomFields: false }); // Return mock success response return { success: true, message: 'Custom fields updated successfully (preview mode)' }; } try { // Make real API call to update subscription custom fields const response = await fetch(`/zephr/subscriptions/${subscriptionId}/custom-fields`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ accountId: accountId, // Required for backend ownership verification customFields: fieldValues }) }); if (!response.ok) { const errorData = await response.json().catch(() => ({})); throw new Error(errorData.message || `Failed to update subscription: ${response.status} ${response.statusText}`); } const result = await response.json(); // Update form state with the new values formActions.updateFormState({ selectedSubscription: { ...selectedSubscription, ...fieldValues }, loadingSubscriptionCustomFields: false }); // Return success - the component will handle showing success message return result; } catch (error) { console.error('Error updating subscription custom fields:', error); // Clear loading state on error formActions.updateFormState({ loadingSubscriptionCustomFields: false }); throw error; // Re-throw so component can handle it } } } }; } }; // TODO: This is a temporary list of countries that are accepted by Zuora. // We need to get this from the Contact metadata endpoint. const ZUORA_BILLING_COUNTRIES = [ "Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bonaire, Saint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kosovo", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, the former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthelemy", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe" ]; /* src/components/elements/billToContact/BillToContact.svelte generated by Svelte v4.2.12 */ function get_each_context$3(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[19] = list[i]; return child_ctx; } // (70:6) {#each ZUORA_BILLING_COUNTRIES as country} function create_each_block$3(ctx) { let option; let t0; let t1; let option_selected_value; return { c() { option = element("option"); t0 = text(/*country*/ ctx[19]); t1 = space(); option.__value = /*country*/ ctx[19]; set_input_value(option, option.__value); option.selected = option_selected_value = /*billToContact*/ ctx[0].country === /*country*/ ctx[19]; }, m(target, anchor) { insert(target, option, anchor); append(option, t0); append(option, t1); }, p(ctx, dirty) { if (dirty & /*billToContact*/ 1 && option_selected_value !== (option_selected_value = /*billToContact*/ ctx[0].country === /*country*/ ctx[19])) { option.selected = option_selected_value; } }, d(detaching) { if (detaching) { detach(option); } } }; } // (90:4) {#if errors["address1"]} function create_if_block_6(ctx) { let div; let t_value = /*errors*/ ctx[1]["address1"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["address1"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (104:4) {#if errors["address2"]} function create_if_block_5(ctx) { let div; let t_value = /*errors*/ ctx[1]["address2"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["address2"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (118:4) {#if errors["city"]} function create_if_block_4(ctx) { let div; let t_value = /*errors*/ ctx[1]["city"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["city"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (132:4) {#if errors["state"]} function create_if_block_3$1(ctx) { let div; let t_value = /*errors*/ ctx[1]["state"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["state"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (146:4) {#if errors["zipCode"]} function create_if_block_2$2(ctx) { let div; let t_value = /*errors*/ ctx[1]["zipCode"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["zipCode"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (160:4) {#if errors["county"]} function create_if_block_1$4(ctx) { let div; let t_value = /*errors*/ ctx[1]["county"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["county"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (174:4) {#if errors["taxRegion"]} function create_if_block$4(ctx) { let div; let t_value = /*errors*/ ctx[1]["taxRegion"] + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "error-text svelte-z564ap"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*errors*/ 2 && t_value !== (t_value = /*errors*/ ctx[1]["taxRegion"] + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } function create_fragment$7(ctx) { let div8; let div0; let label0; let t1; let select; let option; let select_value_value; let t3; let div1; let label1; let t5; let input0; let t6; let t7; let div2; let label2; let t9; let input1; let t10; let t11; let div3; let label3; let t13; let input2; let t14; let t15; let div4; let label4; let t17; let input3; let t18; let t19; let div5; let label5; let t21; let input4; let t22; let t23; let div6; let label6; let t25; let input5; let t26; let t27; let div7; let label7; let t29; let input6; let t30; let mounted; let dispose; let each_value = ensure_array_like(ZUORA_BILLING_COUNTRIES); let each_blocks = []; for (let i = 0; i { formActions.updateFormState({ billToContact }); validateForm(); }; const onCountrySelect = e => { $$invalidate(0, billToContact.country = e.target.value, billToContact); updateSuspendResumeSubscription(); }; const validateForm = () => { // Reset errors $$invalidate(1, errors = {}); if (!!billToContact.address1 && billToContact.address1.length > 255) { $$invalidate(1, errors["address1"] = "Address 1 should be 255 characters or less", errors); } if (!!billToContact.address2 && billToContact.address2.length > 255) { $$invalidate(1, errors["address2"] = "Address 2 should be 255 characters or less", errors); } if (!!billToContact.city && billToContact.city.length > 40) { $$invalidate(1, errors["city"] = "City should be 40 characters or less", errors); } if (!!billToContact.county && billToContact.county.length > 32) { $$invalidate(1, errors["county"] = "County should be 32 characters or less", errors); } if (!!billToContact.zipCode && billToContact.zipCode.length > 20) { $$invalidate(1, errors["zipCode"] = "Postal code should be 20 characters or less", errors); } // Dispatch event for form validity const isValid = Object.keys(errors).length === 0; dispatch("validity", { isValid }); }; function input0_input_handler() { billToContact.address1 = this.value; $$invalidate(0, billToContact); } function input1_input_handler() { billToContact.address2 = this.value; $$invalidate(0, billToContact); } function input2_input_handler() { billToContact.city = this.value; $$invalidate(0, billToContact); } function input3_input_handler() { billToContact.state = this.value; $$invalidate(0, billToContact); } function input4_input_handler() { billToContact.zipCode = this.value; $$invalidate(0, billToContact); } function input5_input_handler() { billToContact.county = this.value; $$invalidate(0, billToContact); } function input6_input_handler() { billToContact.taxRegion = this.value; $$invalidate(0, billToContact); } $$self.$$set = $$props => { if ('formState' in $$props) $$invalidate(4, formState = $$props.formState); if ('formActions' in $$props) $$invalidate(5, formActions = $$props.formActions); if ('form' in $$props) $$invalidate(6, form = $$props.form); }; return [ billToContact, errors, updateSuspendResumeSubscription, onCountrySelect, formState, formActions, form, input0_input_handler, input1_input_handler, input2_input_handler, input3_input_handler, input4_input_handler, input5_input_handler, input6_input_handler ]; } class BillToContact extends SvelteComponent { constructor(options) { super(); init(this, options, instance$7, create_fragment$7, safe_not_equal, { formState: 4, formActions: 5, form: 6 }); } } const billToContactFactory = { matches: (sectionElement) => sectionElement.type === elementTypes.BILL_TO_CONTACT, create: (form, formState, formActions) => { return { component: BillToContact, props: { form, formState, formActions, } }; } }; const factory$3 = { matches: (sectionElement) => sectionElement.type === elementTypes.BILLING_COUNTRY, create: (form, formState, formActions, elementConfig) => { const disabled = elementConfig.disabled || formState.isBusy; // Only show for zuora-billing payment provider AND when countryLabel is configured if (form.organisationConfiguration.paymentProvider !== 'zuora-billing') { return null; } const paymentConfig = formConfigAs(form); // Don't render if countryLabel is not configured in admin console if (!paymentConfig.countryLabel) { return null; } const configuredLabel = paymentConfig.countryLabel || elementConfig.label || "Country"; return ({ component: BillingCountry, props: { formKey: form.uniqueKey, config: { ...elementConfig, label: configuredLabel }, value: formState.billingCountry || "", disabled, onChange: (value) => { if (!disabled) { formActions.updateFormState({ billingCountry: value, // Clear state when country changes (always clear to avoid US/CA state conflicts) billingState: "", serverErrors: [] }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: `zephr-form-billing-country-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'billing_country' }); } }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: `zephr-form-billing-country-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'billing_country' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: `zephr-form-billing-country-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'billing_country' }), isPaymentForm: form.formType === FormType.PAYMENT, }, isValid: !elementConfig.required || !!formState.billingCountry }); } }; const factory$2 = { matches: (sectionElement) => sectionElement.type === elementTypes.BILLING_STATE, create: (form, formState, formActions, elementConfig) => { const disabled = elementConfig.disabled || formState.isBusy; // Only show for zuora-billing payment provider AND when stateLabel is configured if (form.organisationConfiguration.paymentProvider !== 'zuora-billing') { return null; } const paymentConfig = formConfigAs(form); // Don't render if stateLabel is not configured in admin console if (!paymentConfig.stateLabel) { return null; } const configuredLabel = paymentConfig.stateLabel || elementConfig.label || "State"; return ({ component: BillingState, props: { formKey: form.uniqueKey, config: { ...elementConfig, label: configuredLabel }, value: formState.billingState || "", billingCountry: formState.billingCountry || "", disabled, onChange: (value) => { if (!disabled) { formActions.updateFormState({ billingState: value, serverErrors: [] }); logDataLayerEvent(form, 'zephr_form_input_change', { inputName: `zephr-form-billing-state-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'billing_state' }); } }, onFocus: () => logDataLayerEvent(form, 'zephr_form_input_focus', { inputName: `zephr-form-billing-state-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'billing_state' }), onBlur: () => logDataLayerEvent(form, 'zephr_form_input_blur', { inputName: `zephr-form-billing-state-${form.uniqueKey}`, sectionId: formState.currentSection.type, field: 'billing_state' }), isPaymentForm: form.formType === FormType.PAYMENT, }, isValid: !elementConfig.required || (formState.billingCountry === "US" || formState.billingCountry === "CA" ? !!formState.billingState : true) // Not required if country is not US or CA }); } }; /* src/components/elements/catalogPaymentOptionSelection/CatalogPaymentOptionComponent.svelte generated by Svelte v4.2.12 */ function get_each_context$2(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[6] = list[i]; return child_ctx; } function get_each_context_1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[6] = list[i]; return child_ctx; } // (18:6) {#if paymentOption.highlightedText} function create_if_block_2$1(ctx) { let div; let t_value = /*paymentOption*/ ctx[1].highlightedText + ""; let t; return { c() { div = element("div"); t = text(t_value); attr(div, "class", "box-top-text svelte-24yv85"); }, m(target, anchor) { insert(target, div, anchor); append(div, t); }, p(ctx, dirty) { if (dirty & /*paymentOption*/ 2 && t_value !== (t_value = /*paymentOption*/ ctx[1].highlightedText + "")) set_data(t, t_value); }, d(detaching) { if (detaching) { detach(div); } } }; } // (28:6) {#if discountPercentages.length > 0 || discountAmounts.length > 0} function create_if_block_1$3(ctx) { let ul; let t; let each_value_1 = ensure_array_like(/*discountPercentages*/ ctx[4]); let each_blocks_1 = []; for (let i = 0; i 0 || /*discountAmounts*/ ctx[3].length > 0) && create_if_block_1$3(ctx); button = new Button({ props: { disabled: false, text: /*paymentOption*/ ctx[1].selectButtonText ?? 'Select Plan', onClick: /*onSelect*/ ctx[0], isPaymentForm: true } }); let if_block2 = /*paymentOption*/ ctx[1].disclaimerMessage && create_if_block$3(ctx); return { c() { div6 = element("div"); div5 = element("div"); div0 = element("div"); if (if_block0) if_block0.c(); t0 = space(); div4 = element("div"); div1 = element("div"); span0 = element("span"); t1 = text(t1_value); t2 = space(); span1 = element("span"); t3 = text(/*formattedPrice*/ ctx[5]); t4 = space(); if (if_block1) if_block1.c(); t5 = space(); div2 = element("div"); t6 = space(); div3 = element("div"); create_component(button.$$.fragment); t7 = space(); if (if_block2) if_block2.c(); attr(div0, "class", "box-top svelte-24yv85"); attr(span0, "class", "plan-name svelte-24yv85"); attr(span1, "class", "plan-price svelte-24yv85"); attr(div1, "class", "plan-header svelte-24yv85"); attr(div2, "class", "box-content svelte-24yv85"); toggle_class(div2, "styled-box-content", /*styleDescription*/ ctx[2]); attr(div3, "class", "box-bottom svelte-24yv85"); attr(div4, "class", div4_class_value = "inner-box " + (/*paymentOption*/ ctx[1].highlightedText || '') + " svelte-24yv85"); attr(div5, "class", div5_class_value = "box-container " + (/*paymentOption*/ ctx[1].highlightedText ? 'highlighted' : '') + " svelte-24yv85"); attr(div6, "class", "payment-option-wrapper svelte-24yv85"); }, m(target, anchor) { insert(target, div6, anchor); append(div6, div5); append(div5, div0); if (if_block0) if_block0.m(div0, null); append(div5, t0); append(div5, div4); append(div4, div1); append(div1, span0); append(span0, t1); append(div1, t2); append(div1, span1); append(span1, t3); append(div4, t4); if (if_block1) if_block1.m(div4, null); append(div4, t5); append(div4, div2); div2.innerHTML = raw_value; append(div4, t6); append(div4, div3); mount_component(button, div3, null); append(div3, t7); if (if_block2) if_block2.m(div3, null); current = true; }, p(ctx, [dirty]) { if (/*paymentOption*/ ctx[1].highlightedText) { if (if_block0) { if_block0.p(ctx, dirty); } else { if_block0 = create_if_block_2$1(ctx); if_block0.c(); if_block0.m(div0, null); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if ((!current || dirty & /*paymentOption*/ 2) && t1_value !== (t1_value = /*paymentOption*/ ctx[1].label + "")) set_data(t1, t1_value); if (!current || dirty & /*formattedPrice*/ 32) set_data(t3, /*formattedPrice*/ ctx[5]); if (/*discountPercentages*/ ctx[4].length > 0 || /*discountAmounts*/ ctx[3].length > 0) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block_1$3(ctx); if_block1.c(); if_block1.m(div4, t5); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if ((!current || dirty & /*paymentOption*/ 2) && raw_value !== (raw_value = (/*paymentOption*/ ctx[1].description ?? '') + "")) div2.innerHTML = raw_value; if (!current || dirty & /*styleDescription*/ 4) { toggle_class(div2, "styled-box-content", /*styleDescription*/ ctx[2]); } const button_changes = {}; if (dirty & /*paymentOption*/ 2) button_changes.text = /*paymentOption*/ ctx[1].selectButtonText ?? 'Select Plan'; if (dirty & /*onSelect*/ 1) button_changes.onClick = /*onSelect*/ ctx[0]; button.$set(button_changes); if (/*paymentOption*/ ctx[1].disclaimerMessage) { if (if_block2) { if_block2.p(ctx, dirty); } else { if_block2 = create_if_block$3(ctx); if_block2.c(); if_block2.m(div3, null); } } else if (if_block2) { if_block2.d(1); if_block2 = null; } if (!current || dirty & /*paymentOption*/ 2 && div4_class_value !== (div4_class_value = "inner-box " + (/*paymentOption*/ ctx[1].highlightedText || '') + " svelte-24yv85")) { attr(div4, "class", div4_class_value); } if (!current || dirty & /*paymentOption*/ 2 && div5_class_value !== (div5_class_value = "box-container " + (/*paymentOption*/ ctx[1].highlightedText ? 'highlighted' : '') + " svelte-24yv85")) { attr(div5, "class", div5_class_value); } }, i(local) { if (current) return; transition_in(button.$$.fragment, local); current = true; }, o(local) { transition_out(button.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div6); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); destroy_component(button); if (if_block2) if_block2.d(); } }; } function instance$6($$self, $$props, $$invalidate) { let formattedPrice; let discountPercentages; let discountAmounts; let { onSelect } = $$props; let { paymentOption } = $$props; let { styleDescription } = $$props; $$self.$$set = $$props => { if ('onSelect' in $$props) $$invalidate(0, onSelect = $$props.onSelect); if ('paymentOption' in $$props) $$invalidate(1, paymentOption = $$props.paymentOption); if ('styleDescription' in $$props) $$invalidate(2, styleDescription = $$props.styleDescription); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*paymentOption*/ 2) { $$invalidate(5, formattedPrice = formatCurrency(paymentOption.price, paymentOption.currencyCode)); } if ($$self.$$.dirty & /*paymentOption*/ 2) { $$invalidate(4, discountPercentages = paymentOption.discountPercentages ?? []); } if ($$self.$$.dirty & /*paymentOption*/ 2) { $$invalidate(3, discountAmounts = paymentOption.discountAmounts ?? []); } }; return [ onSelect, paymentOption, styleDescription, discountAmounts, discountPercentages, formattedPrice ]; } class CatalogPaymentOptionComponent extends SvelteComponent { constructor(options) { super(); init(this, options, instance$6, create_fragment$6, safe_not_equal, { onSelect: 0, paymentOption: 1, styleDescription: 2 }); } } /* src/components/elements/catalogPaymentOptionSelection/CatalogPaymentOptionSelectionComponent.svelte generated by Svelte v4.2.12 */ function get_each_context$1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[9] = list[i]; return child_ctx; } // (21:4) {#if loading} function create_if_block_1$2(ctx) { let spinner; let current; spinner = new Spinner({}); return { c() { create_component(spinner.$$.fragment); }, m(target, anchor) { mount_component(spinner, target, anchor); current = true; }, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { destroy_component(spinner, detaching); } }; } // (24:2) {#if !loading} function create_if_block$2(ctx) { let each_1_anchor; let current; let each_value = ensure_array_like(/*orderedPaymentOptions*/ ctx[3]); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { for (let i = 0; i { if_block0 = null; }); check_outros(); } if (!/*loading*/ ctx[2]) { if (if_block1) { if_block1.p(ctx, dirty); if (dirty & /*loading*/ 4) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block$2(ctx); if_block1.c(); transition_in(if_block1, 1); if_block1.m(div, null); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); } }; } function instance$5($$self, $$props, $$invalidate) { let orderedPaymentOptions; let { paymentOptions } = $$props; let { config } = $$props; let { onSelect } = $$props; let { logView } = $$props; let { hasCatalogRule } = $$props; let { loading } = $$props; // ensure the payment options are only logged once let hasLoggedView = false; const func = paymentOption => onSelect(paymentOption); $$self.$$set = $$props => { if ('paymentOptions' in $$props) $$invalidate(4, paymentOptions = $$props.paymentOptions); if ('config' in $$props) $$invalidate(0, config = $$props.config); if ('onSelect' in $$props) $$invalidate(1, onSelect = $$props.onSelect); if ('logView' in $$props) $$invalidate(5, logView = $$props.logView); if ('hasCatalogRule' in $$props) $$invalidate(6, hasCatalogRule = $$props.hasCatalogRule); if ('loading' in $$props) $$invalidate(2, loading = $$props.loading); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*paymentOptions*/ 16) { $$invalidate(3, orderedPaymentOptions = [...paymentOptions].sort((a, b) => a.fieldOrder - b.fieldOrder)); } if ($$self.$$.dirty & /*hasLoggedView, hasCatalogRule, loading, logView*/ 228) { if (!hasLoggedView && (hasCatalogRule ? loading === false : true)) { $$invalidate(7, hasLoggedView = true); logView(); } } }; return [ config, onSelect, loading, orderedPaymentOptions, paymentOptions, logView, hasCatalogRule, hasLoggedView, func ]; } class CatalogPaymentOptionSelectionComponent extends SvelteComponent { constructor(options) { super(); init(this, options, instance$5, create_fragment$5, safe_not_equal, { paymentOptions: 4, config: 0, onSelect: 1, logView: 5, hasCatalogRule: 6, loading: 2 }); } } const filterValidPaymentOptions = (form, formState, paymentOptions) => { if (!formConfigAs(form).changeSubscriptionMode) { return paymentOptions; } return paymentOptions .filter(paymentOption => formState .validChangeFromPlans .some(validPlan => validPlan.planSlug === paymentOption.slug)); }; const getPaymentOptions = (form, formState) => { let paymentOptions; if (formState.catalogRulePaymentOptions) { paymentOptions = formState.catalogRulePaymentOptions; } else { paymentOptions = formConfigAs(form).paymentOptions; } return filterValidPaymentOptions(form, formState, paymentOptions); }; const factory$1 = { matches: (sectionElement) => sectionElement.type === elementTypes.CATALOG_PAYMENT_OPTION_SELECTION, create: (form, formState, formActions, elementConfig) => ({ component: CatalogPaymentOptionSelectionComponent, props: { paymentOptions: getPaymentOptions(form, formState), config: elementConfig ? elementConfig : {}, loading: formState.loadingCatalogPlans, hasCatalogRule: !!formConfigAs(form).catalogRule?.id || !!formConfigAs(form).catalogRulePreview, onSelect: (paymentOption) => { const paymentOptionKey = `${paymentOption.productId}-${paymentOption.slug}`; const updateState = { paymentOption: { ...paymentOption, autoRenewConfig: paymentOption.autoRenewConfig, autoRenewToggleLabel: paymentOption.autoRenewToggleLabel }, serverErrors: [], billingAddress: { country: null, postalCode: null, } }; // Only initialize auto-renew state for payment options with custom_toggle config if (paymentOption.autoRenewConfig === 'custom_toggle') { updateState.paymentOptionAutoRenew = { ...formState.paymentOptionAutoRenew, [paymentOptionKey]: paymentOption.terms?.autoRenew ?? false }; } formActions.updateFormState(updateState); if (form.organisationConfiguration.trackFormDataLayerEvents) { logDataLayerEvent(form, 'zephr_form_button_press', { sectionId: formState.currentSection.type, buttonType: 'SUBMIT' }); } void formActions.completeSection(); }, logView: () => { getPaymentOptions(form, formState).forEach(paymentOption => logDataLayerEvent(form, 'view_item', { ecommerce: { currency: formConfigAs(form).formCurrency ?? paymentOption?.currencyCode, value: paymentOption.price, items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOption.price, quantity: 1 }] } })); } } }) }; const SCRIPT_URL = 'https://www.google.com/recaptcha/enterprise.js?onload=onRecaptchaLoaded&render=explicit'; let scriptLoaded = false; let ready = false; const pendingCallbacks = []; function loadRecaptchaScript() { if (scriptLoaded) return; scriptLoaded = true; window.onRecaptchaLoaded = () => { ready = true; pendingCallbacks.forEach(cb => cb()); pendingCallbacks.length = 0; }; const script = document.createElement('script'); script.src = SCRIPT_URL; script.async = true; script.defer = true; document.head.appendChild(script); } function onRecaptchaReady(callback) { if (ready) { callback(); } else { pendingCallbacks.push(callback); } } /* src/components/elements/recaptcha/RecaptchaWidget.svelte generated by Svelte v4.2.12 */ function create_fragment$4(ctx) { let div; return { c() { div = element("div"); attr(div, "class", "zephr-recaptcha-container"); }, m(target, anchor) { insert(target, div, anchor); /*div_binding*/ ctx[4](div); }, p: noop, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } /*div_binding*/ ctx[4](null); } }; } function instance$4($$self, $$props, $$invalidate) { let { siteKey } = $$props; let { onSuccess } = $$props; let { onExpired } = $$props; let widgetId = null; let containerEl; const renderWidget = () => { if (window.grecaptcha?.enterprise && containerEl && widgetId === null) { widgetId = window.grecaptcha.enterprise.render(containerEl, { sitekey: siteKey, callback: onSuccess, 'expired-callback': onExpired }); } }; onMount(() => { loadRecaptchaScript(); onRecaptchaReady(renderWidget); }); onDestroy(() => { if (widgetId !== null && window.grecaptcha?.enterprise) { window.grecaptcha.enterprise.reset(widgetId); } }); function div_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { containerEl = $$value; $$invalidate(0, containerEl); }); } $$self.$$set = $$props => { if ('siteKey' in $$props) $$invalidate(1, siteKey = $$props.siteKey); if ('onSuccess' in $$props) $$invalidate(2, onSuccess = $$props.onSuccess); if ('onExpired' in $$props) $$invalidate(3, onExpired = $$props.onExpired); }; return [containerEl, siteKey, onSuccess, onExpired, div_binding]; } class RecaptchaWidget extends SvelteComponent { constructor(options) { super(); init(this, options, instance$4, create_fragment$4, safe_not_equal, { siteKey: 1, onSuccess: 2, onExpired: 3 }); } } const factory = { matches: (sectionElement) => sectionElement.type === elementTypes.RECAPTCHA, create: (form, formState, formActions) => { const siteKey = form.organisationConfiguration.recaptchaV2SiteKey; if (!form.organisationConfiguration.recaptchaV2Enabled || !siteKey) { return null; } const onSuccess = (token) => { formActions.updateFormState({ recaptchaCompleted: true, recaptchaToken: token, }); formActions.completeSection(); }; const onExpired = () => { formActions.updateFormState({ recaptchaCompleted: false, recaptchaToken: undefined, }); formActions.jumpToSection(sectionTypes.RECAPTCHA.type); }; return { component: RecaptchaWidget, props: { siteKey, onSuccess, onExpired }, }; } }; const elementFactories = [ factory$w, factory$v, factory$u, factory$t, factory$s, factory$r, factory$q, factory$p, paymentAutoRenewToggleFactory, factory$o, factory$n, factory$m, factory$l, factory$k, factory$j, factory$i, factory$h, factory$g, factory$f, factory$e, factory$d, factory$c, factory$b, factory$a, factory$9, subscriptionSelectFactory, subscriptionsListFactory, pastSubscriptionsLinkFactory, changePaymentMethodButtonFactory, eventLinkFactory, factory$8, factory$7, readOnlyUserAttributeFactory, deviceSessionsFactory, deviceSessionsSignOutAll, billingHistoryFactory, factory$6, factory$5, recipientNameFactory, recipientEmailFactory, recipientAddressFactory, recipientMessageFactory, factory$4, giftSubscriptionsListFactory, giftToggleFactory, giftFutureDateToggleFactory, giftFutureDateInputFactory, suspendResumeSubscriptionFactory, subscriptionCustomFieldsUpdateFactory, subscriptionCustomFieldsListFactory, billToContactFactory, factory$3, factory$2, factory$1, factory, ]; /* src/components/ElementResolver.svelte generated by Svelte v4.2.12 */ function create_if_block$1(ctx) { let switch_instance; let t; let if_block_anchor; let current; const switch_instance_spread_levels = [ /*enrichPropsWithServerError*/ ctx[4](/*element*/ ctx[2].props, /*formState*/ ctx[0], /*sectionElement*/ ctx[1]) ]; var switch_value = /*element*/ ctx[2].component; function switch_props(ctx, dirty) { let switch_instance_props = {}; for (let i = 0; i { destroy_component(old_component, 1); }); check_outros(); } if (switch_value) { switch_instance = construct_svelte_component(switch_value, switch_props(ctx, dirty)); create_component(switch_instance.$$.fragment); transition_in(switch_instance.$$.fragment, 1); mount_component(switch_instance, t.parentNode, t); } else { switch_instance = null; } } else if (switch_value) { const switch_instance_changes = (dirty & /*enrichPropsWithServerError, element, formState, sectionElement*/ 23) ? get_spread_update(switch_instance_spread_levels, [ get_spread_object(/*enrichPropsWithServerError*/ ctx[4](/*element*/ ctx[2].props, /*formState*/ ctx[0], /*sectionElement*/ ctx[1])) ]) : {}; switch_instance.$set(switch_instance_changes); } if (/*element*/ ctx[2].isValid === false && /*formState*/ ctx[0].showFieldErrors) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*element, formState*/ 5) { transition_in(if_block, 1); } } else { if_block = create_if_block_1$1(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; if (switch_instance) transition_in(switch_instance.$$.fragment, local); transition_in(if_block); current = true; }, o(local) { if (switch_instance) transition_out(switch_instance.$$.fragment, local); transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(t); detach(if_block_anchor); } if (switch_instance) destroy_component(switch_instance, detaching); if (if_block) if_block.d(detaching); } }; } // (61:2) {#if element.isValid === false && formState.showFieldErrors} function create_if_block_1$1(ctx) { let errormessage; let current; errormessage = new ErrorMessage({ props: { error: "Field is invalid", isPaymentForm: /*isPaymentForm*/ ctx[3] } }); return { c() { create_component(errormessage.$$.fragment); }, m(target, anchor) { mount_component(errormessage, target, anchor); current = true; }, p: noop, i(local) { if (current) return; transition_in(errormessage.$$.fragment, local); current = true; }, o(local) { transition_out(errormessage.$$.fragment, local); current = false; }, d(detaching) { destroy_component(errormessage, detaching); } }; } function create_fragment$3(ctx) { let if_block_anchor; let current; let if_block = /*element*/ ctx[2] && create_if_block$1(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { if (/*element*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*element*/ 4) { transition_in(if_block, 1); } } else { if_block = create_if_block$1(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(if_block_anchor); } if (if_block) if_block.d(detaching); } }; } function instance$3($$self, $$props, $$invalidate) { let element; let { form } = $$props; let { formActions } = $$props; let isPaymentForm = form.formType === "PAYMENT"; let { formState } = $$props; let { sectionElement } = $$props; const enrichPropsWithServerError = (props, _formState, _sectionElement) => { const serverErrorForElementValue = serverErrorForElement(_sectionElement.type, _formState); const error = ServerErrors[serverErrorForElementValue]; if (error) { // send message to app saying payment form has errored const formErrorMessage = { error: ServerError[serverErrorForElementValue], errorMessage: resolveErrorLanguagePackKey(form, serverErrorForElementValue), success: false, formSlug: form.id }; const formEventPayload = JSON.stringify(formErrorMessage); // handle ios message window?.webkit?.messageHandlers?.messageHandler?.postMessage(formEventPayload); // handle android message window?.AndroidFormEventListener?.processFormEvent(formEventPayload); } return error ? { ...element.props, error: element.props.error ?? (error.useDymamicMessage ? _formState.dynamicServerErrorMessage : resolveErrorLanguagePackKey(form, serverErrorForElementValue)) } : props; }; const buildElement = (_formState, _sectionElement) => { if (_sectionElement.config?.enabled === false || _sectionElement.hidden === true) { return null; } const factory = elementFactories.find(f => f.matches(_sectionElement, form, _formState.currentPart, _formState.currentSection)); if (!factory) { throw `Unknown element ${JSON.stringify(_sectionElement)}`; } const element = factory.create(form, _formState, formActions, _sectionElement.config); updateElementValidity(element, _formState, _sectionElement, formActions); return element; }; $$self.$$set = $$props => { if ('form' in $$props) $$invalidate(5, form = $$props.form); if ('formActions' in $$props) $$invalidate(6, formActions = $$props.formActions); if ('formState' in $$props) $$invalidate(0, formState = $$props.formState); if ('sectionElement' in $$props) $$invalidate(1, sectionElement = $$props.sectionElement); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*formState, sectionElement*/ 3) { $$invalidate(2, element = buildElement(formState, sectionElement)); } }; return [ formState, sectionElement, element, isPaymentForm, enrichPropsWithServerError, form, formActions ]; } class ElementResolver extends SvelteComponent { constructor(options) { super(); init(this, options, instance$3, create_fragment$3, safe_not_equal, { form: 5, formActions: 6, formState: 0, sectionElement: 1 }); } } const extractDefaultUserAttributes = (form) => form.parts .flatMap((p) => p.sections) .flatMap((s) => s.elements) .filter((e) => e.type === elementTypes.USER_ATTRIBUTE) .map(e => e.config) .reduce((attributes, config) => { const schemafield = form.organisationConfiguration.schemaFields.find(s => s.slug === config.slug); if (schemafield) { return { ...attributes, [config.slug]: (config.defaultValue || (schemafield["select-options"]?.find(o => o.default)?.value)) ?? undefined }; } else { return { ...attributes }; } }, {}); /** * Sort all items in the Form by their order properties */ const sortForm = (form) => ({ ...form, parts: form.parts .sort((a, b) => partTypeFor(a.type).order - partTypeFor(b.type).order) .map((p) => ({ ...p, sections: p.sections .sort((a, b) => a.order - b.order) .map((s) => ({ ...s, elements: s.elements.sort((a, b) => a.order - b.order), })), })) }); const addFormProcessorsToWindow = () => { if (!window.Blaize) { window.Blaize = { formPreProcessors: {}, formPostProcessors: {}, registerFormPreProcessor: function (formSlug, processor) { if (!window.Blaize.formPreProcessors[formSlug]) window.Blaize.formPreProcessors[formSlug] = []; if (typeof processor === "function") { window.Blaize.formPreProcessors[formSlug].push(processor); } }, registerFormPostProcessor: function (formSlug, processor) { if (!window.Blaize.formPostProcessors[formSlug]) window.Blaize.formPostProcessors[formSlug] = []; if (typeof processor === "function") { window.Blaize.formPostProcessors[formSlug].push(processor); } }, preProcessFormData: function (formSlug, formData) { if (window.Blaize.formPreProcessors[formSlug] || window.Blaize.formPreProcessors["*"]) { const processors = []; if (window.Blaize.formPreProcessors["*"]) { window.Blaize.formPreProcessors["*"].forEach(function (processor) { processors.push(processor); }); } if (window.Blaize.formPreProcessors[formSlug]) { window.Blaize.formPreProcessors[formSlug].forEach(function (processor) { processors.push(processor); }); } processors.forEach(function (processor) { const processedFormData = processor(formData); if (processedFormData != undefined) { formData = processedFormData; } }); } return formData; }, postProcessFormData: function (formSlug, formData, response) { if (window.Blaize.formPostProcessors[formSlug] || window.Blaize.formPostProcessors["*"]) { const processors = []; if (window.Blaize.formPostProcessors["*"]) { window.Blaize.formPostProcessors["*"].forEach(function (processor) { processors.push(processor); }); } if (window.Blaize.formPostProcessors[formSlug]) { window.Blaize.formPostProcessors[formSlug].forEach(function (processor) { processors.push(processor); }); } processors.forEach(function (processor) { processor(formData, response); }); } }, }; } }; /* src/components/FormViewedDetect.svelte generated by Svelte v4.2.12 */ function create_fragment$2(ctx) { let div; let current; const default_slot_template = /*#slots*/ ctx[3].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[2], null); return { c() { div = element("div"); if (default_slot) default_slot.c(); }, m(target, anchor) { insert(target, div, anchor); if (default_slot) { default_slot.m(div, null); } /*div_binding*/ ctx[4](div); current = true; }, p(ctx, [dirty]) { if (default_slot) { if (default_slot.p && (!current || dirty & /*$$scope*/ 4)) { update_slot_base( default_slot, default_slot_template, ctx, /*$$scope*/ ctx[2], !current ? get_all_dirty_from_scope(/*$$scope*/ ctx[2]) : get_slot_changes(default_slot_template, /*$$scope*/ ctx[2], dirty, null), null ); } } }, i(local) { if (current) return; transition_in(default_slot, local); current = true; }, o(local) { transition_out(default_slot, local); current = false; }, d(detaching) { if (detaching) { detach(div); } if (default_slot) default_slot.d(detaching); /*div_binding*/ ctx[4](null); } }; } function instance$2($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; let { form } = $$props; let intersecting = false; let element; let observer; const dispatch = createEventDispatcher(); onMount(() => { if (typeof IntersectionObserver !== 'undefined') { observer = new IntersectionObserver(entries => { const entry = entries[0]; intersecting = entry?.isIntersecting; dispatch('observe', entry); if (intersecting && form) { logDataLayerEvent(form, 'zephr_form_view', null); observer.unobserve(element); } }, { threshold: 0.75 }); if (element) { observer.observe(element); } } return () => { if (observer) { observer.disconnect(); } }; }); function div_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { element = $$value; $$invalidate(0, element); }); } $$self.$$set = $$props => { if ('form' in $$props) $$invalidate(1, form = $$props.form); if ('$$scope' in $$props) $$invalidate(2, $$scope = $$props.$$scope); }; return [element, form, $$scope, slots, div_binding]; } class FormViewedDetect extends SvelteComponent { constructor(options) { super(); init(this, options, instance$2, create_fragment$2, safe_not_equal, { form: 1 }); } } const checkForRegisteredUser = async (formActions) => { if (!document.cookie?.includes("blaize_session")) { formActions.updateFormState({ userSession: false, }); return false; } let response; try { response = await request('blaize/account', { method: "GET" }, formActions); } catch (err) { console.error(err); } if (response?.ok) { const responseJson = await response.json(); formActions.updateFormState({ userExists: true, emailIsContact: false, emailAddress: responseJson.identifiers?.email_address, userSession: true, loginRegistrationComplete: true }); } else { formActions.updateFormState({ userSession: false, }); } return response?.ok; }; /* src/components/FormRoot.svelte generated by Svelte v4.2.12 */ function get_each_context(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[22] = list[i]; return child_ctx; } // (208:2) {#if formCanBeManuallyClosed} function create_if_block_3(ctx) { let div; let button; let fa; let current; let mounted; let dispose; fa = new Fa({ props: { icon: faTimesCircle } }); return { c() { div = element("div"); button = element("button"); create_component(fa.$$.fragment); attr(button, "type", "button"); attr(button, "class", "close-button svelte-j7lu48"); attr(div, "class", "close-button-container svelte-j7lu48"); }, m(target, anchor) { insert(target, div, anchor); append(div, button); mount_component(fa, button, null); current = true; if (!mounted) { dispose = listen(button, "click", /*closeForm*/ ctx[8]); mounted = true; } }, p: noop, i(local) { if (current) return; transition_in(fa.$$.fragment, local); current = true; }, o(local) { transition_out(fa.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(fa); mounted = false; dispose(); } }; } // (221:2) {:else} function create_else_block(ctx) { let formvieweddetect; let t; let if_block_anchor; let current; formvieweddetect = new FormViewedDetect({ props: { form: /*form*/ ctx[5], $$slots: { default: [create_default_slot] }, $$scope: { ctx } } }); let if_block = /*topLevelError*/ ctx[3] && create_if_block_2(ctx); return { c() { create_component(formvieweddetect.$$.fragment); t = space(); if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { mount_component(formvieweddetect, target, anchor); insert(target, t, anchor); if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, dirty) { const formvieweddetect_changes = {}; if (dirty & /*$$scope, isFullWidth, formState*/ 33554437) { formvieweddetect_changes.$$scope = { dirty, ctx }; } formvieweddetect.$set(formvieweddetect_changes); if (/*topLevelError*/ ctx[3]) { if (if_block) { if_block.p(ctx, dirty); if (dirty & /*topLevelError*/ 8) { transition_in(if_block, 1); } } else { if_block = create_if_block_2(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(formvieweddetect.$$.fragment, local); transition_in(if_block); current = true; }, o(local) { transition_out(formvieweddetect.$$.fragment, local); transition_out(if_block); current = false; }, d(detaching) { if (detaching) { detach(t); detach(if_block_anchor); } destroy_component(formvieweddetect, detaching); if (if_block) if_block.d(detaching); } }; } // (217:69) function create_if_block_1(ctx) { let div; let spinner; let current; spinner = new Spinner({}); return { c() { div = element("div"); create_component(spinner.$$.fragment); attr(div, "class", "loading-placeholder svelte-j7lu48"); }, m(target, anchor) { insert(target, div, anchor); mount_component(spinner, div, null); current = true; }, p: noop, i(local) { if (current) return; transition_in(spinner.$$.fragment, local); current = true; }, o(local) { transition_out(spinner.$$.fragment, local); current = false; }, d(detaching) { if (detaching) { detach(div); } destroy_component(spinner); } }; } // (215:2) {#if formHasCrashed} function create_if_block(ctx) { let div; return { c() { div = element("div"); div.textContent = `${resolveErrorLanguagePackKey(/*form*/ ctx[5], ServerError.UNKNOWN)}`; }, m(target, anchor) { insert(target, div, anchor); }, p: noop, i: noop, o: noop, d(detaching) { if (detaching) { detach(div); } } }; } // (228:8) {#each form.sectionFlow.extraElements.concat(formState.currentSection.elements || []) as element} function create_each_block(ctx) { let elementresolver; let current; elementresolver = new ElementResolver({ props: { form: /*form*/ ctx[5], formState: /*formState*/ ctx[0], formActions: /*formActions*/ ctx[7], sectionElement: /*element*/ ctx[22] } }); return { c() { create_component(elementresolver.$$.fragment); }, m(target, anchor) { mount_component(elementresolver, target, anchor); current = true; }, p(ctx, dirty) { const elementresolver_changes = {}; if (dirty & /*formState*/ 1) elementresolver_changes.formState = /*formState*/ ctx[0]; if (dirty & /*formState*/ 1) elementresolver_changes.sectionElement = /*element*/ ctx[22]; elementresolver.$set(elementresolver_changes); }, i(local) { if (current) return; transition_in(elementresolver.$$.fragment, local); current = true; }, o(local) { transition_out(elementresolver.$$.fragment, local); current = false; }, d(detaching) { destroy_component(elementresolver, detaching); } }; } // (222:4) function create_default_slot(ctx) { let form_1; let current; let mounted; let dispose; let each_value = ensure_array_like(/*form*/ ctx[5].sectionFlow.extraElements.concat(/*formState*/ ctx[0].currentSection.elements || [])); let each_blocks = []; for (let i = 0; i transition_out(each_blocks[i], 1, 1, () => { each_blocks[i] = null; }); return { c() { form_1 = element("form"); for (let i = 0; i { if_blocks[previous_block_index] = null; }); check_outros(); if_block1 = if_blocks[current_block_type_index]; if (!if_block1) { if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); if_block1.c(); } else { if_block1.p(ctx, dirty); } transition_in(if_block1, 1); if_block1.m(div, null); } if (accordion_action && is_function(accordion_action.update) && dirty & /*formIsOpen*/ 16) accordion_action.update.call(null, /*formIsOpen*/ ctx[4]); if (!current || dirty & /*isFullWidth*/ 4) { toggle_class(div, "zephr-form-max-width", !/*isFullWidth*/ ctx[2]); } if (!current || dirty & /*isFullWidth*/ 4) { toggle_class(div, "zephr-payment-form-max-width", !/*isFullWidth*/ ctx[2]); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (detaching) { detach(div); } if (if_block0) if_block0.d(); if_blocks[current_block_type_index].d(); mounted = false; dispose(); } }; } const defaultBusyKey = "default"; const submit_handler = e => e?.preventDefault(); function instance$1($$self, $$props, $$invalidate) { let formIsOpen; let topLevelError; let isFullWidth; onMount(addFormProcessorsToWindow); let { formConfiguration } = $$props; let form = sortForm(formConfiguration); if (form.environment.debugLogging) { console.log(form); } // variable let isPaymentForm = form.formType === "PAYMENT"; let requestCountByKey = {}; let isSessionChecked = false; const previewSection = form.environment.previewMode && form.environment.previewInitialState ? findSectionByAddress(form.environment.previewInitialState, form) : null; const defaultCountry = formConfigAs(form).defaultCountry || ""; let formState = Object.freeze({ currentPart: previewSection?.part ?? form.parts[0], currentSection: previewSection?.section ?? form.parts[0].sections[0], paymentOption: null, paymentOptionPrices: null, emailAddress: "", billingCountry: defaultCountry, billingState: "", createPassword: "", password: "", confirmCreatePassword: "", accountMembershipCode: "", passwordIsValid: false, elementValidity: [], canAttemptSectionCompletion: true, showFieldErrors: false, loginRegistrationComplete: false, serverErrors: [], isBusy: false, isBusyByKey: [], formCannotBeActioned: false, forgotPassword: false, promoCode: "", addons: [], discountedPlanPrices: [], paymentProviderFormLoaded: false, paymentProviderError: null, paymentFormComplete: false, paymentProviderVendorFields: null, verificationCode: "", userAttributes: extractDefaultUserAttributes(form), socialSignin: false, paymentProcessed: false, invitationEmail: "", invitationSent: false, validChangeFromPlans: [], taxCalculations: {}, billingAddress: { country: null, postalCode: null }, formPrerequisiteLoaded: !form.sectionFlow.formRequiresPrerequisiteLoading(form), dynamicOfferResult: null, originalDynamicOfferResult: null, giftCode: new URLSearchParams(window.location.search).get('giftCode') || '', giftRecipient: { name: '', email: '', customMessage: '', recipientAddress: { addressLine1: '', addressLine2: '', city: '', state: '', country: '', postalCode: '' } } }); // actions const updateFormState = update => { $$invalidate(0, formState = Object.freeze({ ...formState, ...update })); form.environment.debugLogging && console.log(formState); form.environment.onStateChanged(update, formState); return formState; }; const _attemptCompleteSection = () => { void attemptCompleteSection(form, formState, formActions); }; const _completeSection = () => { void completeSection(form, formState, formActions); }; const jumpToPartStart = partType => { void jumpToPart(partType, form, formActions); }; const _jumpToSection = sectionType => { void jumpToSection(sectionType, form, formActions); }; const onEvent = formEvent => { if (form.environment.previewMode) { return; } void form.sectionFlow.eventHandlers[formEvent]?.(form, formState, formActions); }; const modifyRequestCount = (by, busyKey) => { const key = busyKey ?? defaultBusyKey; if (requestCountByKey[key] === undefined) { requestCountByKey[key] = 0; } requestCountByKey[key] += by; if (requestCountByKey[key] v > 0); if (isBusy !== formState.isBusy) { updateFormState({ isBusy }); } const isBusyByKey = requestCountByKey[key] > 0; if (isBusyByKey !== formState.isBusyByKey[key]) { updateFormState({ isBusyByKey: { ...formState.isBusyByKey, [key]: isBusyByKey } }); } }; const formActions = { updateFormState, attemptCompleteSection: _attemptCompleteSection, completeSection: _completeSection, jumpToPartStart, jumpToSection: _jumpToSection, onEvent, incrementRequestCount: (busyKey = null) => modifyRequestCount(+1, busyKey), decrementRequestCount: (busyKey = null) => modifyRequestCount(-1, busyKey), getFormState: () => formState, apiUrlBase: form.environment.apiUrlBase }; // Preview if (form.environment.previewMode) { form.environment.previewBundle?.setupPreviewMode(form, formActions); } // When the form first loads, check if this is a currently-registered user onMount(async () => { if (form.formType === "GIFT_REDEMPTION") { // Check user session before triggering form start await checkForRegisteredUser(formActions); $$invalidate(1, isSessionChecked = true); } formActions.onEvent(FormEvent.FORM_START); logDataLayerEvent(form, 'zephr_form_render', null); }); let formManuallyClosed = false; const closeForm = () => $$invalidate(11, formManuallyClosed = true); const formCanBeManuallyClosed = form.sectionFlow.canDismissFormManually(form) && form.formType !== 'CHANGE_SUBSCRIPTION'; $$self.$$set = $$props => { if ('formConfiguration' in $$props) $$invalidate(10, formConfiguration = $$props.formConfiguration); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*formState*/ 1) { { const canAttemptSectionCompletion = form.sectionFlow.canAttemptSectionCompletion(form, formState); if (canAttemptSectionCompletion != formState.canAttemptSectionCompletion) { updateFormState({ canAttemptSectionCompletion }); } } } if ($$self.$$.dirty & /*formManuallyClosed, formState*/ 2049) { $$invalidate(4, formIsOpen = !formManuallyClosed && formState.formPrerequisiteLoaded && !formState.formCannotBeActioned); } if ($$self.$$.dirty & /*formState*/ 1) { // Unshown errors $$invalidate(3, topLevelError = formState.serverErrors[0] && (formState.currentSection.elements || []).filter(e => serverErrorForElement(e.type, formState)).length === 0 ? formState.serverErrors[0] : null); } if ($$self.$$.dirty & /*formState*/ 1) { $$invalidate(2, isFullWidth = [...Object.values(sectionTypes)].find(s => s.type === formState.currentSection.type)?.fullWidth); } }; return [ formState, isSessionChecked, isFullWidth, topLevelError, formIsOpen, form, isPaymentForm, formActions, closeForm, formCanBeManuallyClosed, formConfiguration, formManuallyClosed ]; } class FormRoot extends SvelteComponent { constructor(options) { super(); init(this, options, instance$1, create_fragment$1, safe_not_equal, { formConfiguration: 10 }); } } const defaultCssVariables = { "--zephr-button-borderRadius": "9", "--zephr-button-borderWidth": "0", "--zephr-button-fontSize": "16", "--zephr-button-fontWeight": "normal", "--zephr-button-height": "50", "--zephr-color-accent-main": "#dcf1fb", "--zephr-color-accent-tinted": "#81cdf1", "--zephr-color-action-main": "#006edb", "--zephr-color-action-tinted": "#0f87ff", "--zephr-color-background-main": "#fff", "--zephr-color-background-tinted": "#ccc", "--zephr-color-text-main": "#000", "--zephr-color-text-tinted": "#333", "--zephr-color-warning-main": "#d90b00", "--zephr-color-warning-tinted": "#ff190d", "--zephr-input-borderColor": "#333", "--zephr-input-borderRadius": "5", "--zephr-input-borderWidth": "1", "--zephr-input-height": "50", "--zephr-typography-title-fallbackFont": "sans-serif", "--zephr-typography-title-font": "Roboto", "--zephr-typography-body-fallbackFont": "sans-serif", "--zephr-typography-body-font": "Roboto", }; /* eslint-disable @typescript-eslint/restrict-template-expressions */ const convertSiteStylesToCssVariables = (siteStyles) => { const styles = {}; const convertToCssVariables = (styleGuide, variablePrefix) => { if (styleGuide !== null && typeof styleGuide == "object") { Object.entries(styleGuide).forEach(([key, value]) => { convertToCssVariables(value, variablePrefix.concat(`${variablePrefix ? "-" : ""}${key}`)); }); } else { styles[`--zephr-${variablePrefix}`] = styleGuide; } }; convertToCssVariables(siteStyles, ""); return Object.entries({ ...defaultCssVariables, ...styles }) .map(([key, value]) => `${key}: ${value}`) .join(';\n'); }; function formTypeClass(formType) { switch (formType) { case FormType.CHANGE_SUBSCRIPTION: case FormType.PAYMENT: case FormType.GIFT_SUBSCRIPTION: return "zephr-payment-form"; case FormType.REGISTRATION: case FormType.COMPLETE_REGISTRATION: case FormType.GIFT_REDEMPTION: return "zephr-registration-form"; case FormType.CONTACT: return "zephr-contact-form"; case FormType.DATA_CAPTURE: return "zephr-data-capture-form"; default: return ""; } } const mapToServerError = (responseCode, responseMessage, formState) => { if (responseCode === 401) { if (responseMessage.indexOf("verification is required") > -1) { return ServerError.EMAIL_VERIFICATION_REQUIRED; } if (responseMessage.indexOf("session must be authenticated") > -1) { return ServerError.NO_AUTHENTICATED_SESSION; } if (formState.verificationCode) { return ServerError.VERIFICATION_CODE_OR_PASSWORD_INCORRECT; } return ServerError.LOGIN_FAILED; } if (responseCode === 402 && responseMessage?.includes('this domain is not supported.')) { return ServerError.BLOCKED_EMAIL_DOMAIN; } if (responseCode === 409) { return ServerError.USER_ALREADY_EXISTS; } if (responseCode === 400 && responseMessage?.includes("The provided password is not strong enough")) { return ServerError.PASSWORD_NOT_STRONG_ENOUGH; } if (responseCode === 404 && responseMessage?.includes("account")) { return ServerError.ACCOUNT_NOT_FOUND; } if (responseCode === 404) return ServerError.USER_DOES_NOT_EXIST; if (responseCode === 429 && responseMessage?.includes("sessions limit reached")) { return ServerError.TOO_MANY_SESSIONS; } if (responseCode === 429) return ServerError.NO_ACCOUNT_ACCESS; if (formState.socialSignin) return ServerError.SOCIAL_SIGNIN_REGISTRATION_LOGIN_ERROR; if (responseCode === 403 && responseMessage?.includes("Contact creation not enabled")) { return ServerError.CONTACT_CREATION_NOT_ENABLED; } return ServerError.UNKNOWN_LOGIN_REGISTER_ERROR; }; const logConversion = (conversion, form, formActions) => { if (!form.organisationConfiguration.ruleAnalyticsEnabled) { return; } void request('zephr/public/rule-outcomes/v1/conversions', { method: 'POST', bodyObject: { "conversion": conversion, "ruleId": form.ruleId, "outcomeId": form.outcomeId } }, formActions); }; const logConversionAfterRegistration = (form, formActions) => logConversion("REGISTERED", form, formActions); const PATH_PARAM_NAME = "sharing_id"; /** * Extract a sharing ID from the page URL. */ const getProductSharingInvite = () => { try { const sharingId = new URLSearchParams(window.location.search).get(PATH_PARAM_NAME); return sharingId ? { product_sharing_id: sharingId } : null; } catch { // If there is any browser compatibility issue, ignore it return null; } }; const removeSharingInviteFromUrl = (url) => { try { const r = new URL(url); if (!r.searchParams.has(PATH_PARAM_NAME)) { return url; } r.searchParams.delete(PATH_PARAM_NAME); return r.href; } catch { // If there is any browser compatibility issue, ignore it return url; } }; const toLoginPayload = (formState) => ({ identifiers: { email_address: formState.emailAddress }, validators: { password: formState.password || undefined, email_otp: formState.verificationCode || undefined, token_exchange: formState.socialSigninToken || undefined }, recaptchaToken: formState.recaptchaToken || undefined, }); const preprocessorIdentity$2 = (slug, t) => t; const toRegistrationPayload = (form, formState) => { const autoAppliedAttributes = formConfigAs(form).autoApplyAttributes ?? {}; const preprocessor = window.Blaize?.preProcessFormData ?? preprocessorIdentity$2; const attributes = userAttributesValuesForPart(partTypes.ACCOUNT_VERIFICATION.type, form, formState); const attributesWithAutoApplied = { ...attributes, ...autoAppliedAttributes }; const productSharingData = getProductSharingInvite(); return preprocessor(form.id, { identifiers: formState.socialSignin ? {} : { email_address: formState.emailAddress }, validators: { password: formState.createPassword || undefined, email_otp: formState.verificationCode || undefined, token_exchange: formState.socialSigninToken || undefined }, attributes: Object.keys(attributesWithAutoApplied).length ? attributesWithAutoApplied : undefined, account_membership_code: formState.accountMembershipCode || undefined, recaptchaToken: formState.recaptchaToken || undefined, ...(productSharingData ?? {}) }); }; const register = async (form, formState, formActions) => { const payload = toRegistrationPayload(form, formState); const response = await request('blaize/register', { method: "POST", bodyObject: payload }, formActions); return processResponse$2(payload, response, form, formState, formActions); }; const login = async (form, formState, formActions) => { const payload = toLoginPayload(formState); const response = await request('blaize/login', { method: "POST", bodyObject: payload }, formActions); return processResponse$2(null, response, form, formState, formActions); }; const processResponse$2 = async (registrationPayload, response, form, formState, formActions) => { registrationPayload ? logDataLayerEvent(form, 'zephr_form_register', { success: response?.ok }) : logDataLayerEvent(form, 'zephr_form_login', { success: response?.ok }); if (!response?.ok) { if (formState.verificationCode) { formActions.updateFormState({ verificationCodeValid: false }); } const responseMessage = (await response.json())?.message; const serverError = mapToServerError(response.status, responseMessage, formState); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); if (serverError === ServerError.PASSWORD_NOT_STRONG_ENOUGH) { formActions.updateFormState({ dynamicServerErrorMessage: responseMessage, }); } formActions.updateFormState({ serverErrors: [serverError] }); if (ServerErrors[serverError].jumpToPart) { formActions.jumpToPartStart(ServerErrors[serverError].jumpToPart); } return Promise.resolve(); } if (!formState.userExists) { logConversionAfterRegistration(form, formActions); } return response.json() .then(async (json) => { const cookieInResponse = json.cookie?.includes("blaize_session"); if (cookieInResponse) { document.cookie = json.cookie; } else { if (!form.sectionFlow.canPartiallyRegister) { console.warn("No cookie returned from login/register endpoint - most likely incorrect form configuration."); formActions.updateFormState({ serverErrors: [ServerError.NO_COOKIE_FROM_LOGIN_REGISTER_ERROR], }); return Promise.resolve(); } } registrationPayload && window.Blaize?.postProcessFormData && window.Blaize.postProcessFormData(form.id, registrationPayload, json); if (formState.verificationCode && formState.currentSection.elements.some(e => e.type === elementTypes.VERIFICATION_CODE)) { formActions.updateFormState({ verificationCodeValid: true }); await waitAfterCode(form); } formActions.updateFormState({ loginRegistrationComplete: true }); return formActions.onEvent(FormEvent.LOGIN_REGISTRATION_COMPLETE); }); }; const CHANGE_SUBSCRIPTION_DEFAULT_CONVERSION_NAME = "CHANGE_SUBSCRIPTION"; const logConversionAfterPurchase = (form, formActions) => logConversion(formConfigAs(form).changeSubscriptionMode ? (formConfigAs(form).changeSubscriptionConversionName ?? CHANGE_SUBSCRIPTION_DEFAULT_CONVERSION_NAME) : "CUSTOMER", form, formActions); // Unique ID creation requires a high quality random # generator. In the browser we therefore // require the crypto API and do not support built-in fallback to lower quality random number // generators (like Math.random()). let getRandomValues; const rnds8 = new Uint8Array(16); function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); if (!getRandomValues) { throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); } } return getRandomValues(rnds8); } /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ const byteToHex = []; for (let i = 0; i { const attributesPromise = formState.paymentAttributesSubmitted ? Promise.resolve() : submitUserAttributesForPart(partTypes.PAYMENT.type, form, formState, formActions); return attributesPromise.then(() => { const completer = formState.mobilePaymentService == null ? paymentProviderFor(form.organisationConfiguration.paymentProvider).completer : mobilePaymentServiceFor(form.organisationConfiguration.paymentProvider).completer; return completer(form, formState, formActions) .then(() => { const postFormSubmitMessage = { error: null, errorMessage: "", success: true, formSlug: form.id }; const formEventPayload = JSON.stringify(postFormSubmitMessage); // handle ios message window?.webkit?.messageHandlers?.messageHandler?.postMessage(formEventPayload); // handle android message window?.AndroidFormEventListener?.processFormEvent(formEventPayload); logConversionAfterPurchase(form, formActions); formActions.updateFormState({ paymentProcessed: true }); logDataLayerEvent(form, 'zephr_form_purchase', { productId: formState.paymentOption.productId, planId: formState.paymentOption.slug, price: formState.paymentOptionPrices?.totalPrice }); logDataLayerEvent(form, 'purchase', { ecommerce: { transaction_id: v4(), value: formState.paymentOptionPrices?.totalPrice, tax: formState.paymentOptionPrices?.taxPrice, currency: getRelevantCurrency(form, formState), coupon: formState.promoCode, items: [{ item_id: formState.paymentOption.slug, item_name: formState.paymentOption.productId, price: formState.paymentOptionPrices?.totalPrice, quantity: 1 }] } }); if (formState.convertCancelSubscriptionToAcceptOffer) { logDataLayerEvent(form, 'zephr_form_subscription_cancel_accept_offer', { canceledProductId: formState.selectedSubscription.productId, acceptedProductId: formState.paymentOption.productId, productLabel: formState.paymentOption.label, currency: formState.paymentOption.currencyCode, amount: formState.paymentOptionPrices?.totalPrice }); } formActions.jumpToPartStart(partTypes.SUCCESS.type); if (formConfigAs(form).changeSubscriptionMode) { const changingFromSubscription = formState .validChangeFromPlans .find(plan => formState.paymentOption.slug === plan.planSlug && formState.paymentOption.productId === plan.productId) .changesFromSubscription; logDataLayerEvent(form, 'zephr_form_subscription_change', { fromProductId: changingFromSubscription.productId, fromProductAmount: changingFromSubscription.amount, toProductId: formState.paymentOption.productId, toProductAmount: formState.paymentOptionPrices.netPriceFormattedString, }); } }).catch(err => { const serverError = formState.mobilePaymentService == null ? ServerError.PAYMENT_PROCESSING_ERROR : ServerError.MOBILE_PAYMENT_PROCESSING_ERROR; console.error("Error completing payment", err); logDataLayerEvent(form, 'zephr_form_payment_failure', { reason: err }); formActions.updateFormState({ mobilePaymentService: null, serverErrors: [serverError] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); }); }); }; const calculateChangeSubscriptionProrate = async (form, formState, formActions) => { if (!formConfigAs(form).changeSubscriptionMode) { return; } formActions.updateFormState({ changeSubscriptionProrate: null }); const prorateCalculator = paymentProviderFor(form.organisationConfiguration.paymentProvider) .changeSubscriptionProrateCalculator; if (!prorateCalculator) { return; } const prorate = await prorateCalculator(form, formState, formActions); formActions.updateFormState({ changeSubscriptionProrate: prorate }); }; const getSubscriptionParam = (url) => { const urlObj = new URL(url); return urlObj.searchParams.get("subscription"); }; /** * Checks if the current user has payment methods stored in their Zuora billing account * Only runs for zuora-billing payment provider */ const checkUserHasPaymentMethods = async (form, formActions) => { // Only check for zuora-billing provider if (form.organisationConfiguration.paymentProvider !== 'zuora-billing') { return true; // Assume other providers have payment methods or don't need this check } try { const response = await request('plugins/public/zuora-billing/payment-methods', { method: 'GET' }, formActions); const data = await response.json(); // Check if user has any credit cards stored return data.creditCards && data.creditCards[0]?.id; } catch (error) { console.warn('Unable to check payment methods, assuming user has payment methods:', error); // If we can't check, assume they have payment methods to avoid blocking the flow return true; } }; const getChangeFromPlans = (subscriptions, form) => { return subscriptions.length === 0 ? [] : formConfigAs(form).paymentOptions.map(paymentOption => { const mapping = (formConfigAs(form).changeSubscriptionPlanMappings ?? []) .find(mapping => mapping.toPlan.planSlug === paymentOption.slug && mapping.toPlan.productId === paymentOption.productId); if (!mapping) { return; } const validSubscriptions = subscriptions.filter(subscription => // Ignore if subscription is for the destination payment option !(subscription.planId === paymentOption.slug && subscription.productId === paymentOption.productId) && ( // Ignore if subscription plan is not in 'fromPlans', unless allowing any plan mapping.fromAnyPlan || mapping.fromPlans.some(fromPlan => ((!subscription.multiphasePlan && fromPlan.planSlug === subscription.planId) || subscriptionMatchesMultiphasePlan(fromPlan, subscription)) && fromPlan.productId === subscription.productId))); if (validSubscriptions.length === 0) { return; } if (validSubscriptions.length > 1) { console.log("Found multiple valid subscriptions to move to payment option, selecting the first", paymentOption); } return { planSlug: paymentOption.slug, productId: paymentOption.productId, changesFromSubscription: subscriptions[0], }; }).filter(Boolean); }; const subscriptionMatchesMultiphasePlan = (fromPlan, subscription) => { if (!subscription.multiphasePlan) { return false; } const planSlug = fromPlan.planSlug; const multiphasePlan = subscription.multiphasePlanMappings?.[planSlug]; if (!multiphasePlan) { return false; } return multiphasePlan.phases.some(phase => phase.planId === subscription.planId); }; const loadExistingSubscriptions$1 = async (form, formState, formActions, hasDynamicOfferAttached, validPlansRequired) => { const subscriptionLoader = paymentProviderFor(form.organisationConfiguration.paymentProvider).existingSubscriptionLoader; if (!subscriptionLoader) { console.error(`Existing subscription loader not configured for ${form.organisationConfiguration.paymentProvider}`); formActions.updateFormState({ formCannotBeActioned: true }); return; } let subscriptions; try { subscriptions = await subscriptionLoader(form, formState, formActions, true); } catch (err) { console.error("Unable to load subscriptions", err); formActions.updateFormState({ formCannotBeActioned: true }); return; } // Check if payment method setup is required const paymentConfig = formConfigAs(form); let requiresPaymentMethodSetup = false; if (paymentConfig.allowNoPaymentMethodUpgrade && form.organisationConfiguration.paymentProvider === 'zuora-billing') { const hasPaymentMethods = await checkUserHasPaymentMethods(form, formActions); if (!hasPaymentMethods) { requiresPaymentMethodSetup = true; } } const subscriptionQueryParamId = getSubscriptionParam(window.location.href); if (subscriptionQueryParamId) { const subscriptionMatched = subscriptions.filter(sub => sub.externalId === subscriptionQueryParamId); if (subscriptionMatched.length && getChangeFromPlans(subscriptionMatched, form).length) { subscriptions = subscriptionMatched; } } if (hasDynamicOfferAttached) { filterDynamicOfferChangeFromPlans(subscriptions, formState, formActions, requiresPaymentMethodSetup); return subscriptions; } const changeFromPlans = getChangeFromPlans(subscriptions, form); const selectionMode = formConfigAs(form).subscriptionSelectionMode; if (subscriptions.length === 0) { console.warn("Not showing form as user has no active subscriptions"); } else if (changeFromPlans.length === 0 && !selectionMode && validPlansRequired) { console.warn("Not showing form as no payment options can be actioned with the user's current subscriptions"); } if (selectionMode) { subscriptions = subscriptions.map(subscription => { if (formConfigAs(form).changeSubscriptionPlanMappings.some(m => m.fromAnyPlan || m.fromPlans.some(fromPlan => ((!subscription.multiphasePlan && fromPlan.planSlug === subscription.planId) || subscriptionMatchesMultiphasePlan(fromPlan, subscription)) && fromPlan.productId === subscription.productId))) { subscription.cannotBeChanged = false; } else { subscription.cannotBeChanged = true; } return subscription; }); } formActions.updateFormState({ existingSubscriptions: subscriptions, formCannotBeActioned: changeFromPlans.length === 0 && !selectionMode && validPlansRequired && !requiresPaymentMethodSetup, validChangeFromPlans: changeFromPlans, formPrerequisiteLoaded: true, requiresPaymentMethodSetup, showPaymentMethodFlowFirst: requiresPaymentMethodSetup, }); return subscriptions; }; const filterDynamicOfferChangeFromPlans = (subscriptions, formState, formActions, requiresPaymentMethodSetup) => { if (subscriptions.length === 0) { console.log("No subscriptions available."); formActions.updateFormState({ existingSubscriptions: [], formCannotBeActioned: true, validChangeFromPlans: [], formPrerequisiteLoaded: true, requiresPaymentMethodSetup, showPaymentMethodFlowFirst: requiresPaymentMethodSetup, }); return; } const dynamicOffer = formState.dynamicOfferResult; if (!dynamicOffer) { console.log("No dynamic offer result available."); } // Filter payment plans from dynamic offers that the user is not already subscribed to and matches the currency of existing subscriptions. const changeFromPlans = dynamicOffer?.products?.flatMap(product => product.paymentPlans.filter(plan => { const isSubscribed = subscriptions.some(sub => sub.planId === plan.planId && sub.productId === product.id); const currencyMatch = subscriptions.every(sub => plan.charges.every(charge => charge.prices?.some(price => price.currency === sub.currency))); return !isSubscribed && currencyMatch; }).map(plan => ({ planSlug: plan.planId, productId: product.id, changesFromSubscription: subscriptions.find(sub => plan.charges.every(charge => charge.prices?.some(price => price.currency === sub.currency))) })).filter(plan => { const hasChangesFromSubscription = !!plan.changesFromSubscription; return hasChangesFromSubscription; })) ?? []; formActions.updateFormState({ existingSubscriptions: subscriptions, formCannotBeActioned: changeFromPlans.length === 0 && !requiresPaymentMethodSetup, validChangeFromPlans: changeFromPlans, formPrerequisiteLoaded: true, requiresPaymentMethodSetup, showPaymentMethodFlowFirst: requiresPaymentMethodSetup, }); }; const loadExistingSubscriptions = async (form, formState, formActions, activeOnly) => { const provider = form.organisationConfiguration.paymentProvider; const loader = paymentProviderFor(provider)?.existingSubscriptionLoader; if (!loader) { console.error(`❌ [loadExistingSubscriptions] Existing subscription loader not configured for ${provider}`); return []; } const existingSubscriptions = loader ? await loader(form, formState, formActions, activeOnly) : []; formActions.updateFormState({ existingSubscriptions }); return existingSubscriptions; }; const formStartAction$a = async (form, formState, formActions) => { const hasGifts = form.formType === FormType.LIST_GIFT_SUBSCRIPTIONS_SENT || (form.formType === FormType.LIST_SUBSCRIPTIONS && form.organisationConfiguration.paymentProvider.includes('zuora-billing')); // Load gift subscriptions if applicable (for sent gifts or regular subscriptions that need to show received gifts) if (hasGifts) { // Set loading state to true first formActions.updateFormState({ loadingGiftSubscriptions: true }); // Get the mock data outside the try block so it's accessible in the catch block let allGiftSubscriptionsData = []; // For preview mode, we can skip the API call and use the mock data directly if (form.environment?.previewMode) { allGiftSubscriptionsData = [ // Received gift (current user is recipient) { gift_code: "GIFT-PREVIEW-1", subscription_number: "gift-sub-preview-1", status: "REDEEMED", is_purchaser: false, is_recipient: true, amount: "GBP 99/year", currency: "GBP", currentTermPeriodType: "Year", tenant_id: "organization_tenant_id", purchaser_user_id: "user_sender_12345", recipient_user_id: "user_current", recipient_email: "current.user@example.com", recipientFirstName: "John", recipientLastName: "Smith", message: "Enjoy your premium gift subscription!", subscriptionType: "Premium Digital", subscriptionStartDate: "January 1, 2025", subscriptionEndDate: "January 1, 2026", error_reason: null, host: "example.com", recipient_zuora_account_id: "account_123" }, // Sent gift (current user is purchaser) { gift_code: "GIFT-PREVIEW-2", subscription_number: "gift-sub-preview-2", status: "REDEEMED", is_purchaser: true, is_recipient: false, amount: "GBP 50/year", currency: "GBP", currentTermPeriodType: "Year", tenant_id: "organization_tenant_id", purchaser_user_id: "user_current", recipient_user_id: "user_recipient_12345", recipient_email: "recipient@example.com", recipientFirstName: "Jane", recipientLastName: "Doe", message: "Here's your gift subscription!", subscriptionType: "Basic Digital", subscriptionStartDate: "February 15, 2025", subscriptionEndDate: "February 15, 2026", error_reason: null, host: "example.com", recipient_zuora_account_id: "account_456" }, // Pending gift (not yet redeemed) { gift_code: "GIFT-PREVIEW-3", subscription_number: "gift-sub-preview-3", status: "PENDING", is_purchaser: true, is_recipient: false, amount: "GBP 50/year", currency: "GBP", currentTermPeriodType: "Year", tenant_id: "organization_tenant_id", purchaser_user_id: "user_current", recipient_user_id: null, recipient_email: "pending@example.com", recipientFirstName: "", recipientLastName: "", message: "A gift subscription for you!", subscriptionType: "Basic Digital", subscriptionStartDate: "March 1, 2025", subscriptionEndDate: "March 1, 2026", error_reason: null, host: "example.com", recipient_zuora_account_id: null } ]; formActions.updateFormState({ giftSubscriptions: allGiftSubscriptionsData, formPrerequisiteLoaded: true, loadingGiftSubscriptions: false }); } else { try { formActions.updateFormState({ loadingSubscriptions: true }); // loads in subscriptions and gift data await loadGiftSubscriptions(form, formState, formActions); formActions.updateFormState({ formPrerequisiteLoaded: true, loadingGiftSubscriptions: false }); } catch (error) { console.error('❌ [LIST_SUBSCRIPTIONS] Error loading gift subscriptions:', error); formActions.updateFormState({ formPrerequisiteLoaded: true, serverErrors: [ ServerError.UNKNOWN ] }); } } formActions.updateFormState({ loadingGiftSubscriptions: false, loadingSubscriptions: false }); } // Load regular subscriptions for the standard list view try { formActions.updateFormState({ loadingSubscriptions: true }); await loadExistingSubscriptions(form, formState, formActions, false); } catch (error) { console.error("❌ [LIST_SUBSCRIPTIONS] Error loading subscriptions", error); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR], }); } finally { formActions.updateFormState({ loadingSubscriptions: false, loadingGiftSubscriptions: false, }); } }; const goBack$2 = async (_, __, formActions) => { formActions.jumpToPartStart(partTypes.LIST_SUBSCRIPTIONS.type); return Promise.resolve(); }; const changePayment = async (form, formState, formActions) => { const completer = paymentProviderFor(form.organisationConfiguration.paymentProvider).changePaymentCompleter; await completer(form, formState, formActions) .then(async () => { formActions.updateFormState({ paymentProviderFormBusy: false }); const paymentConfig = formConfigAs(form); if (paymentConfig.changeSubscriptionMode && formState.paymentMethodSetupComplete) { const subscriptionCompleter = paymentProviderFor(form.organisationConfiguration.paymentProvider).completer; await subscriptionCompleter(form, formState, formActions) .then(() => { formActions.jumpToPartStart(partTypes.SUCCESS.type); logDataLayerEvent(form, 'zephr_form_subscription_change', null); }) .catch(err => { console.error("Error changing subscription after adding payment method:", err); formActions.updateFormState({ serverErrors: [ServerError.PAYMENT_PROCESSING_ERROR] }); }); } else { formActions.jumpToPartStart(partTypes.SUCCESS.type); logDataLayerEvent(form, 'zephr_form_payment_method_changed', null); } }).catch(err => { const serverError = formState.mobilePaymentService == null ? ServerError.PAYMENT_PROCESSING_ERROR : ServerError.MOBILE_PAYMENT_PROCESSING_ERROR; console.error("Error completing payment change", err); formActions.updateFormState({ mobilePaymentService: null, paymentProviderFormBusy: false, serverErrors: [serverError] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); }); }; // NB: If you change these event handlers, you must also consider updating the event handlers in giftSubscriptionsListSectionFlow.ts const eventHandlers$c = { [FormEvent.FORM_START]: formStartAction$a, [FormEvent.GO_BACK]: goBack$2, [FormEvent.PART_CHANGE_PAYMENT_COMPLETE]: changePayment, }; const sectionVisibilities$a = []; const canAttemptSectionCompletion$b = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const extraElements$3 = [ { type: elementTypes.PAYMENT_PRE_LOADER, order: -1, }, ]; const listSubscriptionsSectionFlow = { extraElements: extraElements$3, eventHandlers: eventHandlers$c, sectionVisibilities: sectionVisibilities$a, canAttemptSectionCompletion: canAttemptSectionCompletion$b, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; /** * Map of possible movements through the form sections. */ let checkForRegisteredUserResolve$1; const checkForRegisteredUserPromise$1 = new Promise(function (resolve) { checkForRegisteredUserResolve$1 = resolve; }); const formStartAction$9 = async (form, _, formActions) => { const hasDynamicOfferAttached = !!formConfigAs(form).dynamicOffer?.id || !!formConfigAs(form).dynamicOfferPreview; if (hasDynamicOfferAttached) { await getDynamicOffer(form, formActions).catch((e) => { console.error('Error loading Dynamic Offer', e); }); } return checkForRegisteredUser(formActions) .then(async (alreadyRegistered) => { checkForRegisteredUserResolve$1(checkForRegisteredUserResolve$1); if (formConfigAs(form).changeSubscriptionMode) { formActions.updateFormState({ formCannotBeActioned: !alreadyRegistered }); await loadExistingSubscriptions$1(form, formActions.getFormState(), formActions, hasDynamicOfferAttached, true); const subscriptionQueryParam = getSubscriptionParam(window.location.href); if (subscriptionQueryParam && formActions.getFormState().existingSubscriptions.length === 1) { formActions.jumpToPartStart(partTypes.PLAN_SELECT.type); } } }); }; const onPlanSelectComplete$3 = (form, formState, formActions) => // After plan select, wait to see if the user is already logged in checkForRegisteredUserPromise$1 .then(async () => { const state = formActions.getFormState(); if (state.userSession || state.loginRegistrationComplete) { const updatedState = await getProductAddons(form, state, formActions); void calculatePrices(form, updatedState, formActions) .then(formState => logDataLayerEvents$1(form, formState)); void calculateChangeSubscriptionProrate(form, updatedState, formActions); // If payment method setup is required, go to change-payment part first const hasChangePaymentPart = form.parts.some(p => p.type === partTypes.CHANGE_PAYMENT.type); if (updatedState.requiresPaymentMethodSetup && !updatedState.paymentMethodSetupComplete && hasChangePaymentPart) { formActions.jumpToPartStart(partTypes.CHANGE_PAYMENT.type); } else { formActions.jumpToPartStart(partTypes.PAYMENT.type); } } else { void calculatePrices(form, formState, formActions) .then(formState => logDataLayerEvents$1(form, formState)); void calculateChangeSubscriptionProrate(form, formState, formActions); formActions.jumpToPartStart(partTypes.ACCOUNT_VERIFICATION.type); } }); const logDataLayerEvents$1 = (form, formState) => { // don't trigger data layer events for other form types that override this flow (i.e. gift subscription form) if (form.organisationConfiguration.trackFormDataLayerEvents && form.formType == FormType.PAYMENT) { const paymentOption = formState.paymentOption; // await calculatePrices(form, formActions.getFormState(), formActions); const paymentOptionPrice = formState.paymentOptionPrices?.totalPrice; logDataLayerEvent(form, 'zephr_form_payment_option_selected', { productId: paymentOption.productId, planId: paymentOption.slug, price: paymentOptionPrice, }); logDataLayerEvent(form, 'select_item', { ecommerce: { items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOptionPrice, quantity: 1 }] } }); logDataLayerEvent(form, 'add_to_cart', { ecommerce: { currency: formConfigAs(form).formCurrency ?? paymentOption?.currencyCode, value: paymentOptionPrice, items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOptionPrice, quantity: 1 }] } }); logDataLayerEvent(form, 'begin_checkout', { ecommerce: { currency: formConfigAs(form).formCurrency ?? paymentOption?.currencyCode, value: paymentOptionPrice, items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOptionPrice, quantity: 1 }] } }); } }; const onAccountVerificationComplete$2 = (form, formState, formActions) => (formState.userExists ? login : register)(form, formState, formActions); const onSuccessComplete$2 = (form, formState, formActions) => submitUserAttributesForPart(partTypes.SUCCESS.type, form, formState, formActions) .then(() => { const redirectPath = formConfigAs(form).successfulPaymentRedirectUrl?.trim(); if (redirectPath) { const isAllowedRedirectPath = redirectPath.startsWith('/') && !redirectPath.startsWith('//'); if (isAllowedRedirectPath) { window.location.href = `${window.location.origin}${redirectPath}`; } else { window.location.reload(); } } else { window.location.reload(); } }); const onLoginRegister$1 = (form, _, formActions) => getProductAddons(form, formActions.getFormState(), formActions) .then(() => calculatePrices(form, formActions.getFormState(), formActions)) .then(() => formActions.jumpToPartStart(partTypes.PAYMENT.type)); const onSubscriptionSelectComplete$4 = (form, formState, formActions) => { const changeFromPlans = getChangeFromPlans([formState.selectedSubscription], form); formActions.updateFormState({ existingSubscriptions: [formState.selectedSubscription], formCannotBeActioned: changeFromPlans.length === 0, validChangeFromPlans: changeFromPlans, formPrerequisiteLoaded: true, }); formActions.jumpToPartStart(partTypes.PLAN_SELECT.type); }; const eventHandlers$b = { [FormEvent.FORM_START]: formStartAction$9, [FormEvent.LOGIN_REGISTRATION_COMPLETE]: onLoginRegister$1, [FormEvent.SECTION_EMAIL_COMPLETE]: onEmailEntered, [FormEvent.SECTION_PASSWORD_RESET_COMPLETE]: resetPassword, [FormEvent.SECTION_FORGOT_PASSWORD_COMPLETE]: verifiyPasswordResetCode, [FormEvent.PART_PLAN_SELECT_COMPLETE]: onPlanSelectComplete$3, [FormEvent.PART_ACCOUNT_VERIFICATION_COMPLETE]: onAccountVerificationComplete$2, [FormEvent.PART_PAYMENT_COMPLETE]: pay, [FormEvent.PART_SUCCESS_COMPLETE]: onSuccessComplete$2, [FormEvent.SELECT_SUBSCRIPTION_COMPLETE]: onSubscriptionSelectComplete$4, [FormEvent.PART_CHANGE_PAYMENT_COMPLETE]: changePayment, }; const sectionVisibilities$9 = [ { type: sectionTypes.EMAIL.type, isDisplayedInProgressBar: true, isVisible: (form) => !formConfigAs(form).changeSubscriptionMode }, { type: sectionTypes.LOGIN_PASSWORD.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.userExists && !formState.socialSignin }, { type: sectionTypes.PASSWORD_SETUP.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && !formState.userExists && !formState.socialSignin }, { type: sectionTypes.SUCCESS.type, isDisplayedInProgressBar: false, isVisible: () => true }, { type: sectionTypes.PASSWORD_RESET.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.FORGOT_PASSWORD.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.VERIFICATION_CODE_LOGIN.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => (formState.userExists && (formConfigAs(form).useVerificationCodes || formState.socialSignin)) ?? false }, { type: sectionTypes.VERIFICATION_CODE_REGISTRATION.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => (!formState.userExists && (formConfigAs(form).useVerificationCodes || formState.emailIsContact)) ?? false }, { type: sectionTypes.REGISTRATION_CUSTOM.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => !formState.userExists }, { type: sectionTypes.CHANGE_PAYMENT.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => { const paymentConfig = formConfigAs(form); return paymentConfig.changeSubscriptionMode && paymentConfig.allowNoPaymentMethodUpgrade && formState.requiresPaymentMethodSetup === true && !formState.paymentMethodSetupComplete; } } ]; const canAttemptSectionCompletion$a = (form, formState) => { const providerConfig = paymentProviderFor(form.organisationConfiguration.paymentProvider); return !formState.elementValidity.filter(e => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .filter(e => !(e.elementType === elementTypes.PAYMENT && providerConfig.canAttemptIncompletePaymentFormSubmission && formState.paymentProviderFormLoaded)) .some(e => !e.isValid); }; const canDismissFormManually$1 = (form) => formConfigAs(form).changeSubscriptionMode; const formRequiresPrerequisiteLoading$1 = (form) => formConfigAs(form).changeSubscriptionMode; const extraElements$2 = [ { type: elementTypes.PAYMENT_PRE_LOADER, order: -1, }, ]; const sectionFlow$a = { extraElements: extraElements$2, sectionVisibilities: sectionVisibilities$9, eventHandlers: eventHandlers$b, canAttemptSectionCompletion: canAttemptSectionCompletion$a, canDismissFormManually: canDismissFormManually$1, formRequiresPrerequisiteLoading: formRequiresPrerequisiteLoading$1 }; /** * Map of possible movements through the form sections for reg forms. */ const onAccountVerificationComplete$1 = (form, formState, formActions) => (formState.userExists ? login : register)(form, formState, formActions); const onLoginRegisterComplete$1 = async (form, formState, formActions) => { const config = formConfigAs(form); const isPasswordless = getFormIsPasswordless(form); if (!formState.userExists && (isPasswordless || (form.organisationConfiguration.requireEmailVerfication && !config.useVerificationCodes && !formState.socialSignin))) { await sendLink(form, 'register', formState.emailAddress, formActions); await jumpToSection(sectionTypes.EMAIL_VERIFIED.type, form, formActions); return Promise.resolve(); } if (config.showSuccessOnFormCompletion && !formState.userExists) { await jumpToSection(sectionTypes.SUCCESS.type, form, formActions); } else { window.location.href = removeSharingInviteFromUrl(window.location.href); if (window.flowpoint) { window.flowpoint.track("Registration/Login Form Submitted"); } } return Promise.resolve(); }; const onSuccessComplete$1 = () => { window.location.href = removeSharingInviteFromUrl(window.location.href); if (window.flowpoint) { window.flowpoint.track("Registration/Login Form Submitted"); } return Promise.resolve(); }; const eventHandlers$a = { [FormEvent.LOGIN_REGISTRATION_COMPLETE]: onLoginRegisterComplete$1, [FormEvent.SECTION_EMAIL_COMPLETE]: onEmailEntered, [FormEvent.SECTION_PASSWORD_RESET_COMPLETE]: resetPassword, [FormEvent.SECTION_FORGOT_PASSWORD_COMPLETE]: verifiyPasswordResetCode, [FormEvent.PART_ACCOUNT_VERIFICATION_COMPLETE]: onAccountVerificationComplete$1, [FormEvent.PART_SUCCESS_COMPLETE]: onSuccessComplete$1, }; const sectionVisibilities$8 = [ { type: sectionTypes.EMAIL.type, isDisplayedInProgressBar: true, isVisible: () => true }, { type: sectionTypes.RECAPTCHA.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => form.organisationConfiguration.recaptchaV2Enabled && !formState.recaptchaCompleted && !formState.socialSignin }, { type: sectionTypes.LOGIN_PASSWORD.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.userExists && !formState.socialSignin }, { type: sectionTypes.PASSWORD_SETUP.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => formConfigAs(form).usePassword && !formState.userExists && !formState.socialSignin }, { type: sectionTypes.PASSWORD_RESET.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.FORGOT_PASSWORD.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.VERIFICATION_CODE_LOGIN.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => (formState.userExists && (formConfigAs(form).useVerificationCodes || formState.socialSignin)) ?? false }, { type: sectionTypes.VERIFICATION_CODE_REGISTRATION.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => (!formState.userExists && (formConfigAs(form).useVerificationCodes || formState.emailIsContact)) ?? false }, { type: sectionTypes.REGISTRATION_CUSTOM.type, isDisplayedInProgressBar: true, isVisible: (_, formState) => !formState.userExists }, { type: sectionTypes.SUCCESS.type, isDisplayedInProgressBar: false, isVisible: () => true }, { type: sectionTypes.EMAIL_VERIFIED.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => form.organisationConfiguration.requireEmailVerfication && !(formConfigAs(form).useVerificationCodes) && !formState.socialSignin }, { type: sectionTypes.PASSWORDLESS_VIA_LOGIN_LINK.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formState.userExists && getFormIsPasswordless(form) } ]; const canAttemptSectionCompletion$9 = (_, formState) => { return !formState.elementValidity.filter(e => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some(e => !e.isValid); }; const sectionFlow$9 = { extraElements: [], eventHandlers: eventHandlers$a, sectionVisibilities: sectionVisibilities$8, canAttemptSectionCompletion: canAttemptSectionCompletion$9, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, canPartiallyRegister: true, }; const processResponse$1 = async (payload, response, form, formState, formActions) => { const json = await response.json(); if (response?.ok) { logConversion('CONTACT', form, formActions); window.Blaize?.postProcessFormData && window.Blaize.postProcessFormData(form.id, payload, json); return Promise.resolve(true); } // Handle errors const serverError = mapToServerError(response.status, json?.message, formState); formActions.updateFormState({ serverErrors: [serverError] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); if (ServerErrors[serverError].jumpToPart) { formActions.jumpToPartStart(ServerErrors[serverError].jumpToPart); } return Promise.resolve(false); }; const preprocessorIdentity$1 = (_, t) => t; const coerceAttributesBySchema = (attributes, schemaFields) => { if (!schemaFields?.length) return attributes; const result = { ...attributes }; for (const field of schemaFields) { const slug = field.slug; if (!(slug in result)) continue; const value = result[slug]; if (field["input-type"] === "checkbox" && (value === "true" || value === "false")) { result[slug] = value === "true"; } } return result; }; const toContactCreeatePayload = (form, formState) => { const autoAppliedAttributes = formConfigAs(form).autoApplyAttributes ?? {}; const preprocessor = window.Blaize?.preProcessFormData ?? preprocessorIdentity$1; const attributes = userAttributesValuesForPart(partTypes.CONTACT_VERIFICATION.type, form, formState); const attributesWithAutoApplied = coerceAttributesBySchema({ ...attributes, ...autoAppliedAttributes, }, form.organisationConfiguration?.schemaFields); return preprocessor(form.id, { identifiers: { email_address: formState.emailAddress }, attributes: Object.keys(attributesWithAutoApplied).length ? attributesWithAutoApplied : undefined, }); }; const registerContact = async (form, formState, formActions) => { const payload = toContactCreeatePayload(form, formState); const response = await request('zephr/createContact', { method: "POST", bodyObject: payload }, formActions); return processResponse$1(payload, response, form, formState, formActions); }; /** * Map of possible movements through the form sections for contact forms. */ const formStartAction$8 = async (_, __, formActions) => { await checkForRegisteredUser(formActions); }; // handle submit of email on first step or after additional attributes preferences provided const onContactVerificationComplete = async (form, formState, formActions) => { const config = formConfigAs(form); try { await registerContact(form, formState, formActions); if (config.showSuccessOnFormCompletion) { await jumpToPart(partTypes.SUCCESS.type, form, formActions); } else { window.location.reload(); } } catch (error) { console.error(error); await jumpToSection(sectionTypes.EMAIL.type, form, formActions); } }; const eventHandlers$9 = { [FormEvent.FORM_START]: formStartAction$8, [FormEvent.PART_CONTACT_VERIFICATION_COMPLETE]: onContactVerificationComplete, }; const sectionVisibilities$7 = [ { type: sectionTypes.EMAIL.type, isDisplayedInProgressBar: false, isVisible: () => true, }, { type: sectionTypes.REGISTRATION_CUSTOM.type, isDisplayedInProgressBar: false, isVisible: (_, formState) => !formState.userExists, }, ]; const canAttemptSectionCompletion$8 = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const sectionFlow$8 = { extraElements: [], eventHandlers: eventHandlers$9, sectionVisibilities: sectionVisibilities$7, canAttemptSectionCompletion: canAttemptSectionCompletion$8, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; const processResponse = async (payload, response, attributes, form, formState, formActions) => { if (response?.ok) { if (form.formType == FormType.UPDATE_PROFILE) { logDataLayerEvent(form, 'zephr_form_profile_update', { success: response?.ok, ...Object.entries(attributes).reduce((acc, [key, value]) => ({ ...acc, [`attr_${key}`]: value }), {}) }); } if (form.formType == FormType.DATA_CAPTURE) { logConversion('Data Captured', form, formActions); logDataLayerEvent(form, 'zephr_form_data_capture', { success: response?.ok, ...Object.entries(attributes).reduce((acc, [key, value]) => ({ ...acc, [`attr_${key}`]: value }), {}) }); } if (form.formType == FormType.COMPLETE_REGISTRATION) { logConversion('Completed Registration', form, formActions); logDataLayerEvent(form, 'zephr_form_complete_registration', { success: response?.ok, ...Object.entries(attributes).reduce((acc, [key, value]) => ({ ...acc, [`attr_${key}`]: value }), {}) }); } const json = await response.json(); payload && window.Blaize?.postProcessFormData && window.Blaize.postProcessFormData(form.id, payload, json); return Promise.resolve(true); } const responseMessage = (await response.json())?.message; const serverError = mapToServerError(response.status, responseMessage, formState); formActions.updateFormState({ serverErrors: [serverError] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[serverError], }); return Promise.resolve(false); }; const preprocessorIdentity = (_, t) => t; const toUpdateUserPayload = (form, formState, partType) => { const preprocessor = window.Blaize?.preProcessFormData ?? preprocessorIdentity; const attributes = userAttributesValuesForPart(partType, form, formState); const autoAppliedAttributes = formConfigAs(form).autoApplyAttributes ?? {}; return preprocessor(form.id, { ...attributes, ...autoAppliedAttributes, ...(formState.createPassword && { 'blaize-validator': formState.createPassword }), }); }; const updateUser = async (form, formState, formActions, partType) => { const payload = toUpdateUserPayload(form, formState, partType); if (formState.fireCancelationReasonEvent) { formActions.updateFormState({ cancelationReasonAttributes: payload }); } const response = await request('blaize/profile', { method: "PATCH", bodyObject: payload }, formActions); const attributes = userAttributesValuesForPart(partType, form, formState); return processResponse(payload, response, attributes, form, formState, formActions); }; const formStartAction$7 = async (form, formState, formActions) => { const hideIfSet = form.parts .map(e => e.sections) .reduce((acc, curr) => { const attrToHide = curr.map(e => e.elements .filter(e => e.type == "user_attribute" && e.config?.hideIfSet) .map(e => e.config?.slug) .filter(slug => slug != null)); return acc.concat(attrToHide); }, []) .flat(); const toRemove = []; try { const response = await request('blaize/profile', { method: "GET" }, formActions); if (response?.ok) { const responseJson = await response.json(); formConfigAs(form).autoApplyAttributes && Object.keys(formConfigAs(form).autoApplyAttributes).forEach(a => { if (Object.prototype.hasOwnProperty.call(responseJson, a)) { delete responseJson[a]; } }); hideIfSet.forEach(a => { if (Object.prototype.hasOwnProperty.call(responseJson, a)) { toRemove.push(a); } }); if (toRemove.length == Object.keys(formState.userAttributes).length && form.formType != FormType.COMPLETE_REGISTRATION) { console.warn("Not showing form as user has no attributes to update"); } else { formActions.updateFormState({ formPrerequisiteLoaded: true, hideIfSetAttributes: toRemove, userAttributes: { ...responseJson }, }); } } } catch (err) { console.error(err); } }; const onUpdateProfileComplete = async (form, formState, formActions) => { const config = formConfigAs(form); try { await updateUser(form, formState, formActions, partTypes.PROFILE_UPDATE.type) .then(async (success) => { if (success && config.showSuccessOnFormCompletion) { await jumpToPart(partTypes.SUCCESS.type, form, formActions); } else if (success) { window.location.reload(); } }); } catch (error) { console.error(error); } }; const eventHandlers$8 = { [FormEvent.FORM_START]: formStartAction$7, [FormEvent.PART_PROFILE_UPDATE_COMPLETE]: onUpdateProfileComplete, }; const sectionVisibilities$6 = []; const canAttemptSectionCompletion$7 = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const sectionFlow$7 = { extraElements: [], eventHandlers: eventHandlers$8, sectionVisibilities: sectionVisibilities$6, canAttemptSectionCompletion: canAttemptSectionCompletion$7, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => true, }; const startUpdateEmailFlow = async (form, formState, formActions) => { try { const updateEmailWithoutPassword = !formState.password; const payload = { current_identifiers: { email_address: formState.readOnlyEmail, }, new_identifiers: { email_address: formState.emailAddress, }, ...(updateEmailWithoutPassword ? {} : { validators: { password: formState.password, }, }), }; const response = await request(updateEmailWithoutPassword ? 'blaize/users/update-email' : 'zephr/users/update-email', { method: 'POST', bodyObject: payload, }, formActions); logDataLayerEvent(form, 'zephr_form_email_update_code_sent', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); return { success: false, isLinkBased: updateEmailWithoutPassword }; } return { success: true, isLinkBased: updateEmailWithoutPassword }; } catch (err) { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); return { success: false, isLinkBased: !formState.password }; } }; const endEmailUpdateFlow = async (form, formState, formActions) => { formActions.incrementRequestCount(); formActions.updateFormState({ verificationCodeValid: undefined }); const response = await request(`zephr/users/update-email/${formState.verificationCode}`, { method: "POST", bodyObject: { current_identifiers: { email_address: formState.readOnlyEmail, }, } }, formActions); logDataLayerEvent(form, 'zephr_form_password_reset_code_validate', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.VERIFICATION_CODE_INCORRECT] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.VERIFICATION_CODE_INCORRECT], }); formActions.decrementRequestCount(); return false; } await waitAfterCode(form); formActions.decrementRequestCount(); return true; }; const startPasswordUpdateFlow = async (form, formState, formActions) => { try { const payload = { current_validators: { password: formState.currentPassword, }, new_validators: { password: formState.createPassword, }, }; const response = await request('zephr/users/change-password', { method: 'POST', bodyObject: payload, }, formActions); logDataLayerEvent(form, 'zephr_form_password_update_code_sent', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); return false; } return true; } catch (err) { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); return false; } }; const endPasswordUpdateFlow = async (form, formState, formActions) => { formActions.incrementRequestCount(); formActions.updateFormState({ verificationCodeValid: undefined }); const response = await request(`zephr/users/change-password/${formState.verificationCode}`, { method: "GET", }, formActions); logDataLayerEvent(form, 'zephr_form_password_update_code_validate', { success: response?.ok }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.VERIFICATION_CODE_INCORRECT] }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.VERIFICATION_CODE_INCORRECT], }); formActions.decrementRequestCount(); return false; } await waitAfterCode(form); formActions.decrementRequestCount(); return true; }; const formStartAction$6 = async (_, __, formActions) => { formActions.incrementRequestCount(); try { await Promise.all([fetchProfile(formActions), fetchEmail(formActions)]); } finally { formActions.decrementRequestCount(); } }; const startEmailUpdate = async (form, formState, formActions) => { const result = await startUpdateEmailFlow(form, formState, formActions); if (result.success) { if (result.isLinkBased) { // Passwordless flow - show confirmation message to check email for link // Check if confirmation part exists in form config (defensive guard for legacy forms) const hasConfirmationPart = form.parts.some(p => p.type === partTypes.EMAIL_UPDATE_CONFIRMATION.type); if (hasConfirmationPart) { await jumpToPart(partTypes.EMAIL_UPDATE_CONFIRMATION.type, form, formActions); } else { // Fallback: show OTP screen for legacy forms without confirmation part await jumpToPart(partTypes.EMAIL_UPDATE_OTP.type, form, formActions); } } else { // Password-protected flow - show OTP code input screen await jumpToPart(partTypes.EMAIL_UPDATE_OTP.type, form, formActions); } } }; const endEmailUpdate = async (form, formState, formActions) => { const success = await endEmailUpdateFlow(form, formState, formActions); if (success) { await reset(form, formState, formActions, true); } }; const startPasswordUpdate = async (form, formState, formActions) => { const success = await startPasswordUpdateFlow(form, formState, formActions); if (success) { await jumpToPart(partTypes.PASSWORD_UPDATE_OTP.type, form, formActions); } }; const endPasswordUpdate = async (form, formState, formActions) => { const success = await endPasswordUpdateFlow(form, formState, formActions); if (success) { await reset(form, formState, formActions, true); } }; const onUpdateAttributes$1 = async (form, formState, formActions) => { const submitSuccess = await updateUser(form, formState, formActions, partTypes.ATTRIBUTES_UPDATE.type); if (submitSuccess) { await reset(form, formState, formActions, true); } }; const goBack$1 = async (form, formState, formActions) => reset(form, formState, formActions, false); const jumpToUserAttributeUpdate = async (form, _, formActions) => { await jumpToPart(partTypes.ATTRIBUTES_UPDATE.type, form, formActions); }; const reset = async (form, formState, formActions, wait) => { formActions.updateFormState({ emailAddress: null, password: null, createPassword: null, passwordIsValid: null, verificationCode: null, currentPassword: null, serverErrors: [], }); if (wait) { await formStartAction$6(form, formState, formActions); } else { void formStartAction$6(form, formState, formActions); } await jumpToPart(partTypes.PROFILE_UPDATE.type, form, formActions); }; const fetchProfile = async (formActions) => { try { const response = await request('blaize/profile', { method: "GET" }, formActions); const json = await response.json(); formActions.updateFormState({ readOnlyAttributeValues: json, }); } catch (err) { console.error("Unable to load user profile", err); } }; const fetchEmail = async (formActions) => { try { const response = await request('blaize/account', { method: "GET" }, formActions); const email = (await response.json())?.identifiers.email_address; formActions.updateFormState({ readOnlyEmail: email }); } catch (err) { console.error("Unable to load user email", err); } }; const eventHandlers$7 = { [FormEvent.FORM_START]: formStartAction$6, [FormEvent.GO_BACK]: goBack$1, [FormEvent.UPDATE]: jumpToUserAttributeUpdate, [FormEvent.PART_EMAIL_UPDATE_COMPLETE]: startEmailUpdate, [FormEvent.VERIFY_EMAIL_UPDATE_OTP]: endEmailUpdate, [FormEvent.PART_PASSWORD_UPDATE_COMPLETE]: startPasswordUpdate, [FormEvent.VERIFY_PASSWORD_UPDATE_OTP]: endPasswordUpdate, [FormEvent.PART_ATTRIBUTES_UPDATE_COMPLETE]: onUpdateAttributes$1, }; const canAttemptSectionCompletion$6 = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const sectionFlow$6 = { extraElements: [], eventHandlers: eventHandlers$7, sectionVisibilities: [], canAttemptSectionCompletion: canAttemptSectionCompletion$6, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; const formStartAction$5 = async (form, formState, formActions) => { const hasDynamicOfferAttached = !!formConfigAs(form).dynamicOffer?.id; const hasCancelReason = formConfigAs(form).hasCancelReason; const hasSaveOffer = formConfigAs(form).hasSaveOffer; // Skip Dynamic Offer fetch if we need to capture cancellation reason first // This ensures the cancellation reason is available as a user attribute for Dynamic Offer filtering const shouldFetchDynamicOfferNow = hasDynamicOfferAttached && !(hasSaveOffer && hasCancelReason); if (shouldFetchDynamicOfferNow) { await getDynamicOffer(form, formActions).catch((e) => { console.error('Error loading Dynamic Offer', e); }); formState = formActions.getFormState(); } const existingSubscriptions = formConfigAs(form).hasSaveOffer ? await loadExistingSubscriptions$1(form, formState, formActions, shouldFetchDynamicOfferNow, false) : await loadExistingSubscriptions(form, formState, formActions, true); const subscriptionQueryParam = getSubscriptionParam(window.location.href); if (!subscriptionQueryParam) { return; } const queryParamSubscription = existingSubscriptions.find(subscription => subscription.externalId === subscriptionQueryParam); if (queryParamSubscription) { formActions.updateFormState({ selectedSubscription: queryParamSubscription, isExternalReferrer: true, }); formActions.completeSection(); } }; const cancel = async (form, formActions) => { const formState = formActions.getFormState(); try { const response = await request(`zephr/subscriptions/${formState.selectedSubscription.externalId}`, { method: 'DELETE', }, formActions); if (response.ok) { if (formState.fireCancelationReasonEvent) { logDataLayerEvent(form, 'zephr_form_subscription_cancel_reason', { productId: formState.selectedSubscription.productId, ...Object.entries(formState.cancelationReasonAttributes).reduce((acc, [key, value]) => ({ ...acc, [`attr_${key}`]: value }), {}) }); } logDataLayerEvent(form, 'zephr_form_subscription_cancel', { productId: formState.selectedSubscription.productId, productLabel: formState.selectedSubscription.productLabel, currency: formState.selectedSubscription.currency, amount: formState.selectedSubscription.amount, }); if (form.parts.some(e => e.type == partTypes.CANCEL_SUCCESS.type)) { formActions.jumpToPartStart(partTypes.CANCEL_SUCCESS.type); } else { formActions.jumpToPartStart(partTypes.SUCCESS.type); } } else { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } } catch (error) { console.error("Error occurred while cancelling subscription.", error); formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } }; const onSubscriptionSelectComplete$3 = async (form, formState, formActions) => { if (formConfigAs(form).hasCancelReason) { formActions.updateFormState({ fireCancelationReasonEvent: true, cancelFlowSubscriptionSelectedId: formState.selectedSubscription.externalId, }); formActions.jumpToPartStart(partTypes.ATTRIBUTES_UPDATE.type); } else if (formState.validChangeFromPlans.length === 0) { await cancel(form, formActions); } else if (formConfigAs(form).hasSaveOffer) { formActions.updateFormState({ cancelFlowSubscriptionSelectedId: formState.selectedSubscription.externalId, }); formActions.jumpToPartStart(partTypes.PLAN_SELECT.type); } else { await cancel(form, formActions); } }; const onPlanSelectComplete$2 = async (form, formState, formActions) => { if (formState.confirmCancel) { await cancel(form, formActions); } else { const state = formActions.getFormState(); const updatedState = await getProductAddons(form, state, formActions); void calculatePrices(form, updatedState, formActions); void calculateChangeSubscriptionProrate(form, updatedState, formActions); formActions.updateFormState({ convertCancelSubscriptionToAcceptOffer: true, }); formActions.jumpToPartStart(partTypes.PAYMENT.type); } }; const onUpdateAttributes = async (form, formState, formActions) => { const submitSuccess = await updateUser(form, formState, formActions, partTypes.ATTRIBUTES_UPDATE.type); if (!submitSuccess) { return; } // Fetch Dynamic Offer now that cancellation reason is available as a user attribute const hasDynamicOfferAttached = !!formConfigAs(form).dynamicOffer?.id; const hasSaveOffer = formConfigAs(form).hasSaveOffer; if (hasDynamicOfferAttached && hasSaveOffer) { await getDynamicOffer(form, formActions).catch((e) => { console.error('Error loading Dynamic Offer', e); }); // Filter subscriptions with the newly fetched Dynamic Offer result const updatedFormState = formActions.getFormState(); const existingSubscriptions = updatedFormState.existingSubscriptions || []; if (existingSubscriptions.length > 0) { filterDynamicOfferChangeFromPlans(existingSubscriptions, updatedFormState, formActions, updatedFormState.requiresPaymentMethodSetup || false); } formState = formActions.getFormState(); } if (formState.validChangeFromPlans.length === 0) { await cancel(form, formActions); } else if (hasSaveOffer) { formActions.jumpToPartStart(partTypes.PLAN_SELECT.type); } else { await cancel(form, formActions); } }; const goBack = async (_, __, formActions) => { formActions.jumpToPartStart(partTypes.SELECT_SUBSCRIPTION.type); return Promise.resolve(); }; const eventHandlers$6 = { [FormEvent.FORM_START]: formStartAction$5, [FormEvent.SELECT_SUBSCRIPTION_COMPLETE]: onSubscriptionSelectComplete$3, [FormEvent.GO_BACK]: goBack, [FormEvent.PART_PLAN_SELECT_COMPLETE]: onPlanSelectComplete$2, [FormEvent.PART_PAYMENT_COMPLETE]: pay, [FormEvent.PART_ATTRIBUTES_UPDATE_COMPLETE]: onUpdateAttributes, }; const extraElements$1 = [ { type: elementTypes.PAYMENT_PRE_LOADER, order: -1, }, ]; const cancelSubscriptionSectionFlow = { extraElements: extraElements$1, eventHandlers: eventHandlers$6, sectionVisibilities: [], canAttemptSectionCompletion: (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; const formStartAction$4 = async (form, formState, formActions) => { const existingSubscriptions = await loadExistingSubscriptions(form, formState, formActions, true); const subscriptionQueryParam = getSubscriptionParam(window.location.href); if (!subscriptionQueryParam) { return; } const queryParamSubscription = existingSubscriptions.find(subscription => subscription.externalId === subscriptionQueryParam); if (queryParamSubscription) { formActions.updateFormState({ selectedSubscription: queryParamSubscription, isExternalReferrer: true, }); formActions.completeSection(); } }; const onSubscriptionSelectComplete$2 = (form, formState, formActions) => { formActions.updateFormState({ suspendResumeFlowSubscriptionSelectedId: formState.selectedSubscription.externalId, }); formActions.jumpToPartStart(partTypes.SUSPEND_RESUME_SUBSCRIPTION.type); }; const suspendResumeSubscriptionComplete = async (form, formState, formActions) => { try { const response = await request(`zephr/subscriptions/${formState.selectedSubscription.externalId}/manage`, { method: 'POST', bodyObject: { vendor_fields: { order: JSON.stringify({ subscription: { orderActions: [ { type: 'Suspend', suspend: { suspendPolicy: 'SpecificDate', suspendSpecificDate: formState.suspendResumeSubscription.suspensionDate, } }, { type: 'Resume', resume: { resumePolicy: 'SpecificDate', resumeSpecificDate: formState.suspendResumeSubscription.resumeDate, extendsTerm: true, } } ] } }) } } }, formActions); if (response.ok) { logDataLayerEvent(form, 'zephr_form_subscription_suspend', { productId: formState.selectedSubscription.productId, productLabel: formState.selectedSubscription.productLabel, currency: formState.selectedSubscription.currency, amount: formState.selectedSubscription.amount, }); formActions.jumpToPartStart(partTypes.SUCCESS.type); } else { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } } catch (error) { console.error("Error occurred while suspending subscription.", error); formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } }; const eventHandlers$5 = { [FormEvent.FORM_START]: formStartAction$4, [FormEvent.SELECT_SUBSCRIPTION_COMPLETE]: onSubscriptionSelectComplete$2, [FormEvent.SUSPEND_RESUME_SUBSCRIPTION_COMPLETE]: suspendResumeSubscriptionComplete, }; const sectionVisibilities$5 = []; const canAttemptSectionCompletion$5 = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const sectionFlow$5 = { extraElements: [], eventHandlers: eventHandlers$5, sectionVisibilities: sectionVisibilities$5, canAttemptSectionCompletion: canAttemptSectionCompletion$5, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; const formStartAction$3 = async (form, formState, formActions) => { await loadDeviceSessions(form, formState, formActions); }; const eventHandlers$4 = { [FormEvent.FORM_START]: formStartAction$3, }; const sectionVisibilities$4 = []; const canAttemptSectionCompletion$4 = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const sectionFlow$4 = { extraElements: [], eventHandlers: eventHandlers$4, sectionVisibilities: sectionVisibilities$4, canAttemptSectionCompletion: canAttemptSectionCompletion$4, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; /** * Map of possible movements through the form sections for gift subscription forms. */ // Handle the completion of the recipient details section const onGiftRecipientComplete = async (form, formState, formActions) => { // Check if user is logged in using existing session state if (formState.loginRegistrationComplete) { // If logged in, jump directly to payment section await jumpToPart(partTypes.PAYMENT.type, form, formActions); } else { // If not logged in, continue with normal flow to account verification await jumpToSection(sectionTypes.EMAIL.type, form, formActions); } }; // Modified pay service for gift subscription const payWithGiftInfo = async (form, formState, formActions) => { try { // Add gift recipient info to the payment metadata const giftRecipient = formState.giftRecipient; if (!giftRecipient) { throw new Error("Gift recipient information is missing"); } // Call the standard payment flow - the gift-specific logic is handled in zuoraService.ts // which will make the actual API call to create the gift subscription return await pay(form, formState, formActions); } catch (error) { console.error("Error in gift subscription payment:", error); // Use the language pack for error message const errorMessage = resolveLanguagePackKeyTyped(form, 'forms.errors.unknown-payment-error', "Payment failed"); // Display the error message formActions.updateFormState({ dynamicServerErrorMessage: errorMessage }); throw error; } }; // Customize the payment flow's PART_PLAN_SELECT_COMPLETE handler to add our gift recipient step const onPlanSelectComplete$1 = async (form, formState, formActions) => { // Check gift form mode FIRST, before calling payment flow handler if (formState.isGiftForm) { // If gift mode is enabled, check if recipient details are valid before jumping const recipientDetailsElementTypes = [ 'recipient_name', 'recipient_email', 'recipient_address', 'recipient_message' ]; // Check if all recipient details elements are valid const recipientDetailsValid = recipientDetailsElementTypes.every(elementType => { const elementValidity = formState.elementValidity.find(e => e.elementType === elementType && e.sectionType === 'recipient_details'); return elementValidity ? elementValidity.isValid : false; }); // Calculate prices first (from payment form flow) await sectionFlow$a.eventHandlers[FormEvent.PART_PLAN_SELECT_COMPLETE](form, formState, formActions); // Then navigate to recipient details if they are not valid if (!recipientDetailsValid) { await jumpToSection('recipient_details', form, formActions); } // If recipient details are valid, the payment handler already navigated correctly } else { // If gift mode is disabled, just run the standard payment flow await sectionFlow$a.eventHandlers[FormEvent.PART_PLAN_SELECT_COMPLETE](form, formState, formActions); } }; // Starting with the payment form handlers, override only what we need const eventHandlers$3 = { ...sectionFlow$a.eventHandlers, [FormEvent.FORM_START]: async (form, formState, formActions) => { // Execute the standard payment form start handler await sectionFlow$a.eventHandlers[FormEvent.FORM_START](form, formState, formActions); // Check if the form has any gift toggle elements const hasGiftToggleElements = form.parts .flatMap(part => part.sections) .flatMap(section => section.elements) .some(element => element.type === elementTypes.GIFT_TOGGLE); // Initialize the gift form state based on whether gift toggle elements are present // If no gift toggle elements are found, assume this is a dedicated gift form (isGiftForm = true) // If gift toggle elements are present, default to regular subscription mode (isGiftForm = false) formActions.updateFormState({ isGiftForm: !hasGiftToggleElements, // true if no toggles (dedicated gift form), false if toggles exist giftRecipient: { firstName: '', lastName: '', email: '', recipientAddress: { addressLine1: '', addressLine2: '', city: '', state: '', country: '', postalCode: '' }, customMessage: '', futureDeliveryEnabled: false, futureDeliveryDate: '' } }); }, // Override plan select to redirect to gift recipient conditionally [FormEvent.PART_PLAN_SELECT_COMPLETE]: onPlanSelectComplete$1, // Add gift recipient handler [FormEvent.PART_GIFT_RECIPIENT_COMPLETE]: onGiftRecipientComplete, // Override payment complete to include gift logic [FormEvent.PART_PAYMENT_COMPLETE]: payWithGiftInfo, }; // Add our new section visibility for recipient details const sectionVisibilities$3 = [ ...sectionFlow$a.sectionVisibilities, { type: sectionTypes.RECIPIENT_DETAILS.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => { // Only show recipient details section if gift form mode is enabled return formState.isGiftForm === true; } } ]; const canAttemptSectionCompletion$3 = (form, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; // Inherit other properties from payment flow const sectionFlow$3 = { extraElements: sectionFlow$a.extraElements, sectionVisibilities: sectionVisibilities$3, eventHandlers: eventHandlers$3, canAttemptSectionCompletion: canAttemptSectionCompletion$3, canDismissFormManually: sectionFlow$a.canDismissFormManually, formRequiresPrerequisiteLoading: sectionFlow$a.formRequiresPrerequisiteLoading, canPartiallyRegister: true }; const validateGiftCode = async (form, formState, formActions) => { const giftCode = formState.giftCode; try { // First check locally if gift code is valid length if (!giftCode || giftCode.length !== 16) { formActions.updateFormState({ giftCodeError: resolveLanguagePackKeyTyped(form, 'forms.errors.gift-code-invalid-length', 'Gift code must be 16 characters long') }); return false; } formActions.incrementRequestCount(); const response = await request('zephr/public/gifts/v1/redeem', { method: 'POST', bodyObject: { giftCode: giftCode, }, }, formActions); // Log event for gift redemption attempt logDataLayerEvent(form, 'zephr_form_gift_redeem', { success: response.ok, }); if (!response.ok) { formActions.updateFormState({ serverErrors: [ServerError.GIFT_CODE_INVALID], giftCodeError: resolveLanguagePackKeyTyped(form, 'forms.errors.gift-code-invalid', 'The gift code you entered is invalid'), }); formActions.decrementRequestCount(); return false; } formActions.decrementRequestCount(); await jumpToSection(sectionTypes.GIFT_REDEEMED.type, form, formActions); return true; } catch (error) { formActions.updateFormState({ serverErrors: [ServerError.GIFT_CODE_SERVER_ERROR], giftCodeError: resolveLanguagePackKeyTyped(form, 'forms.errors.gift-code-server-error', 'An error occurred processing your gift code'), }); formActions.decrementRequestCount(); return false; } }; const GIFT_REDEMPTION_PART = "gift_redemption"; const onGiftRedemptionComplete = async (form, formState, formActions) => { await validateGiftCode(form, formState, formActions); }; const formStartAction$2 = async (form, formState, formActions) => { // If user session is already set, we don't need to check again if (formState.userSession) { // Skip registration and go straight to gift redemption if user is logged in const giftRedemptionPart = form.parts.find(part => part.type === "gift_redemption"); if (giftRedemptionPart) { formActions.updateFormState({ currentPart: giftRedemptionPart, currentSection: giftRedemptionPart.sections[0], userSession: true, loginRegistrationComplete: true }); } return; } // Otherwise check for user session const userSession = await checkForRegisteredUser(formActions); if (userSession) { // Skip registration and go straight to gift redemption if user is logged in const giftRedemptionPart = form.parts.find(part => part.type === "gift_redemption"); if (giftRedemptionPart) { formActions.updateFormState({ currentPart: giftRedemptionPart, currentSection: giftRedemptionPart.sections[0], userSession: true, loginRegistrationComplete: true }); } } }; const onLoginRegisterComplete = async (form, formState, formActions) => { // Instead of reloading page or showing success, go straight to gift redemption await jumpToPart(GIFT_REDEMPTION_PART, form, formActions); return Promise.resolve(); }; const canAttemptSectionCompletion$2 = (form, formState) => { // Check if we're in the gift redemption section and enforce validation if (formState.currentSection.type === sectionTypes.GIFT_REDEMPTION.type) { const giftCodeElement = formState.elementValidity.find(e => e.elementType === elementTypes.GIFT_CODE && e.sectionType === formState.currentSection.type); if (giftCodeElement && !giftCodeElement.isValid) { return false; } if (formState.giftCode?.length !== 16) { return false; } } // For other sections, use the default registration flow validation return sectionFlow$9.canAttemptSectionCompletion(form, formState); }; const eventHandlers$2 = { ...sectionFlow$9.eventHandlers, [FormEvent.FORM_START]: formStartAction$2, [FormEvent.GIFT_REDEMPTION_COMPLETE]: onGiftRedemptionComplete, [FormEvent.LOGIN_REGISTRATION_COMPLETE]: onLoginRegisterComplete, // Override the registration flow handler }; // Add gift redemption specific section visibilities while inheriting registration ones const sectionVisibilities$2 = [ { type: sectionTypes.EMAIL.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => !formState.userSession }, { type: sectionTypes.LOGIN_PASSWORD.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => !formState.userSession && formConfigAs(form).usePassword && formState.userExists && !formState.socialSignin }, { type: sectionTypes.PASSWORD_SETUP.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => !formState.userSession && formConfigAs(form).usePassword && !formState.userExists && !formState.socialSignin }, { type: sectionTypes.PASSWORD_RESET.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => !formState.userSession && formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.FORGOT_PASSWORD.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => !formState.userSession && formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.GIFT_REDEMPTION.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => { // Show after registration is complete or if user is logged in return formState.loginRegistrationComplete || formState.userSession; } }, { type: sectionTypes.GIFT_REDEEMED.type, isDisplayedInProgressBar: false, isVisible: () => true } ]; const sectionFlow$2 = { ...sectionFlow$9, eventHandlers: eventHandlers$2, sectionVisibilities: sectionVisibilities$2, canAttemptSectionCompletion: canAttemptSectionCompletion$2, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, canPartiallyRegister: true }; const formStartAction$1 = async (form, formState, formActions) => { const existingSubscriptions = await loadExistingSubscriptions(form, formState, formActions, true); const subscriptionQueryParam = getSubscriptionParam(window.location.href); if (!subscriptionQueryParam) { return; } const queryParamSubscription = existingSubscriptions.find(subscription => subscription.externalId === subscriptionQueryParam); if (queryParamSubscription) { formActions.updateFormState({ selectedSubscription: queryParamSubscription, isExternalReferrer: true, }); formActions.completeSection(); } }; const onSubscriptionSelectComplete$1 = (form, formState, formActions) => { formActions.jumpToPartStart(partTypes.BILL_TO_CONTACT.type); }; const onBillToContactComplete = async (form, formState, formActions) => { try { const response = await request(`zephr/accounts/${formState.selectedSubscription.accountId}/update`, { method: 'PATCH', bodyObject: { vendor_fields: { account: JSON.stringify({ billToContact: formState.billToContact }) } } }, formActions); if (response.ok) { logDataLayerEvent(form, 'zephr_form_bill_to_contact_change', { accountId: formState.selectedSubscription.accountId, billToContact: formState.billToContact }); formActions.jumpToPartStart(partTypes.SUCCESS.type); } else { formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } } catch (error) { console.error("Error occurred while updating bill to contact address.", error); formActions.updateFormState({ serverErrors: [ServerError.UNKNOWN], }); logDataLayerEvent(form, 'zephr_form_error', { error: ServerError[ServerError.UNKNOWN], }); } }; const eventHandlers$1 = { [FormEvent.FORM_START]: formStartAction$1, [FormEvent.SELECT_SUBSCRIPTION_COMPLETE]: onSubscriptionSelectComplete$1, [FormEvent.BILL_TO_CONTACT_COMPLETE]: onBillToContactComplete, }; const sectionVisibilities$1 = []; const canAttemptSectionCompletion$1 = (_, formState) => { return !formState.elementValidity .filter((e) => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .some((e) => !e.isValid); }; const sectionFlow$1 = { extraElements: [], eventHandlers: eventHandlers$1, sectionVisibilities: sectionVisibilities$1, canAttemptSectionCompletion: canAttemptSectionCompletion$1, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }; const getEffectivePricing = (charge) => charge.pricingWaterfalls.base_price?.pricing ?? null; const mapCatalogRuleResultToPaymentOptions = (catalogRuleResult) => { const paymentOptions = []; for (const item of catalogRuleResult) { const { product, plans } = item; const activePlans = plans.filter(plan => plan.status === 'ACTIVE'); for (const plan of activePlans) { const prices = []; const allDiscountPercentages = []; const allDiscountAmounts = []; for (const charge of plan.productRatePlanCharges) { const pricing = getEffectivePricing(charge); if (!pricing) continue; if (charge.chargeModel === 'flat_fee') { for (const [currency, amount] of Object.entries(pricing.flatAmounts ?? {})) { prices.push({ currency, amount }); } } else if (charge.chargeModel === 'discount_percentage') { for (const [currency, percentage] of Object.entries(pricing.discountPercentages ?? {})) { allDiscountPercentages.push({ id: charge.id, name: charge.name, description: charge.description, currency, percentage }); } } else if (charge.chargeModel === 'discount_fixed_amount') { for (const [currency, amount] of Object.entries(pricing.discountAmounts ?? {})) { allDiscountAmounts.push({ id: charge.id, name: charge.name, description: charge.description, currency, amount }); } } } const primaryPrice = prices[0]; const priceCurrency = primaryPrice?.currency; const discountPercentages = allDiscountPercentages.filter(d => d.currency === priceCurrency); const discountAmounts = allDiscountAmounts.filter(d => d.currency === priceCurrency); paymentOptions.push({ slug: plan.id, productId: product.id, price: primaryPrice?.amount ?? 0, currencyCode: primaryPrice?.currency ?? '', type: plan.productRateplanType ?? 'subscription', selectButtonText: 'Select Plan', description: plan.description ?? '', label: plan.name, fieldOrder: paymentOptions.length, disclaimerMessage: '', discountPercentages, discountAmounts, }); } } return paymentOptions; }; const getCatalogRuleResult = async (form, formActions) => { formActions.updateFormState({ loadingCatalogPlans: true, }); const catalogRuleId = formConfigAs(form).catalogRule?.id; const catalogRulePreview = formConfigAs(form).catalogRulePreview; if (form.environment.previewMode) { formActions.updateFormState({ loadingCatalogPlans: false, catalogRulePaymentOptions: catalogRulePreview }); return; } let session; let jwt; try { session = document.cookie.match(/blaize_session=[0-9a-z-]+/)[0].substring(15); } catch { session = null; } try { jwt = document.cookie.match(/(? { const hasCatalogRuleAttached = !!formConfigAs(form).catalogRule?.id || !!formConfigAs(form).catalogRulePreview; if (hasCatalogRuleAttached) { await getCatalogRuleResult(form, formActions).catch((e) => { console.error('Error loading Catalog Rule', e); }); } return checkForRegisteredUser(formActions) .then(async (alreadyRegistered) => { checkForRegisteredUserResolve(checkForRegisteredUserResolve); if (formConfigAs(form).changeSubscriptionMode) { formActions.updateFormState({ formCannotBeActioned: !alreadyRegistered }); await loadExistingSubscriptions$1(form, formActions.getFormState(), formActions, false, true); const subscriptionQueryParam = getSubscriptionParam(window.location.href); if (subscriptionQueryParam && formActions.getFormState().existingSubscriptions.length === 1) { formActions.jumpToPartStart(partTypes.PLAN_SELECT.type); } } }); }; const onPlanSelectComplete = (form, formState, formActions) => // After plan select, wait to see if the user is already logged in checkForRegisteredUserPromise .then(() => { const state = formActions.getFormState(); if (state.userSession || state.loginRegistrationComplete) { // const updatedState = await getProductAddons(form, state, formActions) void calculatePrices(form, state, formActions) .then(formState => logDataLayerEvents(form, formState)); void calculateChangeSubscriptionProrate(form, state, formActions); // If payment method setup is required, go to change-payment part first const hasChangePaymentPart = form.parts.some(p => p.type === partTypes.CHANGE_PAYMENT.type); if (state.requiresPaymentMethodSetup && !state.paymentMethodSetupComplete && hasChangePaymentPart) { formActions.jumpToPartStart(partTypes.CHANGE_PAYMENT.type); } else { formActions.jumpToPartStart(partTypes.PAYMENT.type); } } else { void calculatePrices(form, formState, formActions) .then(formState => logDataLayerEvents(form, formState)); void calculateChangeSubscriptionProrate(form, formState, formActions); formActions.jumpToPartStart(partTypes.ACCOUNT_VERIFICATION.type); } }); const logDataLayerEvents = (form, formState) => { // don't trigger data layer events for other form types that override this flow (i.e. gift subscription form) if (form.organisationConfiguration.trackFormDataLayerEvents && form.formType == FormType.CATALOG_PAYMENT) { const paymentOption = formState.paymentOption; // await calculatePrices(form, formActions.getFormState(), formActions); const paymentOptionPrice = formState.paymentOptionPrices?.totalPrice; logDataLayerEvent(form, 'zephr_form_payment_option_selected', { productId: paymentOption.productId, planId: paymentOption.slug, price: paymentOptionPrice, }); logDataLayerEvent(form, 'select_item', { ecommerce: { items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOptionPrice, quantity: 1 }] } }); logDataLayerEvent(form, 'add_to_cart', { ecommerce: { currency: formConfigAs(form).formCurrency ?? paymentOption?.currencyCode, value: paymentOptionPrice, items: [{ item_id: paymentOption.slug, item_name: paymentOption.productId, price: paymentOptionPrice, quantity: 1 }] } }); } }; const onAccountVerificationComplete = (form, formState, formActions) => (formState.userExists ? login : register)(form, formState, formActions); const onSuccessComplete = (form, formState, formActions) => submitUserAttributesForPart(partTypes.SUCCESS.type, form, formState, formActions) .then(() => { const redirectPath = formConfigAs(form).successfulPaymentRedirectUrl?.trim(); if (redirectPath) { const isAllowedRedirectPath = redirectPath.startsWith('/') && !redirectPath.startsWith('//'); if (isAllowedRedirectPath) { window.location.href = `${window.location.origin}${redirectPath}`; } else { window.location.reload(); } } else { window.location.reload(); } }); const onLoginRegister = (form, _, formActions) => calculatePrices(form, formActions.getFormState(), formActions) .then(() => formActions.jumpToPartStart(partTypes.PAYMENT.type)); const onSubscriptionSelectComplete = (form, formState, formActions) => { const changeFromPlans = getChangeFromPlans([formState.selectedSubscription], form); formActions.updateFormState({ existingSubscriptions: [formState.selectedSubscription], formCannotBeActioned: changeFromPlans.length === 0, validChangeFromPlans: changeFromPlans, formPrerequisiteLoaded: true, }); formActions.jumpToPartStart(partTypes.PLAN_SELECT.type); }; const eventHandlers = { [FormEvent.FORM_START]: formStartAction, [FormEvent.LOGIN_REGISTRATION_COMPLETE]: onLoginRegister, [FormEvent.SECTION_EMAIL_COMPLETE]: onEmailEntered, [FormEvent.SECTION_PASSWORD_RESET_COMPLETE]: resetPassword, [FormEvent.SECTION_FORGOT_PASSWORD_COMPLETE]: verifiyPasswordResetCode, [FormEvent.PART_PLAN_SELECT_COMPLETE]: onPlanSelectComplete, [FormEvent.PART_ACCOUNT_VERIFICATION_COMPLETE]: onAccountVerificationComplete, [FormEvent.PART_PAYMENT_COMPLETE]: pay, [FormEvent.PART_SUCCESS_COMPLETE]: onSuccessComplete, [FormEvent.SELECT_SUBSCRIPTION_COMPLETE]: onSubscriptionSelectComplete, [FormEvent.PART_CHANGE_PAYMENT_COMPLETE]: changePayment, }; const sectionVisibilities = [ { type: sectionTypes.EMAIL.type, isDisplayedInProgressBar: true, isVisible: (form) => !formConfigAs(form).changeSubscriptionMode }, { type: sectionTypes.LOGIN_PASSWORD.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.userExists && !formState.socialSignin }, { type: sectionTypes.PASSWORD_SETUP.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && !formState.userExists && !formState.socialSignin }, { type: sectionTypes.SUCCESS.type, isDisplayedInProgressBar: false, isVisible: () => true }, { type: sectionTypes.PASSWORD_RESET.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.FORGOT_PASSWORD.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => formConfigAs(form).usePassword && formState.forgotPassword }, { type: sectionTypes.VERIFICATION_CODE_LOGIN.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => (formState.userExists && (formConfigAs(form).useVerificationCodes || formState.socialSignin)) ?? false }, { type: sectionTypes.VERIFICATION_CODE_REGISTRATION.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => (!formState.userExists && (formConfigAs(form).useVerificationCodes || formState.emailIsContact)) ?? false }, { type: sectionTypes.REGISTRATION_CUSTOM.type, isDisplayedInProgressBar: true, isVisible: (form, formState) => !formState.userExists }, { type: sectionTypes.CHANGE_PAYMENT.type, isDisplayedInProgressBar: false, isVisible: (form, formState) => { const paymentConfig = formConfigAs(form); return paymentConfig.changeSubscriptionMode && paymentConfig.allowNoPaymentMethodUpgrade && formState.requiresPaymentMethodSetup === true && !formState.paymentMethodSetupComplete; } } ]; const canAttemptSectionCompletion = (form, formState) => { const providerConfig = paymentProviderFor(form.organisationConfiguration.paymentProvider); return !formState.elementValidity.filter(e => e.partType === formState.currentPart.type && e.sectionType === formState.currentSection.type && e.sectionOrder === formState.currentSection.order) .filter(e => !(e.elementType === elementTypes.PAYMENT && providerConfig.canAttemptIncompletePaymentFormSubmission && formState.paymentProviderFormLoaded)) .some(e => !e.isValid); }; const canDismissFormManually = (form) => formConfigAs(form).changeSubscriptionMode; const formRequiresPrerequisiteLoading = (form) => formConfigAs(form).changeSubscriptionMode; const extraElements = [ { type: elementTypes.PAYMENT_PRE_LOADER, order: -1, }, ]; const sectionFlow = { extraElements, sectionVisibilities, eventHandlers, canAttemptSectionCompletion, canDismissFormManually, formRequiresPrerequisiteLoading }; const sectionFlows = { [FormType.PAYMENT]: sectionFlow$a, [FormType.CHANGE_SUBSCRIPTION]: sectionFlow$a, [FormType.REGISTRATION]: sectionFlow$9, [FormType.CONTACT]: sectionFlow$8, [FormType.DATA_CAPTURE]: sectionFlow$7, [FormType.COMPLETE_REGISTRATION]: sectionFlow$7, [FormType.UPDATE_PROFILE]: sectionFlow$6, [FormType.CANCEL_SUBSCRIPTION]: cancelSubscriptionSectionFlow, [FormType.LIST_SUBSCRIPTIONS]: listSubscriptionsSectionFlow, [FormType.LIST_GIFT_SUBSCRIPTIONS_SENT]: listSubscriptionsSectionFlow, [FormType.DEVICES]: sectionFlow$4, [FormType.GIFT_SUBSCRIPTION]: sectionFlow$3, [FormType.GIFT_REDEMPTION]: sectionFlow$2, [FormType.SUSPEND_RESUME_SUBSCRIPTION]: sectionFlow$5, [FormType.BILL_TO_CONTACT]: sectionFlow$1, [FormType.EMPTY]: { extraElements: [], sectionVisibilities: [], eventHandlers: {}, canAttemptSectionCompletion: () => true, canDismissFormManually: () => false, formRequiresPrerequisiteLoading: () => false, }, [FormType.CATALOG_PAYMENT]: sectionFlow }; const sectionFlowFor = (formType) => { const flow = sectionFlows[formType]; if (!flow) { throw `No flow for form type ${formType}`; } return flow; }; const baselineCssVariablesTimestamp = Date.parse("2024-04-19T00:00:00Z"); const baselineCssVariables = { "--zf-container-color": "unset", "--zf-container-bgColor": "#fff", "--zf-container-borderRadius": "0", "--zf-input-bgColor": "#fff", "--zf-payment-options-border": "1px solid #000", "--zf-payment-options-color": "#000", "--zf-payment-options-bgColor": "#fff", "--zf-payment-summary-border": "1px solid #000", "--zf-payment-summary-borderRadius": "0", "--zf-payment-summary-color": "unset", "--zf-payment-summary-bgColor": "transparent", }; const appendCssVariables = (cssVariablesStyle, additionalCssVariables) => { const additionalCssVariablesStyle = Object.entries(additionalCssVariables) .map(([key, value]) => `${key}: ${value}`) .join(';\n'); return `${cssVariablesStyle};\n${additionalCssVariablesStyle}`; }; const addBackwardsCompatibilityCssVariables = (cssVariablesStyle, formConfigTimestamp) => (formConfigTimestamp || 0) { }, debugLogging: false, reduceDelays: false, previewMode: false }; let { formType } = $$props; let { formConfig } = $$props; let { formTypeConfig } = $$props; let { organisationConfig } = $$props; let { environment = {} } = $$props; const mergedEnvironment = { ...defaultEnvironment, ...environment, ...(formConfig?._spikeApiUrl) ? { apiUrlBase: formConfig._spikeApiUrl } : {} }; // Styles const styleGuideObj = JSON.parse(organisationConfig.siteStyles ?? "{}"); const cssVariables = addBackwardsCompatibilityCssVariables(convertSiteStylesToCssVariables(styleGuideObj), formConfig.timestamp); // Section flow const sectionFlow = sectionFlowFor(formType); // Language pack resolving const formConfigResolved = resolveLanguagePackKeys(formConfig.languagePack, formConfig); const typeConfigResolved = resolveLanguagePackKeys(formConfig.languagePack, formTypeConfig); const orgConfigResolved = resolveLanguagePackKeys(formConfig.languagePack, organisationConfig); const uniqueKey = randomId(); const isPaymentForm = formType === FormType.PAYMENT; const formConfiguration = { environment: mergedEnvironment, formType, ...formConfigResolved, organisationConfiguration: orgConfigResolved, typeConfiguration: typeConfigResolved, sectionFlow, uniqueKey, formId: isPaymentForm ? "zephr-payment-form-root" : `zephr-form-root-${uniqueKey}` }; $$self.$$set = $$props => { if ('formType' in $$props) $$invalidate(0, formType = $$props.formType); if ('formConfig' in $$props) $$invalidate(3, formConfig = $$props.formConfig); if ('formTypeConfig' in $$props) $$invalidate(4, formTypeConfig = $$props.formTypeConfig); if ('organisationConfig' in $$props) $$invalidate(5, organisationConfig = $$props.organisationConfig); if ('environment' in $$props) $$invalidate(6, environment = $$props.environment); }; return [ formType, cssVariables, formConfiguration, formConfig, formTypeConfig, organisationConfig, environment ]; } class FormApp extends SvelteComponent { constructor(options) { super(); init(this, options, instance, create_fragment, safe_not_equal, { formType: 0, formConfig: 3, formTypeConfig: 4, organisationConfig: 5, environment: 6 }); } } // TODO Parameter version translation // TODO remove circular deps const currentPropsVersion = "main:1"; const translateFormProps = (propsVersion, props) => { if (propsVersion === currentPropsVersion) { return props; } // Knowledge of other prop versions goes here once some backwards-incompatible changes // have been made to the props schema. throw `Unknown props version ${propsVersion}`; }; const renderForm = (container, props) => { const target = (typeof container === 'string' || container instanceof String) ? document.getElementById(container) : container; return new FormApp({ target, props }); }; // Public API entrypoint if (window.Zephr == null) { window.Zephr = {}; } window.Zephr.renderForm = renderForm; window.Zephr.translateFormProps = translateFormProps; })(); //# sourceMappingURL=bundle.js.map /* === FORM CARD CONTAINER === */ .zephr-form-max-width, .zephr-payment-form-max-width { background-color: #f9f9fb !important; padding: 32px !important; border-radius: 31px !important; border: 2px solid #e5e5e5 !important; max-width: 600px !important; margin: 0 auto !important; font-family: inherit !important; } .zephr-form-login-link { margin: 0!important; } .zephr-form-checkmark { border-radius: 0px !important; border: 2px solid #e5e5e5 !important; } /* === FORM LAYOUT === */ .zephr-form-content { display: flex !important; flex-direction: column !important; gap: 1rem !important; margin: 0!important; background-color: var(--bs-body-bg) !important; } .zephr-form form { background-color: var(--bs-body-bg) !important; } /* === INPUT STYLING === */ .zephr-form-input, .zephr-form input[type="email"], .zephr-form input[type="text"], .zephr-form input[type="password"], .zephr-form input[type="number"], .zephr-form input[type="tel"], .zephr-form input[type="url"], .zephr-form textarea { border-radius: 0 !important; border: 1px solid #ddd !important; font-size: 16px !important; padding: 12px 16px !important; width: 100% !important; background-color: #fff !important; font-family: inherit !important; box-shadow: none !important; } /* === INPUT FOCUS === */ .zephr-form input:focus, .zephr-form textarea:focus { outline: none !important; border-color: #000 !important; box-shadow: none !important; } /* === LABEL STYLING === */ .zephr-form-input-label span { font-size: 14px !important; font-weight: 600 !important; color: #111 !important; margin-bottom: 0.25rem !important; display: inline-block !important; } .zephr-form-custom-text { color: var(--bs-body-color) !important; } /* === BUTTON STYLING === */ .zephr-form-button, .zephr-form button[type="submit"] { background-color: #111 !important; color: #fff !important; font-weight: 700 !important; font-size: 16px !important; text-transform: uppercase !important; border-radius: 12px !important; padding: 14px !important; width: 100% !important; border: none !important; cursor: pointer !important; } .zephr-form-button:disabled { background-color: #ccc !important; cursor: not-allowed !important; } .zephr-form-button:hover:not(:disabled) { background-color: #000 !important; } /* === PROMO TOGGLE LINK === */ .zephr-form-promo-activate-line { background: none !important; border: none !important; padding: 0 !important; font-size: 14px !important; font-weight: 500 !important; color: #000 !important; text-align: left !important; margin-top: 8px !important; cursor: pointer !important; } /* === SUMMARY SECTION === */ .zephr-form-summary, .zephr-payment-form-summary { background-color: #f9f9fb !important; border: none !important; padding: 0 0 1rem 0 !important; margin: 0 0 1rem 0 !important; font-family: inherit !important; border-radius: 0 !important; } .zephr-form-summary-line-title { font-size: 20px !important; font-weight: 700 !important; color: #111 !important; } .zephr-form-summary-line-price { font-size: 18px !important; font-weight: 600 !important; color: #111 !important; } /* === SMALL SCREEN PADDING TWEAKS === */ @media (max-width: 576px) { .zephr-form-max-width, .zephr-payment-form-max-width { padding: 24px !important; border-radius: 16px !important; } } /* === MAIN FLEX CONTAINER === */ .payment-options-container { font-family: unset !important; display: flex !important; flex-direction: row !important; justify-content: stretch !important; align-items: stretch !important; flex-wrap: nowrap !important; gap: 0 !important; padding: 0 !important; margin: 0 auto 32px !important; border-radius: 31px !important; border: 2px solid #e5e5e5 !important; overflow: hidden !important; max-width: 960px !important; background: var(--bs-body-bg); } /* === WRAPPER: ENSURE NO MARGIN/BORDER/GAP === */ .payment-option-wrapper { flex: 1 1 0% !important; display: flex !important; flex-direction: column !important; margin: 0 !important; padding: 0 !important; border: none !important; min-width: 0 !important; } /* === REMOVE ANY INTER-BORDER SPACING === */ .payment-option-wrapper:not(:last-of-type) { border-right: 1px solid #e5e5e5 !important; } /* === CLEANUP CONTAINER === */ .box-container { display: flex !important; flex-direction: column !important; width: 100% !important; height: 100% !important; margin: 0 !important; padding: 0 !important; border: none !important; background: transparent !important; box-shadow: none !important; } /* === INNER BOX, NO GAPS OR MARGINS === */ .inner-box { display: flex !important; flex-direction: column !important; justify-content: space-between !important; height: 100% !important; padding: 32px 24px !important; margin: 0 !important; border: none !important; border-radius: 0 !important; background-color: var(bs-secondary-bg) !important; } /* === ROUND ONLY FIRST AND LAST === */ .payment-option-wrapper:first-of-type .inner-box { border-top-left-radius: 20px !important; border-bottom-left-radius: 20px !important; } .payment-option-wrapper:last-of-type .inner-box { border-top-right-radius: 20px !important; border-bottom-right-radius: 20px !important; } /* === PRICE === */ .inner-box h1 { font-size: 36px !important; font-weight: 700 !important; text-align: center !important; margin: 0 0 8px !important; } /* === PLAN NAME === */ .inner-box h3 { font-size: 16px !important; font-weight: 700 !important; text-transform: uppercase !important; text-align: center !important; margin: 0 0 12px !important; } /* === DESCRIPTION === */ .inner-box p { font-size: 14px !important; font-style: italic !important; color: #444 !important; text-align: center !important; margin: 0 0 24px !important; } /* === BUTTONS === */ .zephr-form-button { margin-top: auto !important; padding: 14px 0 !important; font-size: 14px !important; font-weight: bold !important; text-transform: uppercase !important; border: none !important; border-radius: 8px !important; width: 100% !important; background-color: #000 !important; color: #fff !important; cursor: pointer !important; } /* === RED CTA ON MIDDLE BOX === */ .box-container.highlighted .zephr-form-button { background-color: #f53c60 !important; } .zephr-form-button:hover:not(:disabled) { background-color: #f53c60 !important; } zephr-form-button:hover:disabled { background-color: #f53c60 !important; } /* === SAVE BADGE === */ .box-top-text { position: absolute !important; top: 15px !important; right: 15px !important; background-color: #ffff4c !important; transform: rotate(20deg); color: #000 !important; font-size: 12px !important; font-weight: bold !important; border-radius: 50% !important; padding: 19px 18px !important; text-align: center !important; line-height: 1.2 !important; width: 84px !important; height: 84px !important; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important; z-index: 10 !important; } /* === CLEANUP EMPTY .box-top === */ .box-top { height: 0 !important; margin: 0 !important; padding: 0 !important; background: none !important; border: none !important; display: contents !important } .box-container { position: relative !important; } @media (max-width: 768px) { .payment-options-container { flex-direction: column !important; border-radius: 12px !important; overflow: hidden !important; } .payment-option-wrapper { border-right: none !important; border-bottom: 1px solid #e5e5e5 !important; } .payment-option-wrapper:first-of-type .inner-box { border-top-left-radius: 20px !important; border-top-right-radius: 20px !important; } .payment-option-wrapper:last-of-type { border-bottom: none !important; } .payment-option-wrapper:last-of-type .inner-box { border-bottom-left-radius: 20px !important; border-bottom-right-radius: 20px !important; } /* Remove left/right radius that only makes sense in horizontal layout */ .payment-option-wrapper .inner-box { border-radius: 0 !important; } } .zephr-form.svelte-jjl1p8, .zephr-form { color: var(--bs-body-color) !important; } .zephr-form-custom-text:has(> #control-paywall) { display: none; } var element = document.currentScript; while(!(element.classList && element.classList.contains('zephr-form-container'))){ element = element.previousSibling; } window.Zephr.renderForm(element, window.Zephr.translateFormProps("main:1", {"formType":"PAYMENT","formConfig":{"parts":[{"type":"plan-select","label":"1 of 3","sections":[{"type":"plan_select","order":0,"elements":[{"type":"text","order":0,"id":"b420369b-e600-4707-995f-b0eacff55e48","config":{"text":" Subscribe today! \n THE INSIGHTS AND INTELLIGENCE YOU NEED TO SUCCEED
Yes, I want to receive emails from ADWEEK about products, services and events that they feel may be of interest to me.
Yes, I want to receive emails from ADWEEK on behalf of carefully-selected third party partners about products, services and events that may interest me.
By submitting your information you agree to ADWEEK's Terms of Use and Privacy Policy and you will begin receiving our newsletters.
I understand by creating an account, I agree to ADWEEK s Terms of Use and Privacy Policy and that I may review and update my marketing preferences at any time.
A code has been sent to your email address. Enter it below.
A code has been sent to your email address. Enter it below.
By subscribing you agree to Adweek s Terms of Use and Privacy Policy
Automatic Renewal and Cancellation By subscribing, you agree to the terms of sale, including the Cancellation and Refund Policy . You authorize Adweek.com to charge your credit/debit card at the annual subscription price at the amount noted above now and in time to automatically renew your Adweek.com subscription every year, before the start of each new 12-month term unless you tell us to stop. Renewal rates are subject to change at any time with or without notice. Unless you notify us in advance, your service will continue without interruption.
Billed every four weeks, cancel any time.
Billed annually at $199, cancel any time.
Billed annually at $249, cancel any time.
Mark Stenberg is ADWEEK's senior media reporter.
By submitting your email, you agree to our Terms of Use and Privacy Policy . You may opt-out anytime by clicking 'unsubscribe' from the newsletter or from your account.
Select ADWEEK as one of your favorite sources and stay up to date on our latest content.
Publishers and SSPs are piling onto Google with claims that the tech giant's advertising and AI practices unfairly impeded their businesses
The company is the fifth major supply-side platform over the last year to sue the tech giant over alleged anti-competitive digital advertising practices
2026 Adweek - All Rights Reserved Do not sell my personal information Terms of Use Privacy Policy {"prefetch":[{"source":"document","where":{"and":[{"href_matches":"/*"},{"not":{"href_matches":["/wp-*.php","/wp-admin/*","/wp-content/uploads/*","/wp-content/*","/wp-content/plugins/*","/wp-content/themes/adweek-next/*","/*\\?(.+)"]}},{"not":{"selector_matches":"a[rel~=\"nofollow\"]"}},{"not":{"selector_matches":".no-prefetch, .no-prefetch a"}}]},"eagerness":"conservative"}]} if (!window.Zephr) window.Zephr = {}; if (!window.Zephr.outcomes) window.Zephr.outcomes = {}; window.Zephr.outcomes['get-user-login-data'] = { featureLabel: 'Get User Login Data', outcomeId: 'transformation/2#1', outcomeLabel: 'Remove' }; function redirectToLoginPage(){ awDeleteUserCookie(); awDeleteUserData(); window.location = "https://www.adweek.com/sign-in/?rdt=https%3A%2F%2Fwww.adweek.com%2Fmedia%2Fwoo-sue-arpu-publisher-earnings-reveal-ai-strategies&usr-msg=rf"; } setTimeout( function (e) { 'use strict'; var cookie_value = Cookies.get( '_UH10c8f4W' ); if ( cookie_value ){ try { var cookie_data = JSON.parse( atob( cookie_value ) ), current_timestamp = Math.floor( Date.now() / 1000 ); if ( current_timestamp > cookie_data.check_date ){ $.ajax( { url: aw.ajaxurl, type: 'POST', dataType: 'json', data: { action: 'aw_paywall_refresh_cookie', cw_cookie: cookie_data } } ).done( function( response ) { var data = {}, cookie; try{ data = JSON.parse( response ); } catch( err ){ redirectToLoginPage(); } if ( data.login === 'success' ) { cookie = data.cookie_data; Cookies.set( cookie.cookie_name, cookie.cookie_value, { expires: 365 } ); } else { redirectToLoginPage(); } } ); } } catch( err ) { /* noop */ } } }, 5000 ); .wp-elements-fa6ccfddc17cd9ed62c7d2d2919b5ddc a:where(:not(.wp-element-button)){color:var(--wp--preset--color--cyan-bluish-gray);}.wp-elements-40f40e525c7d9baadb02b14e70fb63da a:where(:not(.wp-element-button)){color:#f53c60;} /*# sourceURL=core-block-supports-inline-css */ wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } ); //# sourceURL=wp-i18n-js-after window.wpParselySiteId = 'adweek.com'; //# sourceURL=wp-parsely-loader-js-before var downloadReceipt = {"download_receipt_script_path":"https://static-www.adweek.com/wp-content/themes/adweek-next/src/js/custom/download-receipt.js"}; //# sourceURL=download_receipt_script-js-extra _stq = window._stq || []; _stq.push([ "view", {"v":"ext","blog":"234039852","post":"1955147","tz":"-4","srv":"www.adweek.com","hp":"vip","j":"1:16.0.1"} ]); _stq.push([ "clickTrackerInit", "234039852", "1955147" ]); //# sourceURL=jetpack-stats-js-before
本条目归入「Consumer Trends」垂直,涉及真实话题:brand、consumer。
· 市场:关注 brand、consumer 对相关品类与竞争格局的潜在影响。
· 消费者:受众行为与偏好变化值得追踪。
· 品牌:本动向对品牌资产建设的启示。
· 渠道:内容分发与触点组合(社媒 / 电商 / 线下)的协同值得复盘。
· 核心话题:brand、consumer。
· 可思考:如何把「brand」的洞察,转化为可衡量的内容与增长动作?
面试中可引用「Woo, Sue, and ARPU: What Publisher Earnings Reveal About Their AI Strategies」:围绕 brand、consumer,说明你对行业动向的判断与可落地动作。
本条目相关英文术语可在「商务英语」模块按话题检索,用于外企面试表达训练。
Subscribe Sign In Agencies Brands Creativity Media TV Commerce Tech Dealroom // Check if the menuHtml is stored in local storage if (!localStorage.getItem('menuHtml')) { // Set the…
I understand by creating an account, I agree to ADWEEK s Terms of Use and Privacy Policy and that I may review and update my marketing preferences at any time.…
} props * @returns {void} */ $set(props) { if (this.$$set && !is_empty(props)) { this.$$.skip_bound = true; this.$$set(props); this.$$.skip_bound = false; } } } /** * @typedef {Obj…