{"version":3,"file":"client.discount-app_rXMjVF3z.pl.esm.js","sources":["../../src/__deprecated__/components/discountApp/constants.ts","../../src/__deprecated__/components/discountApp/analytics/DiscountMonorailTracker.ts","../../src/__deprecated__/components/discountApp/components/shop-discount-code.ts","../../src/__deprecated__/components/discountApp/view/DiscountAuthView.ts","../../src/__deprecated__/components/discountApp/utils/utils.ts","../../src/__deprecated__/components/discountApp/utils/configurations.ts","../../src/__deprecated__/components/discountApp/utils/errors.ts","../../src/__deprecated__/components/discountApp/shop-discount-auth.ts","../../src/__deprecated__/components/discountApp/authorize/authorize.ts","../../src/__deprecated__/components/discountApp/init.ts"],"sourcesContent":["export const ERRORS = {\n temporarilyUnavailable: {\n code: 'temporarily_unavailable',\n message: 'Shop login is temporarily unavailable',\n },\n};\n\nexport const LOAD_TIMEOUT_MS = 10000;\n\nexport const SHOP_DISCOUNT_FLOW = 'discount';\n\nexport const SDA_PHONE_CAPTURE_CLASS = 'sda-phone-capture';\n\nexport const SHOP_DISCOUNT_AUTH_HTML = `\n `;\n\nexport const DISCLOSURE_TEXT_STYLE = `\n `;\n","import {Monorail} from '@shopify/monorail';\n\nimport {MonorailTracker as MonorailTrackerBase} from '../../../common/analytics';\nimport {\n LoginWithShopSdkPageName,\n LoginWithShopSdkUserAction,\n MonorailSchema,\n} from '../../../common/analytics/types';\nimport {SHOP_DISCOUNT_FLOW} from '../constants';\nimport {DiscountAppVersion} from '../../../types';\nimport {getMonorailMiddlewareForDeprecated as getMonorailMiddleware} from '../../../common/analytics/utils';\n\ninterface MonorailTrackerParams {\n elementName: string;\n analyticsTraceId?: string;\n flowVersion: DiscountAppVersion;\n apiKey: string;\n}\n\nconst middleware = getMonorailMiddleware();\n\nexport const monorailProducer =\n // eslint-disable-next-line no-process-env\n process.env.NODE_ENV === 'production'\n ? Monorail.createHttpProducer({\n production: true,\n middleware,\n })\n : Monorail.createLogProducer({\n debugMode: true,\n middleware,\n });\n\nexport default class MonorailTracker extends MonorailTrackerBase {\n private _apiKey: string;\n private _shopAccountUuid: string | undefined;\n\n /**\n * @param {object} params The constructor params.\n * @param {string} params.elementName The name of the element (e.g. `shop-pay-button`, `shop-login-button`, `shopify-payment-terms`).\n * @param {DiscountAppVersion} params.flowVersion The version of the Shop Login flow (eg. '1' or '2').\n * @param {string | undefined} params.apiKey The API key of the client.\n * @param {string | undefined} params.analyticsTraceId A UUID that can correlate all analytics events fired for the same user flow. I.e. Could be\n * used to correlate events between Shop JS and Pay for the Shop Login flow.\n */\n constructor({\n analyticsTraceId,\n apiKey,\n elementName,\n flowVersion,\n }: MonorailTrackerParams) {\n super({\n elementName,\n analyticsTraceId,\n flow: SHOP_DISCOUNT_FLOW,\n flowVersion,\n });\n this._apiKey = apiKey;\n }\n\n update({\n apiKey,\n shopAccountUuid,\n flowVersion,\n }: {\n apiKey?: string;\n shopAccountUuid?: string;\n flowVersion?: DiscountAppVersion;\n }) {\n if (apiKey) {\n this._apiKey = apiKey;\n }\n\n if (shopAccountUuid) {\n this._shopAccountUuid = shopAccountUuid;\n }\n\n if (flowVersion) {\n this._flowVersion = flowVersion;\n }\n }\n\n /**\n * Fired when the shop-login-button component from shop-js has finished requesting discount code from onDiscountCodeRequested.\n * @param {object} params The parameters object.\n * @param {string} params.discountCode The discount code to be saved.\n * with different implementations and potentially different performance metrics.\n */\n trackShopPayLoginWithSdkDiscountStatus({\n discountCode,\n }: {\n discountCode: string;\n }) {\n const payload = {\n apiKey: this._apiKey,\n discountCode,\n flow: SHOP_DISCOUNT_FLOW,\n flowVersion: this._flowVersion,\n discountCodeStatus: 'received',\n analyticsTraceId: this._analyticsTraceId!,\n shopPermanentDomain: this._shopPermanentDomain,\n };\n\n monorailProducer.produce({\n schemaId: MonorailSchema.ShopifyLoginWithShopSdkDiscountStatus,\n payload,\n });\n }\n\n async trackPageImpression({\n page,\n }: {\n page: LoginWithShopSdkPageName;\n }): Promise {\n super.trackPageImpression({\n apiKey: this._apiKey,\n shopAccountUuid: this._shopAccountUuid,\n page,\n });\n }\n\n trackShopPayLoginWithShopSdkUserAction({\n userAction,\n }: {\n userAction: LoginWithShopSdkUserAction;\n }): void {\n super.trackShopPayLoginWithShopSdkUserAction({\n apiKey: this._apiKey,\n userAction,\n });\n }\n\n trackShopPayLoginWithSdkErrorEvents({\n errorCode,\n errorMessage,\n }: {\n errorCode: string;\n errorMessage: string;\n }): void {\n super.trackShopPayLoginWithSdkErrorEvents({\n apiKey: this._apiKey,\n errorCode,\n errorMessage,\n });\n }\n}\n","import WebComponent from '../../../common/WebComponent';\nimport {colors} from '../../../common/colors';\nimport {createShopDiscountIcon, ShopDiscountIcon} from '../../../common/svg';\nimport {Variant as DiscountIconVariant} from '../../../common/svg/shop-discount-icon';\n\nexport const ELEMENT_CLASS_NAME = 'shop-discount-code';\nexport const VARIANT_CODE_VISIBLE = 'code-visible';\nexport const VARIANT_SUBDUED = 'subdued';\n\nconst ATTRIBUTE_CODE = 'code';\nconst ATTRIBUTE_SAVED = 'saved';\n\nexport class ShopDiscountCode extends WebComponent {\n #rootElement: ShadowRoot;\n #wrapperElement!: HTMLDivElement;\n #codeElement!: HTMLSpanElement;\n #iconElement!: ShopDiscountIcon;\n #code: string | null = null;\n #saved = false;\n\n static get observedAttributes(): string[] {\n return [ATTRIBUTE_CODE, ATTRIBUTE_SAVED];\n }\n\n constructor() {\n super();\n\n const template = document.createElement('template');\n template.innerHTML = getStyle();\n\n this.#rootElement = this.attachShadow({mode: 'open'});\n this.#rootElement.appendChild(template.content.cloneNode(true));\n\n this.#wrapperElement = document.createElement('div');\n\n this.#iconElement = createShopDiscountIcon();\n this.#wrapperElement.appendChild(this.#iconElement);\n\n this.#codeElement = document.createElement('span');\n this.#wrapperElement.appendChild(this.#codeElement);\n\n this.#rootElement.appendChild(this.#wrapperElement);\n }\n\n connectedCallback(): void {\n const code = this.getAttribute(ATTRIBUTE_CODE);\n this._initCode(code);\n const saved = Boolean(this.getAttribute(ATTRIBUTE_SAVED) !== null);\n this._initSaved(saved);\n }\n\n attributeChangedCallback(\n name: string,\n _oldValue: string,\n newValue: string | null,\n ): void {\n const attributePassed = Boolean(newValue !== null);\n switch (name) {\n case ATTRIBUTE_CODE:\n this._initCode(newValue);\n break;\n case ATTRIBUTE_SAVED:\n this._initSaved(attributePassed);\n break;\n }\n }\n\n disconnectedCallback(): void {}\n\n private _updateStyles(): void {\n const classNames = [ELEMENT_CLASS_NAME];\n if (this.#code) {\n classNames.push(`${ELEMENT_CLASS_NAME}--${VARIANT_CODE_VISIBLE}`);\n }\n\n if (this.#saved) {\n this.#iconElement.setAttribute('variant', DiscountIconVariant.Branded);\n } else if (this.#code) {\n classNames.push(`${ELEMENT_CLASS_NAME}--${VARIANT_SUBDUED}`);\n this.#iconElement.setAttribute('variant', DiscountIconVariant.Subdued);\n } else {\n this.#iconElement.setAttribute('variant', DiscountIconVariant.Regular);\n }\n\n const className = classNames.join(' ');\n this.#wrapperElement.setAttribute('class', className);\n }\n\n private _initCode(code: string | null) {\n this.#codeElement.textContent = code;\n this.#code = code;\n this._updateStyles();\n }\n\n private _initSaved(saved: boolean) {\n this.#saved = saved;\n this._updateStyles();\n }\n}\n\n/**\n * function which returns the component's style\n * @returns {string} the style\n */\nfunction getStyle(): string {\n return `\n \n `;\n}\n\nif (!customElements.get('shop-discount-code')) {\n customElements.define('shop-discount-code', ShopDiscountCode);\n}\n\n/**\n * helper function for building a DiscountCode component\n * @returns {ShopDiscountCode} a new DiscountCode instance\n */\nexport function createShopDiscountCode(): ShopDiscountCode {\n const element = document.createElement('shop-discount-code');\n return element as ShopDiscountCode;\n}\n","import {MonorailTracker} from '__deprecated__/components/discountApp/analytics';\nimport {constraintWidthInViewport} from '__deprecated__/common/utils/constraintWidthInViewport';\n\nimport {ATTRIBUTE_ANALYTICS_TRACE_ID} from '../../../constants/loginButton';\nimport {\n LoginWithShopSdkPageName,\n LoginWithShopSdkUserAction,\n} from '../../../common/analytics';\nimport {ShopSheetModal} from '../../../common/shop-sheet-modal/shop-sheet-modal';\nimport {copyTemplateToDom, updateAttribute} from '../../../common/utils';\nimport {\n createStatusIndicator,\n ShopStatusIndicator,\n StatusIndicatorLoader,\n} from '../../../common/shop-status-indicator';\nimport {\n createShopDiscountCode,\n ShopDiscountCode,\n} from '../components/shop-discount-code';\nimport {\n SDA_PHONE_CAPTURE_CLASS,\n SHOP_DISCOUNT_AUTH_HTML,\n DISCLOSURE_TEXT_STYLE,\n} from '../constants';\nimport {DiscountAppProcessingStatus as ProcessingStatus} from '../../../types';\n\ninterface DiscountCodeView {\n code?: string;\n saved?: boolean;\n}\n\ninterface StatusIndicatorView {\n branded: boolean;\n status: ProcessingStatus;\n message: string;\n}\n\ninterface ButtonState {\n label: string;\n onClick: () => void;\n}\n\nexport interface ViewState {\n headerDivider?: boolean;\n title?: string;\n description?: string;\n headerVisible?: boolean;\n processingElementVisible?: boolean;\n processingUserElementVisible?: boolean;\n processingUser?: string;\n phoneCaptureContainerVisible?: boolean;\n phoneCaptureButtonsContainerVisible?: boolean;\n phoneConsentConfirmButton?: ButtonState;\n phoneConsentDeclineButton?: ButtonState;\n disclosureHeading?: string;\n disclosureText?: string;\n iframeVisible?: boolean;\n discountVisible?: boolean;\n discountCode?: DiscountCodeView | null;\n statusIndicator?: StatusIndicatorView;\n}\n\nexport default class DiscountAuthView {\n private _rootElement: ShadowRoot;\n private _sheetModal!: ShopSheetModal;\n private _headerElement: HTMLDivElement;\n private _headerTitle: HTMLElement;\n private _headerDescription: HTMLElement;\n private _iframe: HTMLIFrameElement;\n private _processingElement: HTMLDivElement;\n private _processingUserElement: HTMLDivElement;\n private _processingStatusElement: HTMLDivElement;\n private _phoneCaptureContainer: HTMLElement;\n private _disclosureIframe: HTMLIFrameElement;\n private _disclosureContainer: HTMLDivElement | undefined;\n private _phoneCaptureButtonsContainer: HTMLElement;\n private _phoneConsentConfirmButton: HTMLButtonElement;\n private _phoneConsentDeclineButton: HTMLButtonElement;\n private _discountCodeElement?: ShopDiscountCode;\n private _statusIndicator?: ShopStatusIndicator;\n\n private _monorailTracker: MonorailTracker | undefined;\n\n constructor(\n rootElement: ShadowRoot,\n onModalCloseRequest: () => void,\n private _onOpen: () => void,\n private _onClose: () => void,\n ) {\n this._rootElement = rootElement;\n\n copyTemplateToDom(\n SHOP_DISCOUNT_AUTH_HTML,\n 'shop-discount-auth-landing',\n this._rootElement,\n );\n\n this._sheetModal = this._rootElement.querySelector('shop-sheet-modal')!;\n this._headerElement = this._rootElement.querySelector('.sda-header')!;\n this._headerTitle = this._rootElement.querySelector('.sda-header-title')!;\n this._headerDescription = this._rootElement.querySelector(\n '.sda-header-description',\n )!;\n this._iframe = this._rootElement.querySelector('.sda-iframe')!;\n\n this._discountCodeElement = createShopDiscountCode();\n this._sheetModal.prepend(this._discountCodeElement);\n\n this._processingElement =\n this._rootElement.querySelector('.sda-processing')!;\n this._processingUserElement = this._processingElement.querySelector(\n '.sda-processing-user',\n )!;\n this._processingStatusElement = this._processingElement.querySelector(\n '.sda-processing-status',\n )!;\n\n this._phoneCaptureContainer = this._rootElement.querySelector(\n `.${SDA_PHONE_CAPTURE_CLASS}`,\n )!;\n this._phoneCaptureButtonsContainer =\n this._phoneCaptureContainer.querySelector(`.sda-phone-capture-buttons`)!;\n this._phoneConsentConfirmButton = this._phoneCaptureContainer.querySelector(\n `.sda-phone-capture-confirm`,\n )!;\n this._phoneConsentDeclineButton = this._phoneCaptureContainer.querySelector(\n `.sda-phone-capture-decline`,\n )!;\n\n this._disclosureIframe = this._rootElement.querySelector(\n 'iframe.sda-disclosure-text-container',\n )! as HTMLIFrameElement;\n\n this._sheetModal.addEventListener('modalcloserequest', onModalCloseRequest);\n\n // For passkeys\n updateAttribute(this._iframe, 'allow', 'publickey-credentials-get *');\n }\n\n /*\n * The primary function to perform DOM updates. Allows complex view state changes to be exrpressed as one function call\n * with one ViewState object representing the new state.\n *\n * Each attribute controls a section of the DOM.\n * - If an attribute is passed in, its corresponding DOM element is updated (i.e. shown/hidden, content is updated, etc).\n * - If an attribute is `null` its corresponding DOM element is removed.\n * - If an attribute is `undefined` its corresponding DOM element is left untouched.\n */\n updateSheetContent({\n headerVisible,\n title,\n description,\n headerDivider,\n processingElementVisible,\n processingUserElementVisible,\n processingUser,\n phoneCaptureContainerVisible,\n phoneCaptureButtonsContainerVisible,\n phoneConsentConfirmButton,\n phoneConsentDeclineButton,\n disclosureHeading,\n disclosureText,\n iframeVisible,\n statusIndicator,\n discountVisible,\n discountCode,\n }: ViewState) {\n if (headerVisible !== undefined) {\n setElementVisible(this._headerElement, headerVisible);\n }\n if (title !== undefined) {\n this._headerTitle.textContent = title;\n }\n if (description !== undefined) {\n this._headerDescription.textContent = description;\n }\n if (headerDivider !== undefined) {\n this._headerElement.classList.toggle('sda-header-divider', headerDivider);\n }\n\n if (processingUserElementVisible !== undefined) {\n setElementVisible(\n this._processingUserElement,\n processingUserElementVisible,\n );\n }\n if (processingElementVisible !== undefined) {\n setElementVisible(this._processingElement, processingElementVisible);\n }\n if (processingUser !== undefined) {\n this._processingUserElement.textContent = processingUser;\n }\n\n if (phoneCaptureContainerVisible !== undefined) {\n setElementVisible(\n this._phoneCaptureContainer,\n phoneCaptureContainerVisible,\n );\n }\n if (phoneCaptureButtonsContainerVisible !== undefined) {\n setElementVisible(\n this._phoneCaptureButtonsContainer,\n phoneCaptureButtonsContainerVisible,\n );\n }\n if (phoneConsentConfirmButton !== undefined) {\n this._phoneConsentConfirmButton.innerText =\n phoneConsentConfirmButton.label;\n this._phoneConsentConfirmButton.onclick =\n phoneConsentConfirmButton.onClick;\n }\n if (phoneConsentDeclineButton !== undefined) {\n this._phoneConsentDeclineButton.innerText =\n phoneConsentDeclineButton.label;\n this._phoneConsentDeclineButton.onclick =\n phoneConsentDeclineButton.onClick;\n }\n if (disclosureHeading !== undefined) {\n this._rootElement.querySelector('.sda-disclosure-heading')!.textContent =\n disclosureHeading;\n }\n if (disclosureText !== undefined) {\n this._updateDisclosureText(disclosureText);\n }\n\n if (iframeVisible === true) {\n this._showIframe();\n } else if (iframeVisible === false) {\n this._hideIframe();\n }\n\n if (statusIndicator) {\n if (!this._statusIndicator) {\n this._initStatusIndicator(statusIndicator.branded);\n }\n const {status, message} = statusIndicator;\n this._statusIndicator?.setStatus({status, message});\n }\n\n if (discountVisible !== undefined && this._discountCodeElement) {\n setElementVisible(this._discountCodeElement, discountVisible);\n }\n if (discountCode) {\n this._updateDiscountCode(discountCode);\n }\n }\n\n showPhoneConsentScreen({\n title,\n disclosureHeading,\n disclosureText,\n confirmButtonLabel,\n declineButtonLabel,\n discountCode,\n onConfirm,\n onDecline,\n }: {\n title: string;\n disclosureHeading: string;\n disclosureText: string;\n confirmButtonLabel: string;\n declineButtonLabel: string;\n discountCode?: DiscountCodeView | null;\n onConfirm: () => void;\n onDecline: () => void;\n }): void {\n this.updateSheetContent({\n title,\n description: '',\n iframeVisible: false,\n headerDivider: false,\n processingElementVisible: false,\n phoneCaptureContainerVisible: true,\n disclosureHeading,\n disclosureText,\n discountCode,\n phoneConsentConfirmButton: {\n label: confirmButtonLabel,\n onClick: () => {\n this._monorailTracker?.trackShopPayLoginWithShopSdkUserAction({\n userAction: LoginWithShopSdkUserAction.PhoneConsentProvided,\n });\n onConfirm();\n },\n },\n phoneConsentDeclineButton: {\n label: declineButtonLabel,\n onClick: () => {\n this._monorailTracker?.trackShopPayLoginWithShopSdkUserAction({\n userAction: LoginWithShopSdkUserAction.PhoneConsentDeclined,\n });\n onDecline();\n },\n },\n });\n this._monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.PhoneConsent,\n });\n }\n\n showTitleAndDescriptionOnlyScreen({\n title,\n description,\n }: {\n title: string;\n description: string;\n }) {\n this.updateSheetContent({\n title,\n description,\n processingElementVisible: false,\n phoneCaptureContainerVisible: false,\n processingUserElementVisible: false,\n });\n }\n\n getIframe(): HTMLIFrameElement {\n return this._iframe;\n }\n\n resizeIframe(height: number, width: number, onSuccess: () => void) {\n if (!this._iframe) return;\n\n this._iframe.style.height = `${height}px`;\n this._iframe.style.width = `${constraintWidthInViewport(width, this._iframe)}px`;\n onSuccess();\n }\n\n toggleModalBusy(busy: boolean) {\n if (busy) {\n this._sheetModal.setAttribute('busy', 'true');\n } else {\n this._sheetModal.removeAttribute('busy');\n }\n }\n\n isModalBusy(): boolean {\n return this._sheetModal.getAttribute('busy') === 'true';\n }\n\n setModalAnalyticsTraceId(analyticsTraceId: string): void {\n this._sheetModal.setAttribute(\n ATTRIBUTE_ANALYTICS_TRACE_ID,\n analyticsTraceId,\n );\n }\n\n async showModal() {\n const result = await this._sheetModal.open();\n if (result) {\n this._onOpen();\n }\n }\n\n async hideModal(): Promise {\n return this._sheetModal\n .close()\n .then((animation) => {\n if (animation) {\n this._hideIframe();\n this._onClose();\n }\n })\n .catch(() => {\n this._hideIframe();\n this._onClose();\n });\n }\n\n reset() {\n this.hideModal();\n this.updateSheetContent({\n headerVisible: false,\n processingElementVisible: false,\n discountCode: {\n code: '',\n saved: false,\n },\n });\n }\n\n setMonorailTracker(monorailTracker: MonorailTracker) {\n this._monorailTracker = monorailTracker;\n this._sheetModal.setMonorailTracker(this._monorailTracker!);\n }\n\n private _initStatusIndicator(branded: boolean) {\n const loaderType: StatusIndicatorLoader = branded\n ? StatusIndicatorLoader.Branded\n : StatusIndicatorLoader.Regular;\n this._statusIndicator = createStatusIndicator(loaderType);\n this._processingStatusElement.appendChild(this._statusIndicator);\n }\n\n private _showIframe(): void {\n setElementVisible(this._iframe, true);\n }\n\n private _hideIframe(): void {\n setElementVisible(this._iframe, false);\n }\n\n private _updateDiscountCode({code, saved}: DiscountCodeView): void {\n if (code !== undefined) {\n if (code) {\n this._discountCodeElement?.setAttribute('code', code);\n this._monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.DiscountShown,\n });\n } else {\n this._discountCodeElement?.removeAttribute('code');\n }\n }\n if (saved !== undefined) {\n if (saved) {\n this._discountCodeElement?.setAttribute('saved', '');\n } else {\n this._discountCodeElement?.removeAttribute('saved');\n }\n }\n }\n\n private _updateDisclosureText(disclosureText: string) {\n if (!this._disclosureContainer) {\n const disclosureIframeBody =\n this._disclosureIframe.contentDocument?.querySelector('body')!;\n disclosureIframeBody.innerHTML = DISCLOSURE_TEXT_STYLE;\n\n const disclosureContainer = document.createElement('div');\n disclosureContainer.setAttribute('class', 'sda-disclosure-text');\n disclosureIframeBody.appendChild(disclosureContainer);\n this._disclosureContainer = disclosureContainer;\n }\n\n this._disclosureContainer.innerHTML = disclosureText;\n\n // Resize iframe to match height of the disclosure text\n this._disclosureIframe.setAttribute(\n 'height',\n `${this._disclosureContainer.getBoundingClientRect().height}px`,\n );\n }\n}\n\n/**\n * Set the visibility of a given element by toggling the `sda-hidden` class.\n * @param {HTMLElement} element The element to set the visibility of.\n * @param {boolean} visible Whether the element should be visible or not.\n */\nfunction setElementVisible(element: HTMLElement, visible: boolean) {\n element.classList.toggle('sda-hidden', !visible);\n}\n","import DOMPurify from 'dompurify';\n\n// Add a hook to make all links open a new window\nDOMPurify.addHook('afterSanitizeAttributes', function (node) {\n if ('target' in node) {\n node.setAttribute('target', '_blank');\n }\n});\n\n/**\n * Sanitizes Phone Capture Disclosure text (passed as HTML), removing any tags\n * except for inline links.\n * @param {string} text Disclosure text which may be in HTML format.\n * @returns {string} Sanitized disclosure text which can be safely displayed on our modal.\n */\nexport function sanitizeDisclosureText(text: string): string {\n if (!DOMPurify.isSupported) {\n throw new Error(\n 'Disclosure sanitization is not supported in this browser.',\n );\n }\n\n return DOMPurify.sanitize(text, {ALLOWED_TAGS: ['a']});\n}\n\n/**\n * Extracts the text content from HTML, discarding any tags.\n * @param {string} html A string of HTML.\n * @returns {string} Text content of the HTML, discarding any tags.\n */\nfunction getTextFromHTML(html: string): string {\n if (!DOMPurify.isSupported) {\n throw new Error(\n 'Disclosure sanitization is not supported in this browser.',\n );\n }\n\n return DOMPurify.sanitize(html, {ALLOWED_TAGS: []});\n}\n\n/**\n * Returns the character count of the text content of the HTML with all tags discarded.\n * @param {string} html A string of HTML.\n * @returns {number} The character count of the text content of the HTML with all tags discarded.\n */\nexport function getHTMLTextLength(html: string): number {\n return getTextFromHTML(html).length;\n}\n","import {logError} from '../../../common/logging';\n\nimport {getHTMLTextLength} from './utils';\n\n/**\n * NOTE: These steps are ordered, and should not be rearranged.\n * The order is used to determine when to show/save the discount code.\n */\nexport enum Step {\n // User found and shown the authorize form (6-digit code or 1-click continue)\n AuthorizeShown = 'authorize-shown',\n // User has authorized successfully (entered 6-digit code or clicked 1-click continue)\n AuthorizeSuccess = 'authorize-success',\n // User is shown the consent screen with \"Sign up with [phone]\" button.\n PhoneConsentShown = 'phone-consent-shown',\n // User declined phone consent (I do not want texts).\n PhoneConsentDeclined = 'phone-consent-declined',\n // User clicked the \"Sign up with [phone]\" button to provide phone consent.\n PhoneConsentConfirmed = 'phone-consent-confirmed',\n // User shown reminder to check their phone for SMS opt-in.\n CheckYourTexts = 'check-your-texts',\n // Partner saves / shows the discount code, we never do.\n Never = 'never',\n}\n\nexport const STEP_ORDER = Object.values(Step);\n\nexport const PHONE_CAPTURE_STEPS = [\n Step.PhoneConsentShown,\n Step.PhoneConsentConfirmed,\n Step.Never,\n];\n\nexport const SHOW_DISCOUNT_AT_OPTIONS = [\n Step.AuthorizeShown,\n Step.AuthorizeSuccess,\n Step.PhoneConsentShown,\n Step.PhoneConsentConfirmed,\n Step.Never,\n];\n\nexport const SAVE_DISCOUNT_AT_OPTIONS = [\n Step.AuthorizeSuccess,\n Step.PhoneConsentConfirmed,\n Step.Never,\n];\n\nexport function getDiscountAuthVersion({\n phoneCapture,\n showDiscountAt,\n saveDiscountAt,\n}: {\n phoneCapture: boolean;\n showDiscountAt: Step;\n saveDiscountAt: Step;\n}) {\n if (phoneCapture) {\n return `PHONE_CAPTURE_SHOWN_AT_${showDiscountAt}_SAVED_AT_${saveDiscountAt}`\n .toUpperCase()\n .replace(/[-]/g, '_');\n }\n return 'EMAIL_CAPTURE';\n}\n\nexport function shouldSaveDiscount(\n step: Step,\n saveDiscountAt: Step,\n discountSaved: boolean,\n discountSaveTriggered: boolean,\n): boolean {\n return (\n !discountSaved &&\n !discountSaveTriggered &&\n step &&\n step !== Step.PhoneConsentDeclined &&\n STEP_ORDER.indexOf(step) >= STEP_ORDER.indexOf(saveDiscountAt)\n );\n}\n\n/**\n * Returns `true` if the discount code should be visible at the given step. That is, if the\n * given step is at or after the _showDiscountAt config.\n *\n * @param step The provided step.\n * @param showDiscountAt The step at which the discount code should be shown.\n * @returns true if the discount code should be visible at the given step, false otherwise.\n */\nexport function isDiscountVisible(step: Step, showDiscountAt: Step): boolean {\n if (\n step === Step.PhoneConsentDeclined &&\n showDiscountAt === Step.PhoneConsentConfirmed\n ) {\n return false;\n }\n return STEP_ORDER.indexOf(showDiscountAt) <= STEP_ORDER.indexOf(step);\n}\n\n/**\n * Returns `true` if the given step is a valid step for the _showDiscountAt config.\n *\n * @param step The provided step.\n * @returns true if the given step is a valid step for the _showDiscountAt config, false otherwise.\n */\nexport function isValidShowDiscountStep(step?: string | null) {\n return Boolean(step && (SHOW_DISCOUNT_AT_OPTIONS as string[]).includes(step));\n}\n\n/**\n * Returns `true` if the given step is a valid step for the _saveDiscountAt config.\n *\n * @param step The provided step.\n * @returns true if the given step is a valid step for the _saveDiscountAt config, false otherwise.\n */\nexport function isValidSaveDiscountStep(step?: string | null) {\n return Boolean(step && (SAVE_DISCOUNT_AT_OPTIONS as string[]).includes(step));\n}\n\nexport const MAX_DISCLOSURE_TEXT_LENGTH = 500;\n\n/**\n * Validates the component configuration. Called after all attributes are passed and immediately before\n * the component is rendered. In case of a failed validation, an error is thrown and the component is\n * not rendered.\n */\nexport function validateConfig({\n isPhoneCapture,\n phoneCaptureDisclosureText,\n saveDiscountAt,\n showDiscountAt,\n}: {\n isPhoneCapture: boolean;\n phoneCaptureDisclosureText?: string;\n saveDiscountAt: Step;\n showDiscountAt: Step;\n}) {\n if (isPhoneCapture && !phoneCaptureDisclosureText) {\n throw new Error(\n `A valid ${Attribute.PhoneCaptureDisclosureText} must be provided when ${Attribute.PhoneCapture} is enabled.`,\n );\n }\n if (\n phoneCaptureDisclosureText &&\n getHTMLTextLength(phoneCaptureDisclosureText) > MAX_DISCLOSURE_TEXT_LENGTH\n ) {\n throw new Error(\n `The attribute ${Attribute.PhoneCaptureDisclosureText} has a max length of ${MAX_DISCLOSURE_TEXT_LENGTH} characters (excluding HTML tags).`,\n );\n }\n if (!isPhoneCapture && PHONE_CAPTURE_STEPS.includes(showDiscountAt)) {\n throw new Error(\n `The attribute ${Attribute.ShowDiscountAt} can only be set to ${showDiscountAt} when ${Attribute.PhoneCapture} is enabled.`,\n );\n }\n if (!isPhoneCapture && PHONE_CAPTURE_STEPS.includes(saveDiscountAt)) {\n throw new Error(\n `The attribute ${Attribute.SaveDiscountAt} can only be set to ${saveDiscountAt} when ${Attribute.PhoneCapture} is enabled.`,\n );\n }\n}\n\nexport enum Attribute {\n DiscountCodeCallback = 'discount-code-callback',\n StorefrontOrigin = 'storefront-origin',\n DevMode = 'dev-mode',\n ApiKey = 'api-key',\n Email = 'email',\n HideChange = 'hide-change',\n // Whether phone capture is on (default to false)\n PhoneCapture = 'phone-capture',\n // At which step to show the discount code\n ShowDiscountAt = 'show-discount-at',\n // At which step to save the discount code\n SaveDiscountAt = 'save-discount-at',\n // Disclosure text (HTML) to show the user at the Phone Consent Shown step\n PhoneCaptureDisclosureText = 'phone-capture-disclosure-text',\n}\n\nconst requiredAttributes: Attribute[] = [\n Attribute.DiscountCodeCallback,\n Attribute.ApiKey,\n];\n\nexport function validateRequiredAttributes(element: Element) {\n requiredAttributes.forEach((attribute) => {\n if (!element.getAttribute(attribute)) {\n logError(`Missing ${attribute} attribute`);\n }\n });\n}\n","import {getAnalyticsTraceId} from '../../../common/utils';\n\nexport class SaveDiscountError extends Error {\n name = 'SaveDiscountError';\n code = 'save_discount_error';\n\n constructor(\n message: string,\n public analyticsTraceId: string = getAnalyticsTraceId(),\n ) {\n super(message);\n }\n}\n","import {defineCustomElement} from '../../common/init';\nimport {\n LoginWithShopSdkPageName,\n LoginWithShopSdkUserAction,\n ShopifyPayModalState,\n} from '../../common/analytics/types';\nimport Bugsnag from '../../common/bugsnag';\nimport {logError} from '../../common/logging';\nimport {IFrameEventSource} from '../../common/MessageEventSource';\nimport MessageListener from '../../common/MessageListener';\nimport {PayMessageSender} from '../../common/MessageSender';\nimport {ShopSheetModal} from '../../common/shop-sheet-modal/shop-sheet-modal';\nimport {I18n} from '../../common/translator/i18n';\nimport {StoreMetadata} from '../../common/utils/types';\nimport {validateStorefrontOrigin} from '../../common/utils/urls';\nimport {\n ShopHubTopic,\n exchangeLoginCookie,\n getAnalyticsTraceId,\n getStoreMeta,\n isEmptyAttributeValue,\n removeOnePasswordPrompt,\n updateAttribute,\n} from '../../common/utils';\nimport ConnectedWebComponent from '../../common/ConnectedWebComponent';\nimport {\n CompletedEventPayload,\n DiscountCodeCallback,\n DiscountAppMessageEventData as MessageEventData,\n DiscountAppProcessingStatus as ProcessingStatus,\n ShopDiscountAuthEventType,\n AuthorizeStepChangedEvent,\n} from '../../types';\nimport {\n recordOpentel,\n TelemetryMetricId,\n} from '../../dynamicImports/opentelemetry';\n\nimport {MonorailTracker} from './analytics';\nimport {buildAuthorizeUrl, payAuthDomain, payAuthDomainAlt} from './authorize';\nimport {ERRORS, LOAD_TIMEOUT_MS} from './constants';\nimport DiscountAuthView, {ViewState} from './view/DiscountAuthView';\nimport {\n Attribute,\n getDiscountAuthVersion,\n isDiscountVisible,\n isValidSaveDiscountStep,\n isValidShowDiscountStep,\n sanitizeDisclosureText,\n SaveDiscountError,\n SAVE_DISCOUNT_AT_OPTIONS,\n shouldSaveDiscount,\n SHOW_DISCOUNT_AT_OPTIONS,\n Step,\n STEP_ORDER,\n validateConfig,\n validateRequiredAttributes,\n} from './utils';\n\nconst DISCOUNT_SAVED_MESSAGE_DURATION = 1500;\nconst DISCOUNT_SHOWN_MESSAGE_DURATION = 2000;\nconst SMS_CONFIRMATION_MESSAGE_DURATION = 5000;\n\nconst DEVMODE_EMAIL_NOT_A_USER = 'success-not-a-shop-user@myshopify.io';\nconst DEVMODE_EMAIL_BLOCKED = 'blocked-user@myshopify.io';\nconst DEVMODE_EMAIL_DISCOUNT_ERROR = 'discount-code-error@myshopify.io';\n\nconst DEFAULT_CONFIGS = {\n emailCapture: {\n showDiscountAt: Step.AuthorizeShown,\n saveDiscountAt: Step.AuthorizeSuccess,\n },\n phoneCapture: {\n showDiscountAt: Step.Never,\n saveDiscountAt: Step.AuthorizeSuccess,\n },\n};\n\nexport default class ShopDiscountAuth extends ConnectedWebComponent {\n #iframeLoaded = false;\n #iframeReadyToShow = false;\n #userCookieExists = false;\n #email = '';\n #discountCode = '';\n\n #discountCodeCallback = '';\n #i18n: I18n | null = null;\n\n #iframe!: HTMLIFrameElement;\n #iframeListener?: MessageListener;\n #iframeMessenger?: PayMessageSender;\n #iframeLoadTimeout: ReturnType | undefined;\n\n #devMode = false;\n #hideChange: boolean;\n #analyticsTraceId = getAnalyticsTraceId();\n #storefrontOrigin = '';\n #storefrontMeta: StoreMetadata | null = null;\n #monorailTracker?: MonorailTracker;\n private _view: DiscountAuthView;\n private _phoneCapture = false;\n private _showDiscountAt: Step = DEFAULT_CONFIGS.emailCapture.showDiscountAt;\n private _saveDiscountAt: Step = DEFAULT_CONFIGS.emailCapture.saveDiscountAt;\n private _pendingStep: Step = STEP_ORDER[0];\n private _discountSaved = false;\n private _discountSaveTriggered = false;\n private _confirmCompleted = false;\n private _isModalClosing = false;\n private _phoneCaptureDisclosureText = '';\n private _apiKey = '';\n private _maskedPhoneNumber?: string;\n private _completedEventPayload: CompletedEventPayload = {\n loggedIn: false,\n };\n\n // Saves the header state as would be shown without personalization consent.\n private _defaultHeaderState: Partial = {\n title: '',\n headerDivider: true,\n discountVisible: true,\n };\n\n static get observedAttributes(): string[] {\n return [\n Attribute.ApiKey,\n Attribute.DevMode,\n Attribute.DiscountCodeCallback,\n Attribute.Email,\n Attribute.PhoneCapture,\n Attribute.PhoneCaptureDisclosureText,\n Attribute.SaveDiscountAt,\n Attribute.ShowDiscountAt,\n Attribute.StorefrontOrigin,\n ];\n }\n\n constructor() {\n super();\n\n if (!customElements.get('shop-sheet-modal')) {\n customElements.define('shop-sheet-modal', ShopSheetModal);\n }\n\n const rootElement: ShadowRoot = this.attachShadow({mode: 'open'});\n\n const onModalCloseRequest = () => {\n if (this._confirmCompleted || this._pendingStep === Step.AuthorizeShown) {\n this.hideModalAndDispatchCompleted();\n return;\n }\n\n this._view.hideModal();\n this._isModalClosing = true;\n this.#iframeMessenger?.postMessage({\n type: 'phoneshareconsentreceived',\n consented: this._pendingStep === Step.PhoneConsentConfirmed,\n ...(!this._discountSaved && {skipDiscountSaving: true}),\n });\n };\n const onOpen = () => {\n this.#iframeMessenger?.postMessage({type: 'sheetmodalopened'});\n };\n const onClose = () => {\n this.#iframeMessenger?.postMessage({\n type: 'sheetmodalclosed',\n });\n // Remove the 1password custom element from the DOM after the sheet modal is closed.\n removeOnePasswordPrompt();\n };\n this._view = new DiscountAuthView(\n rootElement,\n onModalCloseRequest,\n onOpen,\n onClose,\n );\n this._view.setModalAnalyticsTraceId(this.#analyticsTraceId);\n this.#iframe = this._view.getIframe();\n this.#hideChange = false;\n }\n\n get storefrontOrigin(): string {\n return this.#storefrontOrigin;\n }\n\n set storefrontOrigin(newStorefrontOrigin: string) {\n this.#storefrontOrigin = newStorefrontOrigin;\n this.updateAttribute(Attribute.StorefrontOrigin, newStorefrontOrigin);\n }\n\n get apiKey(): string {\n return this._apiKey;\n }\n\n set apiKey(apiKey: string) {\n this._apiKey = apiKey;\n this.updateAttribute(Attribute.ApiKey, apiKey);\n }\n\n async connectedCallback(): Promise {\n this.#validateAttributes();\n await this.#initTranslations();\n\n this.#devMode = this.getBooleanAttribute(Attribute.DevMode);\n this.#hideChange = this.getAttribute(Attribute.HideChange) !== null;\n\n if (!this.#devMode && !this.#monorailTracker) {\n this.#monorailTracker = new MonorailTracker({\n elementName: 'shop-discount-auth',\n apiKey: this.apiKey,\n flowVersion: getDiscountAuthVersion({\n phoneCapture: this._phoneCapture,\n showDiscountAt: this._showDiscountAt,\n saveDiscountAt: this._saveDiscountAt,\n }),\n analyticsTraceId: this.#analyticsTraceId,\n });\n this._view.setMonorailTracker(this.#monorailTracker);\n\n this.#monorailTracker.trackPageImpression({\n page: LoginWithShopSdkPageName.SdkLoaded,\n });\n\n this.#monorailTracker.trackShopPayModalStateChange({\n currentState: ShopifyPayModalState.Loaded,\n });\n }\n\n this.#updateSrc();\n\n if (!this.#iframeListener) {\n /*\n If this component is used in an iframe, the message event destination will be the window object of the iframe, not the root window.\n This logic only works after the component is added to the DOM, hence it must be in the connectedCallback, not the constructor.\n */\n const eventDestination: Window | undefined =\n this.ownerDocument?.defaultView || undefined;\n\n const coreAuthDomain = this.#getStoreDomain();\n\n this.#iframeListener = new MessageListener(\n new IFrameEventSource(this.#iframe),\n [payAuthDomain, payAuthDomainAlt, coreAuthDomain],\n this.#handlePostMessage.bind(this),\n eventDestination,\n );\n\n this.#storefrontMeta = await getStoreMeta(coreAuthDomain);\n }\n\n if (!this.#iframeMessenger) {\n this.#iframeMessenger = new PayMessageSender(this.#iframe);\n }\n }\n\n async #initTranslations() {\n try {\n // BUILD_LOCALE is used for generating localized bundles.\n // See ./scripts/i18n-dynamic-import-replacer-rollup.mjs for more info.\n // eslint-disable-next-line no-process-env\n const locale = process.env.BUILD_LOCALE || I18n.getDefaultLanguage();\n const dictionary = await import(`./translations/${locale}.json`);\n this.#i18n = new I18n({[locale]: dictionary});\n } catch (error) {\n if (error instanceof Error) {\n Bugsnag.notify(error);\n }\n }\n }\n\n disconnectedCallback(): void {\n this.#iframeListener?.destroy();\n }\n\n attributeChangedCallback(\n name: string,\n _oldValue: string,\n newValue: string | null,\n ): void {\n // For boolean attributes only check if the attribute is passed, ignoring its value\n const attributePassed = Boolean(newValue !== null);\n\n switch (name) {\n case Attribute.DiscountCodeCallback:\n this._initDiscountCodeCallback();\n break;\n case Attribute.StorefrontOrigin:\n this._initStorefrontOrigin();\n break;\n case Attribute.ApiKey:\n this._initApiKey();\n this.#monorailTracker?.update({\n apiKey: this.apiKey,\n });\n break;\n case Attribute.Email:\n this.#updateEmail(newValue);\n break;\n case Attribute.PhoneCapture:\n this._initPhoneCapture(attributePassed);\n this.updateFlowVersion();\n break;\n case Attribute.ShowDiscountAt:\n this._initShowDiscountAt(newValue);\n this.updateFlowVersion();\n break;\n case Attribute.SaveDiscountAt:\n this._initSaveDiscountAt(newValue);\n this.updateFlowVersion();\n break;\n case Attribute.PhoneCaptureDisclosureText:\n this._initPhoneCaptureDisclosureText(newValue);\n break;\n case Attribute.DevMode:\n this._initDevMode();\n break;\n }\n }\n\n notifyEmailFieldShown(): void {\n this.#monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.PartnerEmailInputShown,\n });\n }\n\n requestShow(email: string): void {\n if (!this.#iframeLoaded) {\n recordOpentel(TelemetryMetricId.RequestShowCalledBeforeIframeLoaded, 1, {\n component: 'shop-discount-auth',\n });\n return;\n }\n if (!email) {\n Bugsnag.notify(new Error('requestShow called without email'));\n throw new Error('Missing email string parameter');\n }\n\n this.#updateEmail(email);\n }\n\n #getStoreDomain(): string {\n return this.#storefrontOrigin || window.location.origin;\n }\n\n #validateAttributes(): void {\n validateRequiredAttributes(this);\n\n if (this.#storefrontOrigin) {\n validateStorefrontOrigin(this.#storefrontOrigin);\n }\n }\n\n async #requestDiscountCode(email: string): Promise {\n const discountCode = await this.#getDiscountCode(email);\n\n if (discountCode) {\n this.#discountCode = discountCode;\n this.#displayModalIfReady();\n }\n }\n\n #displayModalIfReady(): void {\n if (!this.#discountCode || !this.#iframeReadyToShow) return;\n\n const discountVisible = isDiscountVisible(\n Step.AuthorizeShown,\n this._showDiscountAt,\n );\n\n this._view.updateSheetContent({\n iframeVisible: true,\n ...(discountVisible && {\n discountCode: {\n code: this.#discountCode,\n },\n }),\n });\n\n this._view.showModal();\n }\n\n #handlePayLoaded(userHasCookie: boolean, loginTitle: string) {\n this.#iframeLoaded = true;\n this.#clearLoadTimeout();\n\n // Save login title in case it's overwritten by the personalization consent step.\n this._defaultHeaderState.title = loginTitle;\n\n // eslint-disable-next-line no-warning-comments\n // TODO: Update this loginTitle per latest mockups. Consider moving it to Shop JS translation files rather than receiving it from Pay. https://github.com/Shopify/shop-identity/issues/1250\n // Once this is done, we will no longer need to save it in this._defaultHeaderState (above).\n this._view.updateSheetContent({\n title: loginTitle,\n headerVisible: userHasCookie,\n });\n\n this.dispatchCustomEvent(userHasCookie ? 'userfound' : 'usernotfound');\n this.#monorailTracker?.trackShopLoginFirstTimeRender();\n }\n\n #updateEmail(email: string | null): void {\n if (!email) return;\n\n try {\n validateConfig({\n isPhoneCapture: this._phoneCapture,\n saveDiscountAt: this._saveDiscountAt,\n showDiscountAt: this._showDiscountAt,\n phoneCaptureDisclosureText: this._phoneCaptureDisclosureText,\n });\n } catch (error) {\n if (error instanceof Error) {\n logError(`Invalid config. ${error.message}`);\n this.#handleError('invalid_config', error.message);\n }\n return;\n }\n\n this.#email = email;\n\n this.#monorailTracker?.trackShopPayLoginWithShopSdkUserAction({\n userAction: LoginWithShopSdkUserAction.ThirdPartyFormSubmission,\n });\n\n this.#requestDiscountCode(email);\n\n if (this.#devMode) {\n if (email === DEVMODE_EMAIL_NOT_A_USER) {\n this._updateCompletedPayload({email, loggedIn: false});\n this.#handleCompleted();\n return;\n }\n\n if (email === DEVMODE_EMAIL_BLOCKED) {\n this.#handleError(\n 'user_blocked',\n 'Hardcoded error event test email was entered.',\n email,\n );\n return;\n }\n }\n\n this.#iframeMessenger?.postMessage({\n type: 'emailsubmitted',\n email,\n hideChange: this.#hideChange,\n });\n }\n\n #updateSrc(): void {\n if (!this.#iframe) return;\n const authorizeUrl = buildAuthorizeUrl({\n analyticsTraceId: this.#analyticsTraceId,\n storefrontOrigin: this.#storefrontOrigin,\n devMode: this.#devMode,\n phoneCapture: this._phoneCapture,\n saveDiscountAt: this._saveDiscountAt,\n apiKey: this._apiKey,\n flowVersion: getDiscountAuthVersion({\n phoneCapture: this._phoneCapture,\n showDiscountAt: this._showDiscountAt,\n saveDiscountAt: this._saveDiscountAt,\n }),\n });\n\n this.#initLoadTimeout();\n updateAttribute(this.#iframe, 'src', authorizeUrl);\n Bugsnag.leaveBreadcrumb('Iframe url updated', {authorizeUrl}, 'state');\n }\n\n updateFlowVersion(): void {\n this.#monorailTracker?.update({\n flowVersion: getDiscountAuthVersion({\n phoneCapture: this._phoneCapture,\n showDiscountAt: this._showDiscountAt,\n saveDiscountAt: this._saveDiscountAt,\n }),\n });\n }\n\n #initLoadTimeout() {\n this.#clearLoadTimeout();\n this.#iframeLoadTimeout = setTimeout(() => {\n const {message, code} = ERRORS.temporarilyUnavailable;\n this.dispatchCustomEvent('error', {\n message,\n code,\n });\n // eslint-disable-next-line no-warning-comments\n // TODO: replace this bugsnag notify with a Observe-able event\n // Bugsnag.notify(\n // new PayTimeoutError(`Pay failed to load within ${LOAD_TIMEOUT_MS}ms.`),\n // {component: this.#component, src: this.iframe?.getAttribute('src')},\n // );\n this.#clearLoadTimeout();\n }, LOAD_TIMEOUT_MS);\n }\n\n #clearLoadTimeout() {\n if (!this.#iframeLoadTimeout) return;\n clearTimeout(this.#iframeLoadTimeout);\n this.#iframeLoadTimeout = undefined;\n }\n\n #handleShopUserMatched(\n userCookieExists: boolean,\n maskedPhoneNumber: string,\n personalizeConsentChallenge: boolean,\n ): void {\n this.#userCookieExists = userCookieExists;\n this._maskedPhoneNumber = maskedPhoneNumber;\n\n this._view.updateSheetContent({\n headerVisible: true,\n ...(personalizeConsentChallenge\n ? {\n title: this.#i18n!.translate(\n 'shop_discount_auth.personalization_consent.title',\n ),\n headerDivider: false,\n discountVisible: false,\n }\n : this._defaultHeaderState),\n });\n\n this.#iframeReadyToShow = true;\n this.dispatchCustomEvent('shopusermatched');\n this.#displayModalIfReady();\n }\n\n #handleAuthorizeStepChanged({\n step,\n email,\n phone,\n }: AuthorizeStepChangedEvent): void {\n switch (step) {\n case 'one_click':\n // Resets the header to the default state - before personalization consent.\n // The \"email\" step is not relevant to the discount flow, the \"sms\" step would also fire a\n // user matched event which would update the copy. So we only care about the \"one_click\" step.\n this._view.updateSheetContent(this._defaultHeaderState);\n break;\n case 'email':\n this._view.updateSheetContent({\n description: this.#i18n!.translate(\n 'shop_discount_auth.auth_modal.login_email_description',\n {email},\n ),\n });\n break;\n case 'sms':\n this._view.updateSheetContent({\n description: this.#i18n!.translate(\n 'shop_discount_auth.auth_modal.login_sms_description',\n {phoneNumber: phone},\n ),\n });\n break;\n case 'webauthn':\n this._view.updateSheetContent({\n headerDivider: false,\n description: this.#i18n!.translate(\n 'shop_discount_auth.auth_modal.login_webauthn_description',\n ),\n });\n break;\n }\n }\n\n #handleProcessing(\n status: ProcessingStatus,\n message: string,\n email?: string,\n ): void {\n this._view.toggleModalBusy(true);\n\n const isPhoneConsentStep = [\n Step.PhoneConsentConfirmed,\n Step.PhoneConsentDeclined,\n ].includes(this._pendingStep);\n\n // Don't show the success \"Discount Saved\" message on the status indicator in the Phone Capture flow.\n // This will be communicated to the user on the last screen of the flow.\n const statusIndicator =\n this._phoneCapture && status === 'success'\n ? undefined\n : {\n branded: this.#userCookieExists,\n status,\n message,\n };\n\n const discountVisible = isDiscountVisible(\n this._pendingStep,\n this._showDiscountAt,\n );\n\n /**\n * The processing indicator can be shown either in the authorization (ULC) steps, or the phone\n * consent steps. In the authorization steps the user's email is shown, so we want to keep showing\n * it while the processing indicator is visible. In the phone consent steps, the user's email is\n * no longer shown.\n */\n const showUserEmail =\n this._saveDiscountAt === Step.AuthorizeSuccess &&\n !(this._isModalClosing && this._pendingStep === Step.PhoneConsentShown) &&\n !isPhoneConsentStep;\n\n if (this._isModalClosing) {\n return;\n }\n\n this._view.updateSheetContent({\n iframeVisible: false,\n processingElementVisible: true,\n processingUserElementVisible: showUserEmail,\n phoneCaptureButtonsContainerVisible: showUserEmail,\n processingUser: email ?? this.#email,\n statusIndicator,\n discountCode: {\n ...(discountVisible && {code: this.#discountCode}),\n },\n });\n }\n\n #handleError(code: string, message: string, email?: string): void {\n this.#clearLoadTimeout();\n\n this.#monorailTracker?.trackShopPayLoginWithSdkErrorEvents({\n errorCode: code,\n errorMessage: message,\n });\n\n this.dispatchCustomEvent('error', {\n code,\n message,\n email,\n });\n\n this._view.toggleModalBusy(false);\n }\n\n #handleDiscountSaved() {\n // Pay saved the discount, try moving to the next step again.\n this._discountSaved = true;\n this._view.updateSheetContent({\n discountCode: {\n saved: this._discountSaved,\n },\n });\n this.#monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.DiscountSaved,\n });\n this.moveToNextStep(this._pendingStep, true);\n }\n\n moveToNextStep(step: Step, discountWasSaved = false) {\n this._pendingStep = step;\n\n if (this._discountSaveTriggered && !this._discountSaved) {\n return;\n }\n\n // Ensure discount is saved at the configured step before moving to the next step.\n if (\n shouldSaveDiscount(\n step,\n this._saveDiscountAt,\n this._discountSaved,\n this._discountSaveTriggered,\n )\n ) {\n // Tell Pay to save the discount. Pay should message back \"discountsaved\" when done,\n // which will trigger moving to the next step again.\n this._view.toggleModalBusy(true);\n this._saveDiscountWithPay();\n return;\n }\n\n let timeout = 0;\n if (discountWasSaved) {\n timeout = DISCOUNT_SAVED_MESSAGE_DURATION;\n }\n if (step === this._showDiscountAt) {\n timeout = DISCOUNT_SHOWN_MESSAGE_DURATION;\n }\n\n setTimeout(() => {\n // Go to next step\n switch (step) {\n case Step.AuthorizeShown:\n break;\n case Step.AuthorizeSuccess:\n break;\n case Step.PhoneConsentShown:\n this._view.toggleModalBusy(false);\n this._updateCompletedPayload({phoneShareConsent: false});\n this._showPhoneConsent();\n break;\n case Step.PhoneConsentConfirmed:\n if (this._saveDiscountAt !== Step.Never) {\n this._showPhoneConsentConfirmed();\n }\n break;\n case Step.PhoneConsentDeclined:\n this._showPhoneConsentDeclined();\n break;\n }\n }, timeout);\n }\n\n // This is called when sdk-confirm is completed from Pay/Core.\n async #handleCompleted(shouldFinalizeLogin = false): Promise {\n if (this._completedEventPayload?.loggedIn && shouldFinalizeLogin) {\n exchangeLoginCookie(this.#storefrontOrigin, (error) => {\n Bugsnag.notify(new Error(error));\n });\n\n const {avatar, email, givenName} = this._completedEventPayload;\n this.publishToHub(ShopHubTopic.UserSessionCreate, {\n email: givenName || email,\n initial: givenName?.[0] || email?.[0] || '',\n avatar,\n });\n }\n\n if (this._phoneCapture) {\n if (this._isModalClosing) {\n this.hideModalAndDispatchCompleted();\n return;\n }\n\n if (\n this._saveDiscountAt === Step.Never &&\n this._pendingStep === Step.PhoneConsentConfirmed\n ) {\n // For the \"Never\" flow, show the CheckYourTexts screen after confirming\n // instead of closing the modal immediately.\n this._showPhoneConsentConfirmed();\n return;\n }\n\n if (\n this._saveDiscountAt !== Step.PhoneConsentConfirmed ||\n this._pendingStep === Step.PhoneConsentDeclined\n ) {\n this.moveToNextStep(this._pendingStep);\n }\n } else {\n this.#monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.DiscountSaved,\n });\n setTimeout(() => {\n this.hideModalAndDispatchCompleted();\n }, DISCOUNT_SHOWN_MESSAGE_DURATION);\n }\n }\n\n #handleUserVerified() {\n if (this._phoneCapture) {\n this.moveToNextStep(Step.PhoneConsentShown);\n } else {\n this.moveToNextStep(Step.AuthorizeSuccess);\n }\n }\n\n hideModalAndDispatchCompleted(): void {\n this.#iframeListener?.destroy();\n this._view.toggleModalBusy(false);\n this._updateCompletedPayload({\n email: this._completedEventPayload.email ?? this.#email,\n });\n\n // eslint-disable-next-line promise/catch-or-return\n this._view.hideModal().finally(() => {\n this.dispatchCustomEvent('completed', this._completedEventPayload);\n });\n }\n\n #handleRestarted(): void {\n this._view.reset();\n this.#userCookieExists = false;\n this.#iframeReadyToShow = false;\n this.dispatchCustomEvent('restarted');\n }\n\n #handleResizeIframe(height: number, width: number): void {\n this._view.resizeIframe(height, width, () => {\n this.dispatchCustomEvent('resized', {height, width});\n });\n }\n\n #handleIframeCloseRequest(): void {\n if (this._view.isModalBusy()) return;\n this.hideModalAndDispatchCompleted();\n }\n\n #handlePostMessage(data: MessageEventData): void {\n switch (data.type) {\n case 'resize_iframe':\n this.#handleResizeIframe(data.height, data.width);\n break;\n case 'restarted':\n this.#handleRestarted();\n break;\n case 'completed': {\n this._confirmCompleted = true;\n const {shopAccountUuid, shouldFinalizeLogin, type, ...remainingData} =\n data;\n this.#monorailTracker?.update({shopAccountUuid});\n this._updateCompletedPayload(remainingData);\n this.#handleCompleted(shouldFinalizeLogin);\n break;\n }\n case 'error':\n this.#handleError(data.code, data.message, data.email);\n break;\n case 'shop_user_matched':\n this.#handleShopUserMatched(\n data.userCookieExists,\n data.maskedPhoneNumber || '',\n data.personalizeConsentChallenge || false,\n );\n break;\n case 'loaded':\n this.#handlePayLoaded(data.userFound, data.loginTitle);\n break;\n case 'authorize_step_changed':\n this.#handleAuthorizeStepChanged(data);\n break;\n case 'processing_status_updated':\n this.#handleProcessing(data.status, data.message, data.email);\n break;\n case 'discount_saved':\n this.#handleDiscountSaved();\n break;\n case 'close_requested':\n this.#handleIframeCloseRequest();\n break;\n case 'user_verified':\n this.#handleUserVerified();\n break;\n }\n Bugsnag.leaveBreadcrumb('Received postMessage', data, 'process');\n }\n\n async #getDiscountCode(email: string) {\n if (this.#discountCode) {\n return this.#discountCode;\n }\n\n try {\n if (this.#devMode && email === DEVMODE_EMAIL_DISCOUNT_ERROR) {\n throw new Error('Discount code error');\n }\n\n if (typeof this.#discountCodeCallback !== 'string') {\n throw new Error(\n 'discount-code-callback attribute was not provided or is not a string',\n );\n }\n\n const discountCodeCallbackFn = (window as any)[\n this.#discountCodeCallback\n ];\n if (typeof discountCodeCallbackFn !== 'function') {\n throw new Error(\n 'discount-code-callback attribute did not contain the name of a global function',\n );\n }\n const discountCode = await (\n discountCodeCallbackFn as DiscountCodeCallback\n )(email);\n if (\n typeof discountCode !== 'string' ||\n discountCode.trim().length === 0\n ) {\n throw new Error('discount code is non-string or empty');\n }\n\n this.#monorailTracker?.trackShopPayLoginWithSdkDiscountStatus({\n discountCode,\n });\n\n return discountCode;\n } catch (error) {\n if (error instanceof Error) {\n this.#handleError('no_discount_received', error.message, email);\n }\n }\n return undefined;\n }\n\n protected dispatchCustomEvent(\n type: ShopDiscountAuthEventType,\n detail?: any,\n ): void {\n super.dispatchCustomEvent(type, detail);\n }\n\n private _initDiscountCodeCallback(): void {\n const discountCodeCallback = this.getAttribute(\n Attribute.DiscountCodeCallback,\n );\n if (discountCodeCallback) {\n this.#discountCodeCallback = discountCodeCallback;\n }\n }\n\n private _initStorefrontOrigin(): void {\n const storefrontOrigin = this.getAttribute(Attribute.StorefrontOrigin);\n if (storefrontOrigin) {\n this.storefrontOrigin = storefrontOrigin;\n }\n }\n\n private _initApiKey() {\n // we require this attr, the validation that it's provided will have already happened\n this.apiKey = this.getAttribute(Attribute.ApiKey)!;\n this.#updateSrc();\n }\n\n private _initPhoneCapture(newValue: boolean) {\n this._phoneCapture = newValue;\n this._initShowDiscountAt(this.getAttribute(Attribute.ShowDiscountAt));\n this._initSaveDiscountAt(this.getAttribute(Attribute.SaveDiscountAt));\n this.#updateSrc();\n }\n\n private _initShowDiscountAt(newValue: string | null) {\n if (isValidShowDiscountStep(newValue)) {\n this._showDiscountAt = newValue as Step;\n this.#updateSrc();\n return;\n }\n\n // Use default\n this._showDiscountAt = this._phoneCapture\n ? DEFAULT_CONFIGS.phoneCapture.showDiscountAt\n : DEFAULT_CONFIGS.emailCapture.showDiscountAt;\n this.#updateSrc();\n\n if (!isEmptyAttributeValue(newValue)) {\n logError(\n `Invalid value of ${\n Attribute.ShowDiscountAt\n } ('${newValue}'). Must be one of: ${SHOW_DISCOUNT_AT_OPTIONS.join(\n ', ',\n )}. Using the default '${this._showDiscountAt}' instead.`,\n );\n }\n }\n\n private _initSaveDiscountAt(newValue: string | null) {\n if (isValidSaveDiscountStep(newValue)) {\n this._saveDiscountAt = newValue as Step;\n this.#updateSrc();\n return;\n }\n\n // Use default\n this._saveDiscountAt = this._phoneCapture\n ? DEFAULT_CONFIGS.phoneCapture.saveDiscountAt\n : DEFAULT_CONFIGS.emailCapture.saveDiscountAt;\n this.#updateSrc();\n\n if (!isEmptyAttributeValue(newValue)) {\n logError(\n `Invalid value of ${\n Attribute.SaveDiscountAt\n } ('${newValue}'). Must be one of: ${SAVE_DISCOUNT_AT_OPTIONS.join(\n ', ',\n )}. Using the default '${this._saveDiscountAt}' instead.`,\n );\n }\n }\n\n private _initPhoneCaptureDisclosureText(newValue: string | null) {\n try {\n this._phoneCaptureDisclosureText = newValue\n ? sanitizeDisclosureText(newValue)\n : '';\n } catch (error) {\n if (error instanceof Error) {\n Bugsnag.notify(error);\n this.#handleError('disclosure_parse_error', error.message);\n }\n }\n }\n\n private _initDevMode() {\n this.#devMode = this.getBooleanAttribute(Attribute.DevMode);\n this.#updateSrc();\n }\n\n private async _showPhoneConsent() {\n const isDiscountSaved = this._saveDiscountAt === Step.AuthorizeSuccess;\n const title = this.#i18n!.translate(\n isDiscountSaved\n ? 'shop_discount_auth.phone_capture.consent.title_discount_saved'\n : 'shop_discount_auth.phone_capture.consent.title_discount_not_saved',\n );\n\n const merchantName = this.#storefrontMeta?.name || '';\n const disclosureHeading = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent.disclosure_heading',\n {merchantName},\n );\n\n const confirmButtonLabel = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent.confirm_button',\n {\n phone: this._maskedPhoneNumber,\n },\n );\n const declineButtonLabel = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent.decline_button',\n );\n\n const discountVisible = isDiscountVisible(\n Step.PhoneConsentShown,\n this._showDiscountAt,\n );\n this._view.showPhoneConsentScreen({\n title,\n disclosureHeading,\n disclosureText: this._phoneCaptureDisclosureText,\n confirmButtonLabel,\n declineButtonLabel,\n onConfirm: () => {\n this._pendingStep = Step.PhoneConsentConfirmed;\n this.#iframeMessenger?.postMessage({\n type: 'phoneshareconsentreceived',\n consented: true,\n });\n this._updateCompletedPayload({phoneShareConsent: true});\n if (this._saveDiscountAt === Step.PhoneConsentConfirmed) {\n this._view.toggleModalBusy(true);\n this._saveDiscountWithPay();\n }\n },\n onDecline: () => {\n this._pendingStep = Step.PhoneConsentDeclined;\n this.#iframeMessenger?.postMessage({\n type: 'phoneshareconsentreceived',\n consented: false,\n ...(!this._discountSaved && {skipDiscountSaving: true}),\n });\n this._updateCompletedPayload({phoneShareConsent: false});\n },\n ...(discountVisible && {\n discountCode: {\n code: this.#discountCode,\n },\n }),\n });\n }\n\n private _showPhoneConsentConfirmed() {\n const title = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent_confirmed.title',\n );\n const description = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent_confirmed.description',\n {\n phone: this._maskedPhoneNumber,\n },\n );\n this._showTitleAndDescriptionOnly(title!, description!);\n\n this.#monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.PhoneConsentConfirmed,\n });\n }\n\n private _showPhoneConsentDeclined() {\n if (this._saveDiscountAt !== Step.AuthorizeSuccess) {\n // Discount was never saved, so we can't tell the user it will be\n // automatically applied. Just close the modal then.\n\n // eslint-disable-next-line no-warning-comments\n // TODO: Tell the user they won't receive SMS, but do not mention the\n // discount. See https://github.com/Shopify/shop-identity/issues/1479\n this.hideModalAndDispatchCompleted();\n return;\n }\n\n const merchantName = this.#storefrontMeta?.name || '';\n const title = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent_declined.title',\n {merchantName},\n );\n const description = this.#i18n!.translate(\n 'shop_discount_auth.phone_capture.consent_declined.description',\n );\n this._showTitleAndDescriptionOnly(title!, description!);\n\n this.#monorailTracker?.trackPageImpression({\n page: LoginWithShopSdkPageName.PhoneConsentDeclined,\n });\n }\n\n private _showTitleAndDescriptionOnly(title: string, description: string) {\n this._view.showTitleAndDescriptionOnlyScreen({\n title,\n description,\n });\n\n const discountVisible = isDiscountVisible(\n Step.CheckYourTexts,\n this._showDiscountAt,\n );\n this._view.updateSheetContent({\n iframeVisible: false,\n ...(discountVisible && {\n discountCode: {\n code: this.#discountCode,\n },\n }),\n });\n\n this._view.toggleModalBusy(false);\n\n setTimeout(() => {\n this.hideModalAndDispatchCompleted();\n }, SMS_CONFIRMATION_MESSAGE_DURATION);\n }\n\n private async _saveDiscountWithPay() {\n this._discountSaveTriggered = true;\n const discountCode = await this.#getDiscountCode(this.#email);\n if (!discountCode) {\n throw new SaveDiscountError(\n 'Tried to save a discount code, but no discount code received',\n );\n }\n\n this.#iframeMessenger?.postMessage({\n type: 'savediscount',\n discountCode,\n });\n }\n\n private _updateCompletedPayload(update: Partial) {\n this._completedEventPayload = {\n ...this._completedEventPayload,\n ...update,\n };\n }\n}\n\n/**\n * Define the shop-discount-auth custom element.\n */\nexport function defineElement() {\n defineCustomElement('shop-discount-auth', ShopDiscountAuth);\n}\n","import {booleanQueryParam} from '../../../common/utils/booleanQueryParam';\nimport {I18n} from '../../../common/translator/i18n';\nimport {SHOP_DISCOUNT_FLOW} from '../constants';\n\nexport const AUTH_PATH_CORE = '/services/login_with_shop/authorize';\n\n/**\n * Builds the Authorize URL to use for the ULC.\n * @param {object} params The root parameter object.\n * @param {string} params.apiKey The app's api key.\n * @param {string} params.analyticsTraceId Links analytics events together in one flow.\n * @param {string} params.storefrontOrigin The domain of the storefront page that the web component is rendered on.\n * @param {boolean} params.devMode Dev mode flag.\n * @param {boolean} params.phoneCapture Phone capture flag. If `true`, the component is configured to ask for phone consent.\n * Otherwise, the component is configured to ask for email consent only.\n * @param {string} params.saveDiscountAt The step at which the discount should be saved. We care mostly about the \"never\"\n * setting since not all clients are allowed to use it.\n * @param {string} params.flowVersion The version/variant of the flow, for analytics purposes.\n * @returns {string} The Authorize URL\n */\nexport const buildAuthorizeUrl = ({\n apiKey,\n analyticsTraceId,\n storefrontOrigin,\n devMode,\n phoneCapture,\n saveDiscountAt,\n flowVersion,\n}: {\n apiKey: string;\n analyticsTraceId?: string;\n storefrontOrigin?: string;\n devMode?: boolean;\n phoneCapture?: boolean;\n saveDiscountAt?: string;\n flowVersion: string;\n}): string => {\n /* eslint-disable @typescript-eslint/naming-convention */\n const params = new URLSearchParams({\n target_origin: window.location.origin,\n api_key: apiKey,\n flow: SHOP_DISCOUNT_FLOW,\n flow_version: flowVersion,\n // BUILD_LOCALE is used for generating localized bundles.\n // See ./scripts/i18n-dynamic-import-replacer-rollup.mjs for more info.\n // eslint-disable-next-line no-process-env\n locale: process.env.BUILD_LOCALE || I18n.getDefaultLanguage(),\n ...(analyticsTraceId && {analytics_trace_id: analyticsTraceId}),\n // eslint-disable-next-line no-warning-comments\n /*\n TODO: We need to come to a consensus on how to handle boolean query params in Pay.\n For phone_capture Pay reads the value, but for dev_mode Pay looks for the presence of\n the param. https://github.com/Shopify/shop-identity/issues/1414\n */\n ...booleanQueryParam('phone_capture', phoneCapture),\n ...(devMode && booleanQueryParam('dev_mode', devMode)),\n ...(saveDiscountAt && {save_discount_at: saveDiscountAt}),\n });\n /* eslint-enable @typescript-eslint/naming-convention */\n const authDomainCore = storefrontOrigin || window.location.origin;\n\n return `${authDomainCore}${AUTH_PATH_CORE}?${params}`;\n};\n","import {startBugsnag, isBrowserSupported} from '../../common/init';\n\nimport {defineElement} from './shop-discount-auth';\n\n/**\n * Initialize the discountApp web component.\n * This is the entry point that will be used for code-splitting.\n */\nfunction init() {\n if (!isBrowserSupported()) return;\n startBugsnag();\n\n defineElement();\n}\n\ninit();\n"],"names":["ERRORS","code","message","SHOP_DISCOUNT_FLOW","middleware","getMonorailMiddleware","monorailProducer","Monorail","createHttpProducer","production","MonorailTracker","MonorailTrackerBase","constructor","analyticsTraceId","apiKey","elementName","flowVersion","super","flow","this","_apiKey","update","shopAccountUuid","_shopAccountUuid","_flowVersion","trackShopPayLoginWithSdkDiscountStatus","discountCode","payload","discountCodeStatus","_analyticsTraceId","shopPermanentDomain","_shopPermanentDomain","produce","schemaId","MonorailSchema","ShopifyLoginWithShopSdkDiscountStatus","trackPageImpression","_a","__awaiter","arguments","page","_super","call","trackShopPayLoginWithShopSdkUserAction","userAction","trackShopPayLoginWithSdkErrorEvents","errorCode","errorMessage","ELEMENT_CLASS_NAME","VARIANT_CODE_VISIBLE","VARIANT_SUBDUED","ATTRIBUTE_CODE","ATTRIBUTE_SAVED","ShopDiscountCode","WebComponent","observedAttributes","_ShopDiscountCode_rootElement","set","_ShopDiscountCode_wrapperElement","_ShopDiscountCode_codeElement","_ShopDiscountCode_iconElement","_ShopDiscountCode_code","_ShopDiscountCode_saved","template","document","createElement","innerHTML","colors","white","backgroundSubdued","foregroundSecondary","__classPrivateFieldSet","attachShadow","mode","__classPrivateFieldGet","appendChild","content","cloneNode","createShopDiscountIcon","connectedCallback","getAttribute","_initCode","saved","Boolean","_initSaved","attributeChangedCallback","name","_oldValue","newValue","attributePassed","disconnectedCallback","_updateStyles","classNames","push","setAttribute","DiscountIconVariant","Branded","Subdued","Regular","className","join","textContent","customElements","get","define","DiscountAuthView","rootElement","onModalCloseRequest","_onOpen","_onClose","_rootElement","copyTemplateToDom","_sheetModal","querySelector","_headerElement","_headerTitle","_headerDescription","_iframe","_discountCodeElement","prepend","_processingElement","_processingUserElement","_processingStatusElement","_phoneCaptureContainer","_phoneCaptureButtonsContainer","_phoneConsentConfirmButton","_phoneConsentDeclineButton","_disclosureIframe","addEventListener","updateAttribute","updateSheetContent","headerVisible","title","description","headerDivider","processingElementVisible","processingUserElementVisible","processingUser","phoneCaptureContainerVisible","phoneCaptureButtonsContainerVisible","phoneConsentConfirmButton","phoneConsentDeclineButton","disclosureHeading","disclosureText","iframeVisible","statusIndicator","discountVisible","undefined","setElementVisible","classList","toggle","innerText","label","onclick","onClick","_updateDisclosureText","_showIframe","_hideIframe","_statusIndicator","_initStatusIndicator","branded","status","setStatus","_updateDiscountCode","showPhoneConsentScreen","confirmButtonLabel","declineButtonLabel","onConfirm","onDecline","_monorailTracker","LoginWithShopSdkUserAction","PhoneConsentProvided","PhoneConsentDeclined","LoginWithShopSdkPageName","PhoneConsent","showTitleAndDescriptionOnlyScreen","getIframe","resizeIframe","height","width","onSuccess","style","constraintWidthInViewport","toggleModalBusy","busy","removeAttribute","isModalBusy","setModalAnalyticsTraceId","ATTRIBUTE_ANALYTICS_TRACE_ID","showModal","open","hideModal","close","then","animation","catch","reset","setMonorailTracker","monorailTracker","loaderType","StatusIndicatorLoader","createStatusIndicator","_b","DiscountShown","_c","_d","_e","_disclosureContainer","disclosureIframeBody","contentDocument","disclosureContainer","getBoundingClientRect","element","visible","getHTMLTextLength","html","DOMPurify","isSupported","Error","sanitize","ALLOWED_TAGS","getTextFromHTML","length","Step","addHook","node","STEP_ORDER","Object","values","PHONE_CAPTURE_STEPS","PhoneConsentShown","PhoneConsentConfirmed","Never","SHOW_DISCOUNT_AT_OPTIONS","AuthorizeShown","AuthorizeSuccess","SAVE_DISCOUNT_AT_OPTIONS","getDiscountAuthVersion","phoneCapture","showDiscountAt","saveDiscountAt","toUpperCase","replace","isDiscountVisible","step","indexOf","Attribute","requiredAttributes","DiscountCodeCallback","ApiKey","SaveDiscountError","getAnalyticsTraceId","DEFAULT_CONFIGS","emailCapture","ShopDiscountAuth","ConnectedWebComponent","DevMode","Email","PhoneCapture","PhoneCaptureDisclosureText","SaveDiscountAt","ShowDiscountAt","StorefrontOrigin","_ShopDiscountAuth_iframeLoaded","_ShopDiscountAuth_iframeReadyToShow","_ShopDiscountAuth_userCookieExists","_ShopDiscountAuth_email","_ShopDiscountAuth_discountCode","_ShopDiscountAuth_discountCodeCallback","_ShopDiscountAuth_i18n","_ShopDiscountAuth_iframe","_ShopDiscountAuth_iframeListener","_ShopDiscountAuth_iframeMessenger","_ShopDiscountAuth_iframeLoadTimeout","_ShopDiscountAuth_devMode","_ShopDiscountAuth_hideChange","_ShopDiscountAuth_analyticsTraceId","_ShopDiscountAuth_storefrontOrigin","_ShopDiscountAuth_storefrontMeta","_ShopDiscountAuth_monorailTracker","_phoneCapture","_showDiscountAt","_saveDiscountAt","_pendingStep","_discountSaved","_discountSaveTriggered","_confirmCompleted","_isModalClosing","_phoneCaptureDisclosureText","_completedEventPayload","loggedIn","_defaultHeaderState","ShopSheetModal","_view","hideModalAndDispatchCompleted","postMessage","assign","type","consented","skipDiscountSaving","removeOnePasswordPrompt","storefrontOrigin","newStorefrontOrigin","_ShopDiscountAuth_instances","_ShopDiscountAuth_validateAttributes","_ShopDiscountAuth_initTranslations","getBooleanAttribute","HideChange","SdkLoaded","trackShopPayModalStateChange","currentState","ShopifyPayModalState","Loaded","_ShopDiscountAuth_updateSrc","eventDestination","ownerDocument","defaultView","coreAuthDomain","MessageListener","IFrameEventSource","payAuthDomain","payAuthDomainAlt","_ShopDiscountAuth_handlePostMessage","bind","getStoreMeta","PayMessageSender","destroy","_initDiscountCodeCallback","_initStorefrontOrigin","_initApiKey","_ShopDiscountAuth_updateEmail","_initPhoneCapture","updateFlowVersion","_initShowDiscountAt","_initSaveDiscountAt","_initPhoneCaptureDisclosureText","_initDevMode","notifyEmailFieldShown","PartnerEmailInputShown","requestShow","email","recordOpentel","TelemetryMetricId","RequestShowCalledBeforeIframeLoaded","component","moveToNextStep","discountWasSaved","discountSaved","discountSaveTriggered","shouldSaveDiscount","_saveDiscountWithPay","timeout","setTimeout","_updateCompletedPayload","phoneShareConsent","_showPhoneConsent","_showPhoneConsentConfirmed","_showPhoneConsentDeclined","finally","dispatchCustomEvent","detail","discountCodeCallback","includes","isEmptyAttributeValue","logError","text","sanitizeDisclosureText","error","_ShopDiscountAuth_handleError","isDiscountSaved","translate","merchantName","phone","_maskedPhoneNumber","_showTitleAndDescriptionOnly","CheckYourTexts","_ShopDiscountAuth_getDiscountCode","locale","dictionary","shop_discount_auth","phone_capture","consent","title_discount_saved","title_discount_not_saved","confirm_button","decline_button","disclosure_heading","consent_confirmed","consent_declined","personalization_consent","auth_modal","login_sms_description","login_email_description","login_webauthn_description","I18n","window","location","origin","forEach","attribute","validateStorefrontOrigin","_ShopDiscountAuth_displayModalIfReady","_ShopDiscountAuth_handlePayLoaded","userHasCookie","loginTitle","_ShopDiscountAuth_clearLoadTimeout","trackShopLoginFirstTimeRender","isPhoneCapture","phoneCaptureDisclosureText","validateConfig","ThirdPartyFormSubmission","_ShopDiscountAuth_requestDiscountCode","_ShopDiscountAuth_handleCompleted","hideChange","authorizeUrl","devMode","params","URLSearchParams","target_origin","api_key","flow_version","analytics_trace_id","booleanQueryParam","save_discount_at","buildAuthorizeUrl","_ShopDiscountAuth_initLoadTimeout","clearTimeout","_ShopDiscountAuth_handleShopUserMatched","userCookieExists","maskedPhoneNumber","personalizeConsentChallenge","phoneNumber","_ShopDiscountAuth_handleProcessing","isPhoneConsentStep","showUserEmail","_ShopDiscountAuth_handleDiscountSaved","DiscountSaved","shouldFinalizeLogin","exchangeLoginCookie","avatar","givenName","publishToHub","ShopHubTopic","UserSessionCreate","initial","_ShopDiscountAuth_handleRestarted","_ShopDiscountAuth_handleResizeIframe","_ShopDiscountAuth_handleIframeCloseRequest","data","remainingData","__rest","userFound","_ShopDiscountAuth_handleAuthorizeStepChanged","_ShopDiscountAuth_handleUserVerified","discountCodeCallbackFn","trim","isBrowserSupported","defineCustomElement"],"mappings":"kWAAO,MAAMA,EACa,CACtBC,KAAM,0BACNC,QAAS,yCAMAC,EAAqB,WCU5BC,EAAaC,IAENC,EAGPC,EAASC,mBAAmB,CAC1BC,YAAY,EACZL,eAOa,MAAAM,UAAwBC,EAY3C,WAAAC,EAAYC,iBACVA,EAAgBC,OAChBA,EAAMC,YACNA,EAAWC,YACXA,IAEAC,MAAM,CACJF,cACAF,mBACAK,KAAMf,EACNa,gBAEFG,KAAKC,QAAUN,CACjB,CAEA,MAAAO,EAAOP,OACLA,EAAMQ,gBACNA,EAAeN,YACfA,IAMIF,IACFK,KAAKC,QAAUN,GAGbQ,IACFH,KAAKI,iBAAmBD,GAGtBN,IACFG,KAAKK,aAAeR,EAExB,CAQA,sCAAAS,EAAuCC,aACrCA,IAIA,MAAMC,EAAU,CACdb,OAAQK,KAAKC,QACbM,eACAR,KAAMf,EACNa,YAAaG,KAAKK,aACl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