@dropins/storefront-checkout 2.2.0-alpha3 → 2.2.0-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"LoginForm.js","sources":["/@dropins/storefront-checkout/src/components/LoginForm/Email.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignIn.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginFormSkeleton.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginForm.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignOut.tsx","/@dropins/storefront-checkout/src/containers/LoginForm/LoginForm.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginEmailProps extends HTMLAttributes<HTMLInputElement> {\n value: string;\n error: string;\n hint: string;\n onChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n onInvalid: (event: Event) => void;\n}\n\nexport const Email: FunctionComponent<LoginEmailProps> = ({\n value,\n error,\n hint,\n onChange,\n onBlur,\n onInvalid,\n}) => {\n const translations = useText({\n LoginFormLabel: 'Checkout.LoginForm.ariaLabel',\n LoginFormFloatingLabel: 'Checkout.LoginForm.floatingLabel',\n LoginFormPlaceholder: 'Checkout.LoginForm.placeholder',\n });\n\n return (\n <Field error={error} hint={hint}>\n <Input\n aria-label={translations.LoginFormLabel}\n aria-required={true}\n autocomplete=\"email\"\n floatingLabel={translations.LoginFormFloatingLabel}\n id=\"customer-email\"\n name=\"customer-email\"\n placeholder={translations.LoginFormPlaceholder}\n required={true}\n type=\"email\"\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onInvalid={onInvalid}\n />\n </Field>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignInProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignIn: FunctionComponent<SignInProps> = ({ onClick }) => {\n const translations = useText({\n account: 'Checkout.LoginForm.account',\n signIn: 'Checkout.LoginForm.signIn'\n });\n\n return (\n <div className=\"checkout-login-form__sign-in\">\n {translations.account}\n\n <a\n className=\"checkout-login-form__link\"\n data-testid=\"sign-in-link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick(event);\n }}\n >\n {translations.signIn}\n </a>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const LoginFormSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"login-form-skeleton\">\n <SkeletonRow fullWidth={true} variant=\"heading\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Email } from '@/checkout/components';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/LoginForm/LoginForm.css';\nimport { LoginFormSkeleton } from '@/checkout/components/LoginForm/LoginFormSkeleton';\nimport { Customer } from '@/checkout/data/models';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginFormProps\n extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n customer: Customer | null;\n email: string;\n error: string;\n headingContent?: VNode;\n hint: string | VNode;\n onEmailBlur: (event: Event) => void;\n onEmailChange: (event: Event) => void;\n onEmailInvalid: (event: Event) => void;\n title?: VNode;\n}\n\nconst LoginFormComponent: FunctionComponent<LoginFormProps> = ({\n className,\n customer,\n email,\n error,\n headingContent,\n hint,\n name,\n onEmailBlur,\n onEmailChange,\n onEmailInvalid,\n title,\n ...props\n}) => {\n return (\n <div className=\"checkout-login-form\" data-testid=\"checkout-login-form\">\n <div className=\"checkout-login-form__heading\">\n {title && (\n <VComponent className=\"checkout-login-form__title\" node={title} />\n )}\n\n {headingContent && (\n <VComponent\n className=\"checkout-login-form__heading-label\"\n node={headingContent}\n />\n )}\n </div>\n\n {customer ? (\n <div className=\"checkout-login-form__customer-details\">\n <div className=\"checkout-login-form__customer-name\">\n {`${customer.firstName} ${customer.lastName}`}\n </div>\n\n <div className=\"checkout-login-form__customer-email\">\n {customer.email}\n </div>\n </div>\n ) : (\n <div className=\"checkout-login-form__content\">\n <form\n {...props}\n noValidate\n className={classes(['dropin-login-form__form', className])}\n name={name}\n >\n {/* Prevent 'Enter' key press from submitting this form. */}\n <button\n disabled\n aria-hidden=\"true\"\n style=\"display: none\"\n type=\"submit\"\n />\n <Email\n error={error}\n hint={hint as any}\n value={email}\n onBlur={onEmailBlur}\n onChange={onEmailChange}\n onInvalid={onEmailInvalid}\n />\n </form>\n </div>\n )}\n </div>\n );\n};\n\nexport const LoginForm = WithConditionals(\n LoginFormComponent,\n LoginFormSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignOutProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignOut: FunctionComponent<SignOutProps> = ({ onClick }) => {\n const translations = useText({\n switch: 'Checkout.LoginForm.switch',\n signOut: 'Checkout.LoginForm.signOut'\n });\n\n return (\n <p className=\"checkout-login-form__sign-out\">\n {translations.switch}\n\n <a\n className=\"checkout-login-form__link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick?.(event);\n }}\n >\n {translations.signOut}\n </a>\n </p>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCustomer,\n isEmailAvailable,\n setGuestEmailOnCart,\n} from '@/checkout/api';\nimport {\n LoginForm as LoginFormComponent,\n SignIn,\n SignOut,\n} from '@/checkout/components/LoginForm';\nimport { Cart, Customer } from '@/checkout/data/models';\nimport {\n getCartEmail,\n getLatestCheckoutUpdate,\n getValue,\n notifyValues,\n validateEmail,\n} from '@/checkout/lib';\nimport { TitleProps } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\n\ninterface ValidationError {\n email: string;\n message: string;\n type: 'missing' | 'invalid';\n}\n\ninterface CartSyncError {\n email: string;\n error: Error;\n}\n\nexport interface LoginFormProps\n extends HTMLAttributes<HTMLFormElement>,\n TitleProps {\n active?: boolean;\n autoSync?: boolean;\n displayHeadingContent?: boolean;\n onSignInClick?: (email: string) => void;\n onSignOutClick?: () => void;\n onCartSyncError?: (error: CartSyncError) => void;\n onValidationError?: (error: ValidationError) => void;\n slots?: {\n Heading?: SlotProps<{\n authenticated: boolean;\n }>;\n } & TitleProps['slots'];\n}\n\nconst DEBOUNCE_TIME = 1000;\n\nexport const LoginForm: Container<LoginFormProps> = ({\n active = true,\n autoSync = true,\n displayHeadingContent = true,\n displayTitle = true,\n initialData,\n onCartSyncError,\n onSignInClick,\n onSignOutClick,\n onValidationError,\n slots,\n ...props\n}) => {\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [email, setEmail] = useState<string>('');\n const [error, setError] = useState<string>('');\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n const [isAvailable, setIsAvailable] = useState<boolean>(true);\n const [isInitialized, setIsInitialized] = useState<boolean>(false);\n\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const {\n alreadyHaveAccountHint,\n cartSyncError,\n defaultTitle,\n fasterCheckoutHint,\n invalidEmailError,\n missingEmailError,\n signInLabel,\n } = useText({\n alreadyHaveAccountHint: 'Checkout.LoginForm.emailExists.alreadyHaveAccount',\n cartSyncError: 'Checkout.LoginForm.cartSyncError',\n defaultTitle: 'Checkout.LoginForm.title',\n fasterCheckoutHint: 'Checkout.LoginForm.emailExists.forFasterCheckout',\n invalidEmailError: 'Checkout.LoginForm.invalidEmailError',\n missingEmailError: 'Checkout.LoginForm.missingEmailError',\n signInLabel: 'Checkout.LoginForm.emailExists.signInButton',\n });\n\n const setEmailAndCheckAvailability = useCallback(\n (email: string) => {\n if (!validateEmail(email) || email === getCartEmail()) return;\n\n isEmailAvailable(email)\n .then((availability) => {\n setIsAvailable(availability);\n })\n .catch((error) => {\n console.error(error);\n setIsAvailable(true);\n });\n\n if (!autoSync) return;\n\n setGuestEmailOnCart(email).catch((error) => {\n onCartSyncError?.({ email, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, onCartSyncError, cartSyncError]\n );\n\n const handleChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value;\n\n setEmail(email);\n setIsAvailable(true);\n setError('');\n\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n debounceTimer.current = setTimeout(() => {\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n debounceTimer.current = null;\n }, DEBOUNCE_TIME);\n },\n [setEmailAndCheckAvailability]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value.trim();\n const isValid = validateEmail(email);\n\n if (isValid) {\n setError('');\n target.setCustomValidity('');\n\n if (!debounceTimer.current) return;\n\n clearTimeout(debounceTimer.current);\n debounceTimer.current = null;\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n return;\n }\n\n const type = email === '' ? 'missing' : 'invalid';\n const message =\n type === 'missing' ? missingEmailError : invalidEmailError;\n\n if (onValidationError) {\n onValidationError({ email, message, type });\n return;\n }\n\n setError(message);\n target.setCustomValidity(message);\n },\n [\n invalidEmailError,\n missingEmailError,\n onValidationError,\n setEmailAndCheckAvailability,\n ]\n );\n\n const handleInvalid = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const validity = target.validity;\n\n const message = validity.valueMissing\n ? missingEmailError\n : invalidEmailError;\n\n if (!onValidationError) {\n setError(message);\n return;\n }\n\n onValidationError({\n email: target.value,\n message,\n type: validity.valueMissing ? 'missing' : 'invalid',\n });\n },\n [missingEmailError, invalidEmailError, onValidationError]\n );\n\n const handleSignIn = useCallback(() => {\n const email = getValue('email') ?? '';\n const isValid = validateEmail(email);\n onSignInClick?.(isValid ? email : '');\n }, [onSignInClick]);\n\n const handleSignOut = useCallback(() => {\n onSignOutClick?.();\n }, [onSignOutClick]);\n\n const handleCheckoutData = useCallback((data: Cart | null) => {\n const prevEmail = getValue('email') ?? '';\n const email = data?.email ?? '';\n\n if (email !== prevEmail) {\n setEmail(email);\n setError('');\n setIsAvailable(true);\n notifyValues({ email });\n }\n }, []);\n\n useEffect(() => {\n if (!active) return;\n\n const onAuthenticated = events.on(\n 'authenticated',\n (authenticated) => {\n setIsAuthenticated(authenticated);\n\n getCustomer()\n .then((customer) => {\n setCustomer(customer);\n })\n .catch(console.error);\n },\n { eager: true }\n );\n\n return () => {\n onAuthenticated?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore local state from checkout data\n const checkoutEmail = pastUpdate.email ?? '';\n if (checkoutEmail) {\n setEmail(checkoutEmail);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-login-form-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots, defaultTitle]);\n\n const headingContent = useMemo(() => {\n if (!displayHeadingContent) return undefined;\n\n return (\n <Slot\n context={{ authenticated: isAuthenticated }}\n name=\"checkout-login-form-heading-label\"\n slot={slots?.Heading}\n >\n {isAuthenticated ? (\n <SignOut onClick={handleSignOut} />\n ) : (\n <SignIn onClick={handleSignIn} />\n )}\n </Slot>\n );\n }, [\n displayHeadingContent,\n isAuthenticated,\n slots,\n handleSignIn,\n handleSignOut,\n ]);\n\n const hintContent = useMemo(() => {\n if (isAvailable) return '';\n\n return (\n <>\n {alreadyHaveAccountHint}{' '}\n <a href=\"#\" onClick={handleSignIn}>\n {signInLabel}\n </a>{' '}\n {fasterCheckoutHint}\n </>\n );\n }, [\n isAvailable,\n alreadyHaveAccountHint,\n signInLabel,\n fasterCheckoutHint,\n handleSignIn,\n ]);\n\n return (\n <LoginFormComponent\n {...props}\n customer={customer}\n email={email}\n error={error}\n headingContent={headingContent}\n hint={hintContent}\n initialized={isInitialized}\n title={titleContent}\n visible={active}\n onEmailBlur={handleBlur}\n onEmailChange={handleChange}\n onEmailInvalid={handleInvalid}\n />\n );\n};\n"],"names":["Email","value","error","hint","onChange","onBlur","onInvalid","translations","useText","jsx","Field","Input","SignIn","onClick","jsxs","event","LoginFormSkeleton","Skeleton","SkeletonRow","LoginFormComponent","className","customer","email","headingContent","name","onEmailBlur","onEmailChange","onEmailInvalid","title","props","VComponent","classes","LoginForm","WithConditionals","SignOut","DEBOUNCE_TIME","active","autoSync","displayHeadingContent","displayTitle","initialData","onCartSyncError","onSignInClick","onSignOutClick","onValidationError","slots","setCustomer","useState","setEmail","setError","isAuthenticated","setIsAuthenticated","isAvailable","setIsAvailable","isInitialized","setIsInitialized","debounceTimer","useRef","alreadyHaveAccountHint","cartSyncError","defaultTitle","fasterCheckoutHint","invalidEmailError","missingEmailError","signInLabel","setEmailAndCheckAvailability","useCallback","validateEmail","getCartEmail","isEmailAvailable","availability","setGuestEmailOnCart","handleChange","notifyValues","handleBlur","target","type","message","handleInvalid","validity","handleSignIn","getValue","isValid","handleSignOut","handleCheckoutData","data","prevEmail","useEffect","onAuthenticated","events","authenticated","getCustomer","pastUpdate","getLatestCheckoutUpdate","checkoutEmail","onCheckoutInit","onCheckoutUpdated","titleContent","useMemo","Slot","hintContent","Fragment"],"mappings":"wsCA+BO,MAAMA,GAA4C,CAAC,CACxD,MAAAC,EACA,MAAAC,EACA,KAAAC,EACA,SAAAC,EACA,OAAAC,EACA,UAAAC,CACF,IAAM,CACJ,MAAMC,EAAeC,EAAQ,CAC3B,eAAgB,+BAChB,uBAAwB,mCACxB,qBAAsB,gCAAA,CACvB,EAGC,OAAAC,EAACC,GAAM,CAAA,MAAAR,EAAc,KAAAC,EACnB,SAAAM,EAACE,GAAA,CACC,aAAYJ,EAAa,eACzB,gBAAe,GACf,aAAa,QACb,cAAeA,EAAa,uBAC5B,GAAG,iBACH,KAAK,iBACL,YAAaA,EAAa,qBAC1B,SAAU,GACV,KAAK,QACL,MAAAN,EACA,OAAAI,EACA,SAAAD,EACA,UAAAE,CAAA,CAAA,EAEJ,CAEJ,ECxCaM,GAAyC,CAAC,CAAE,QAAAC,KAAc,CACrE,MAAM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A,YAAAA,EAAO,QAEZ,SAAAK,IACEhB,GAAQ,CAAA,QAASiD,CAAe,CAAA,EAEjC1E,EAACG,GAAO,CAAA,QAASoE,CAAc,CAAA,CAAA,CAEnC,CAAA,EAED,CACD1C,EACAY,EACAL,EACAmC,EACAG,CAAA,CACD,EAEKiB,GAAcF,EAAQ,IACtB9C,EAAoB,GAInBtC,EAAAuF,GAAA,CAAA,SAAA,CAAA3C,EAAwB,MACxB,IAAE,CAAA,KAAK,IAAI,QAASsB,EAClB,SACHhB,EAAA,EAAK,IACJH,CAAA,EACH,EAED,CACDT,EACAM,EACAM,EACAH,EACAmB,CAAA,CACD,EAGC,OAAAvE,EAACU,GAAA,CACE,GAAGU,EACJ,SAAAR,EACA,MAAAC,EACA,MAAApB,EACA,eAAAqB,GACA,KAAM6E,GACN,YAAa9C,GACb,MAAO2C,GACP,QAAS7D,EACT,YAAasC,GACb,cAAeF,GACf,eAAgBM,EAAA,CAClB,CAEJ"}
1
+ {"version":3,"file":"LoginForm.js","sources":["/@dropins/storefront-checkout/src/components/LoginForm/Email.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignIn.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginFormSkeleton.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginForm.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignOut.tsx","/@dropins/storefront-checkout/src/containers/LoginForm/LoginForm.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginEmailProps extends HTMLAttributes<HTMLInputElement> {\n value: string;\n error: string;\n hint: string;\n onChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n onInvalid: (event: Event) => void;\n}\n\nexport const Email: FunctionComponent<LoginEmailProps> = ({\n value,\n error,\n hint,\n onChange,\n onBlur,\n onInvalid,\n}) => {\n const translations = useText({\n LoginFormLabel: 'Checkout.LoginForm.ariaLabel',\n LoginFormFloatingLabel: 'Checkout.LoginForm.floatingLabel',\n LoginFormPlaceholder: 'Checkout.LoginForm.placeholder',\n });\n\n return (\n <Field error={error} hint={hint}>\n <Input\n aria-label={translations.LoginFormLabel}\n aria-required={true}\n autocomplete=\"email\"\n floatingLabel={translations.LoginFormFloatingLabel}\n id=\"customer-email\"\n name=\"customer-email\"\n placeholder={translations.LoginFormPlaceholder}\n required={true}\n type=\"email\"\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onInvalid={onInvalid}\n />\n </Field>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignInProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignIn: FunctionComponent<SignInProps> = ({ onClick }) => {\n const translations = useText({\n account: 'Checkout.LoginForm.account',\n signIn: 'Checkout.LoginForm.signIn'\n });\n\n return (\n <div className=\"checkout-login-form__sign-in\">\n {translations.account}\n\n <a\n className=\"checkout-login-form__link\"\n data-testid=\"sign-in-link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick(event);\n }}\n >\n {translations.signIn}\n </a>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const LoginFormSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"login-form-skeleton\">\n <SkeletonRow fullWidth={true} variant=\"heading\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Email } from '@/checkout/components';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/LoginForm/LoginForm.css';\nimport { LoginFormSkeleton } from '@/checkout/components/LoginForm/LoginFormSkeleton';\nimport { Customer } from '@/checkout/data/models';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginFormProps\n extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n customer: Customer | null;\n email: string;\n error: string;\n headingContent?: VNode;\n hint: string | VNode;\n onEmailBlur: (event: Event) => void;\n onEmailChange: (event: Event) => void;\n onEmailInvalid: (event: Event) => void;\n title?: VNode;\n}\n\nconst LoginFormComponent: FunctionComponent<LoginFormProps> = ({\n className,\n customer,\n email,\n error,\n headingContent,\n hint,\n name,\n onEmailBlur,\n onEmailChange,\n onEmailInvalid,\n title,\n ...props\n}) => {\n return (\n <div className=\"checkout-login-form\" data-testid=\"checkout-login-form\">\n <div className=\"checkout-login-form__heading\">\n {title && (\n <VComponent className=\"checkout-login-form__title\" node={title} />\n )}\n\n {headingContent && (\n <VComponent\n className=\"checkout-login-form__heading-label\"\n node={headingContent}\n />\n )}\n </div>\n\n {customer ? (\n <div className=\"checkout-login-form__customer-details\">\n <div className=\"checkout-login-form__customer-name\">\n {`${customer.firstName} ${customer.lastName}`}\n </div>\n\n <div className=\"checkout-login-form__customer-email\">\n {customer.email}\n </div>\n </div>\n ) : (\n <div className=\"checkout-login-form__content\">\n <form\n {...props}\n noValidate\n className={classes(['dropin-login-form__form', className])}\n name={name}\n >\n {/* Prevent 'Enter' key press from submitting this form. */}\n <button\n disabled\n aria-hidden=\"true\"\n style=\"display: none\"\n type=\"submit\"\n />\n <Email\n error={error}\n hint={hint as any}\n value={email}\n onBlur={onEmailBlur}\n onChange={onEmailChange}\n onInvalid={onEmailInvalid}\n />\n </form>\n </div>\n )}\n </div>\n );\n};\n\nexport const LoginForm = WithConditionals(\n LoginFormComponent,\n LoginFormSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignOutProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignOut: FunctionComponent<SignOutProps> = ({ onClick }) => {\n const translations = useText({\n switch: 'Checkout.LoginForm.switch',\n signOut: 'Checkout.LoginForm.signOut'\n });\n\n return (\n <p className=\"checkout-login-form__sign-out\">\n {translations.switch}\n\n <a\n className=\"checkout-login-form__link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick?.(event);\n }}\n >\n {translations.signOut}\n </a>\n </p>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCustomer,\n isEmailAvailable,\n setGuestEmailOnCart,\n} from '@/checkout/api';\nimport {\n LoginForm as LoginFormComponent,\n SignIn,\n SignOut,\n} from '@/checkout/components/LoginForm';\nimport { Cart, Customer, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getCartEmail,\n getLatestCheckoutUpdate,\n getValue,\n notifyValues,\n validateEmail,\n} from '@/checkout/lib';\nimport { TitleProps } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\n\ninterface ValidationError {\n email: string;\n message: string;\n type: 'missing' | 'invalid';\n}\n\ninterface CartSyncError {\n email: string;\n error: Error;\n}\n\nexport interface LoginFormProps\n extends HTMLAttributes<HTMLFormElement>,\n TitleProps {\n active?: boolean;\n autoSync?: boolean;\n displayHeadingContent?: boolean;\n onSignInClick?: (email: string) => void;\n onSignOutClick?: () => void;\n onCartSyncError?: (error: CartSyncError) => void;\n onValidationError?: (error: ValidationError) => void;\n slots?: {\n Heading?: SlotProps<{\n authenticated: boolean;\n }>;\n } & TitleProps['slots'];\n}\n\nconst DEBOUNCE_TIME = 1000;\n\nexport const LoginForm: Container<LoginFormProps> = ({\n active = true,\n autoSync = true,\n displayHeadingContent = true,\n displayTitle = true,\n initialData,\n onCartSyncError,\n onSignInClick,\n onSignOutClick,\n onValidationError,\n slots,\n ...props\n}) => {\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [email, setEmail] = useState<string>('');\n const [error, setError] = useState<string>('');\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n const [isAvailable, setIsAvailable] = useState<boolean>(true);\n const [isInitialized, setIsInitialized] = useState<boolean>(false);\n\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const {\n alreadyHaveAccountHint,\n cartSyncError,\n defaultTitle,\n fasterCheckoutHint,\n invalidEmailError,\n missingEmailError,\n signInLabel,\n } = useText({\n alreadyHaveAccountHint: 'Checkout.LoginForm.emailExists.alreadyHaveAccount',\n cartSyncError: 'Checkout.LoginForm.cartSyncError',\n defaultTitle: 'Checkout.LoginForm.title',\n fasterCheckoutHint: 'Checkout.LoginForm.emailExists.forFasterCheckout',\n invalidEmailError: 'Checkout.LoginForm.invalidEmailError',\n missingEmailError: 'Checkout.LoginForm.missingEmailError',\n signInLabel: 'Checkout.LoginForm.emailExists.signInButton',\n });\n\n const setEmailAndCheckAvailability = useCallback(\n (email: string) => {\n if (!validateEmail(email) || email === getCartEmail()) return;\n\n isEmailAvailable(email)\n .then((availability) => {\n setIsAvailable(availability);\n })\n .catch((error) => {\n console.error(error);\n setIsAvailable(true);\n });\n\n if (!autoSync) return;\n\n setGuestEmailOnCart(email).catch((error) => {\n onCartSyncError?.({ email, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, onCartSyncError, cartSyncError]\n );\n\n const handleChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value;\n\n setEmail(email);\n setIsAvailable(true);\n setError('');\n\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n debounceTimer.current = setTimeout(() => {\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n debounceTimer.current = null;\n }, DEBOUNCE_TIME);\n },\n [setEmailAndCheckAvailability]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value.trim();\n const isValid = validateEmail(email);\n\n if (isValid) {\n setError('');\n target.setCustomValidity('');\n\n if (!debounceTimer.current) return;\n\n clearTimeout(debounceTimer.current);\n debounceTimer.current = null;\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n return;\n }\n\n const type = email === '' ? 'missing' : 'invalid';\n const message =\n type === 'missing' ? missingEmailError : invalidEmailError;\n\n if (onValidationError) {\n onValidationError({ email, message, type });\n return;\n }\n\n setError(message);\n target.setCustomValidity(message);\n },\n [\n invalidEmailError,\n missingEmailError,\n onValidationError,\n setEmailAndCheckAvailability,\n ]\n );\n\n const handleInvalid = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const validity = target.validity;\n\n const message = validity.valueMissing\n ? missingEmailError\n : invalidEmailError;\n\n if (!onValidationError) {\n setError(message);\n return;\n }\n\n onValidationError({\n email: target.value,\n message,\n type: validity.valueMissing ? 'missing' : 'invalid',\n });\n },\n [missingEmailError, invalidEmailError, onValidationError]\n );\n\n const handleSignIn = useCallback(() => {\n const email = getValue('email') ?? '';\n const isValid = validateEmail(email);\n onSignInClick?.(isValid ? email : '');\n }, [onSignInClick]);\n\n const handleSignOut = useCallback(() => {\n onSignOutClick?.();\n }, [onSignOutClick]);\n\n const handleCheckoutData = useCallback((data: Cart | NegotiableQuote | null) => {\n const prevEmail = getValue('email') ?? '';\n const email = data?.email ?? '';\n\n if (email !== prevEmail) {\n setEmail(email);\n setError('');\n setIsAvailable(true);\n notifyValues({ email });\n }\n }, []);\n\n useEffect(() => {\n if (!active) return;\n\n const onAuthenticated = events.on(\n 'authenticated',\n (authenticated) => {\n setIsAuthenticated(authenticated);\n\n getCustomer()\n .then((customer) => {\n setCustomer(customer);\n })\n .catch(console.error);\n },\n { eager: true }\n );\n\n return () => {\n onAuthenticated?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore local state from checkout data\n const checkoutEmail = pastUpdate.email ?? '';\n if (checkoutEmail) {\n setEmail(checkoutEmail);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-login-form-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots, defaultTitle]);\n\n const headingContent = useMemo(() => {\n if (!displayHeadingContent) return undefined;\n\n return (\n <Slot\n context={{ authenticated: isAuthenticated }}\n name=\"checkout-login-form-heading-label\"\n slot={slots?.Heading}\n >\n {isAuthenticated ? (\n <SignOut onClick={handleSignOut} />\n ) : (\n <SignIn onClick={handleSignIn} />\n )}\n </Slot>\n );\n }, [\n displayHeadingContent,\n isAuthenticated,\n slots,\n handleSignIn,\n handleSignOut,\n ]);\n\n const hintContent = useMemo(() => {\n if (isAvailable) return '';\n\n return (\n <>\n {alreadyHaveAccountHint}{' '}\n <a href=\"#\" onClick={handleSignIn}>\n {signInLabel}\n </a>{' '}\n {fasterCheckoutHint}\n </>\n );\n }, [\n isAvailable,\n alreadyHaveAccountHint,\n signInLabel,\n fasterCheckoutHint,\n handleSignIn,\n ]);\n\n return (\n <LoginFormComponent\n {...props}\n customer={customer}\n email={email}\n error={error}\n headingContent={headingContent}\n hint={hintContent}\n initialized={isInitialized}\n title={titleContent}\n visible={active}\n onEmailBlur={handleBlur}\n onEmailChange={handleChange}\n onEmailInvalid={handleInvalid}\n />\n );\n};\n"],"names":["Email","value","error","hint","onChange","onBlur","onInvalid","translations","useText","jsx","Field","Input","SignIn","onClick","jsxs","event","LoginFormSkeleton","Skeleton","SkeletonRow","LoginFormComponent","className","customer","email","headingContent","name","onEmailBlur","onEmailChange","onEmailInvalid","title","props","VComponent","classes","LoginForm","WithConditionals","SignOut","DEBOUNCE_TIME","active","autoSync","displayHeadingContent","displayTitle","initialData","onCartSyncError","onSignInClick","onSignOutClick","onValidationError","slots","setCustomer","useState","setEmail","setError","isAuthenticated","setIsAuthenticated","isAvailable","setIsAvailable","isInitialized","setIsInitialized","debounceTimer","useRef","alreadyHaveAccountHint","cartSyncError","defaultTitle","fasterCheckoutHint","invalidEmailError","missingEmailError","signInLabel","setEmailAndCheckAvailability","useCallback","validateEmail","getCartEmail","isEmailAvailable","availability","setGuestEmailOnCart","handleChange","notifyValues","handleBlur","target","type","message","handleInvalid","validity","handleSignIn","getValue","isValid","handleSignOut","handleCheckoutData","data","prevEmail","useEffect","onAuthenticated","events","authenticated","getCustomer","pastUpdate","getLatestCheckoutUpdate","checkoutEmail","onCheckoutInit","onCheckoutUpdated","titleContent","useMemo","Slot","hintContent","Fragment"],"mappings":"wsCA+BO,MAAMA,GAA4C,CAAC,CACxD,MAAAC,EACA,MAAAC,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AAE,MAAO,EAAM,CACjB,EAEA,MAAO,IAAM,CACXY,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAAC5D,EAAQgD,CAAkB,CAAC,EAEzB,MAAAa,GAAeC,EAAQ,IAAM,CAC7B,GAAC3D,EAGH,OAAA9B,EAAC0F,EAAK,CAAA,KAAK,4BAA4B,KAAMtD,GAAA,YAAAA,EAAO,MAClD,SAAApC,EAAC,KAAI,CAAA,SAAAmD,CAAa,CAAA,EACpB,CAED,EAAA,CAACrB,EAAcM,EAAOe,CAAY,CAAC,EAEhCrC,GAAiB2E,EAAQ,IAAM,CAC/B,GAAC5D,EAGH,OAAA7B,EAAC0F,EAAA,CACC,QAAS,CAAE,cAAejD,CAAgB,EAC1C,KAAK,oCACL,KAAML,GAAA,YAAAA,EAAO,QAEZ,SAAAK,IACEhB,GAAQ,CAAA,QAASiD,CAAe,CAAA,EAEjC1E,EAACG,GAAO,CAAA,QAASoE,CAAc,CAAA,CAAA,CAEnC,CAAA,EAED,CACD1C,EACAY,EACAL,EACAmC,EACAG,CAAA,CACD,EAEKiB,GAAcF,EAAQ,IACtB9C,EAAoB,GAInBtC,EAAAuF,GAAA,CAAA,SAAA,CAAA3C,EAAwB,MACxB,IAAE,CAAA,KAAK,IAAI,QAASsB,EAClB,SACHhB,EAAA,EAAK,IACJH,CAAA,EACH,EAED,CACDT,EACAM,EACAM,EACAH,EACAmB,CAAA,CACD,EAGC,OAAAvE,EAACU,GAAA,CACE,GAAGU,EACJ,SAAAR,EACA,MAAAC,EACA,MAAApB,EACA,eAAAqB,GACA,KAAM6E,GACN,YAAa9C,GACb,MAAO2C,GACP,QAAS7D,EACT,YAAasC,GACb,cAAeF,GACf,eAAgBM,EAAA,CAClB,CAEJ"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{h as ae,s as ce}from"../chunks/fetch-graphql.js";import{classes as V,VComponent as se,deepmerge as ie,Slot as H}from"@dropins/tools/lib.js";import{events as B}from"@dropins/tools/event-bus.js";import{v as me}from"../chunks/validation.js";import{s as q}from"../chunks/setPaymentMethod.js";import{jsxs as U,jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{useState as w,useMemo as $,useCallback as P,useEffect as j}from"@dropins/tools/preact-hooks.js";import"../chunks/TermsAndConditions.js";import{Skeleton as de,SkeletonRow as N,IllustratedMessage as ue,Icon as J,InLineAlert as le,ToggleButton as he,RadioButton as pe}from"@dropins/tools/components.js";/* empty css */import*as T from"@dropins/tools/preact-compat.js";import{useRef as fe,useEffect as ye}from"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css *//* empty css */import{P as ke}from"../chunks/PurchaseOrder.js";import{P as ge}from"../chunks/PaymentOnAccount2.js";import{r as Me}from"../chunks/render.js";import{i as Se}from"../chunks/events.js";import{h as Ce,a as Pe}from"../chunks/events2.js";import{g as b,n as F}from"../chunks/values.js";import{W as ve}from"../chunks/ConditionalWrapper.js";import{s as Ee}from"../chunks/dom.js";import{useText as K}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/guards.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/getCompanyCredit.js";const _e=e=>T.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},T.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),we=()=>U(de,{"data-testid":"payment-methods-skeleton",children:[a(N,{size:"medium",variant:"heading"}),a(N,{size:"medium",variant:"empty"}),a(N,{fullWidth:!0,size:"xlarge"}),a(N,{fullWidth:!0,size:"xlarge"})]}),Ne=({UIComponentType:e="ToggleButton",busy:r,code:o,icon:m,onSelectionChange:n,selected:c,title:u})=>{const l={busy:r,className:"checkout-payment-methods__method",label:u,name:"payment-method",onChange:()=>n({code:o,title:u}),value:o};return e==="ToggleButton"?a(he,{...l,icon:m?a(J,{source:m}):void 0,selected:c}):a(pe,{...l,checked:c,icon:m??void 0})},Te=({className:e,error:r=null,busy:o=!1,onDismissError:m,onSelectionChange:n=()=>{},options:c,paymentMethodContent:u,selection:l,title:y,UIComponentType:C})=>{const M=K({EmptyState:"Checkout.PaymentMethods.emptyState"}),d=r!==null,S=fe(null);return ye(()=>{d&&S.current&&Ee(S.current)},[d]),U("div",{className:V(["checkout-payment-methods",e]),"data-testid":"checkout-payment-methods",children:[y&&a(se,{className:"checkout-payment-methods__title",node:y}),!o&&c.length===0&&a(ue,{"data-testid":"checkout-payment-methods-empty",icon:a(J,{source:_e}),message:a("p",{children:M.EmptyState})}),U("div",{className:V(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--busy",o]]),"data-testid":"checkout-payment-methods-wrapper",children:[a("div",{className:V(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(k=>a(Ne,{UIComponentType:C,busy:o,code:k.code,icon:k.icon,selected:(l==null?void 0:l.code)===k.code,title:k.displayLabel??!0?k.title:"",onSelectionChange:n},k.code))}),u&&a("div",{className:"checkout-payment-methods__content",children:u})]}),d&&a("div",{ref:S,className:"checkout-payment-methods__error","data-testid":"checkout-payment-methods-alert",children:a(le,{heading:r,type:"error",variant:"primary",onDismiss:m})})]})},be=ve(Te,we),Ie=(e,r)=>{let o;return function(...m){clearTimeout(o),o=setTimeout(()=>e.apply(this,m),r)}};var Oe=(e=>(e.PaymentOnAccount="companycredit",e.PurchaseOrder="purchaseorder",e))(Oe||{});const Z={companycredit:{Container:ge,autoSync:!0,formName:"payment-on-account",validateRefNumber:!1},purchaseorder:{Container:ke,autoSync:!1,formName:"purchase-order",validateRefNumber:!0}},I=new Map,Le=(e,r)=>{const o=`${e}-${r}`;if(!I.has(o)){const m=Ie(async n=>{if(!r||me(n))try{await q({code:e,purchase_order_number:n})}catch(c){console.error(`Failed to set payment method for ${e}:`,c)}},1e3);I.set(o,m)}return I.get(o)},_={},pt=()=>{Object.keys(_).forEach(e=>{delete _[e]}),I.clear()},G=e=>{if(!(e in Z))throw new Error(`Invalid handler code: ${e}`);if(_[e])return _[e];const r=Z[e],{autoSync:o,Container:m,formName:n,validateRefNumber:c}=r,u={enabled:!0,autoSync:o,render:l=>{var M;const y=String(((M=l.additionalData)==null?void 0:M.purchase_order_number)??""),C=document.createElement("div");Me.render(m,{name:n,initialReferenceNumber:y,onReferenceNumberChange:Le(e,c)})(C),l.replaceHTML(C)}};return _[e]=u,u},Ve={companycredit:G("companycredit"),purchaseorder:G("purchaseorder")};function R(e,r){return e?r.some(o=>o.code===e.code):!1}function Re(e,r){return!e||!r?!1:e.code===r.code}function Ue(e){return e?!!e.code&&!!e.title:!1}const ft=({UIComponentType:e="ToggleButton",active:r=!0,autoSync:o=!0,displayTitle:m=!0,slots:n,onCartSyncError:c,onSelectionChange:u})=>{const[l,y]=w(null),[C,M]=w(!1),[d,S]=w(null),[k,A]=w([]),Q=ae.value,h=$(()=>{const t=(n==null?void 0:n.Methods)??{};return ie(Ve,t)},[n==null?void 0:n.Methods]),X=k.filter(t=>{var s;return((s=h==null?void 0:h[t.code])==null?void 0:s.enabled)!==!1}).map(t=>{const s=(h==null?void 0:h[t.code])||{};return{...t,...s}}),{cartSyncError:W,defaultTitle:x}=K({cartSyncError:"Checkout.PaymentMethods.cartSyncError",defaultTitle:"Checkout.PaymentMethods.title"}),Y=P(t=>{S(i=>i&&{...i,additionalData:t});const s=b("selectedPaymentMethod");s&&F({selectedPaymentMethod:{...s,additionalData:t}})},[]),ee=P(()=>{y(null)},[]),f=P(t=>{y(null),S(t),F({selectedPaymentMethod:t})},[]),v=P(async(t,s)=>{if(!(Se()||Ce()))return;const p=h==null?void 0:h[t.code];((p==null?void 0:p.autoSync)??o)&&q({code:t.code}).catch(g=>{f(s??null),c==null||c({method:t,error:g}),c||y(W)})},[h,o,f,c,W]),te=P(async t=>{const s=b("selectedPaymentMethod");f(t),u==null||u(t),await v(t,s)},[u,f,v]),E=P(t=>{if(!t||t.isEmpty){f(null),A([]);return}const i=t.availablePaymentMethods??[];if(A(i),i.length===0){f(null);return}const p=t.selectedPaymentMethod??null,O=Ue(p),g=b("selectedPaymentMethod"),L=R(g,i),oe=Re(g,p);if(g&&L&&!oe){v(g,p);return}if((!g||!L)&&O&&R(p,i)){f(p);return}if((!g||!L)&&(!O||!R(p,i))){const D=i[0];f(D),v(D)}},[f,v]);j(()=>{if(!r)return;const t=Pe();if(t){M(!0);const i=b("selectedPaymentMethod");i&&S(i),E(t);return}const s=B.on("checkout/initialized",i=>{M(!0),E(i)},{eager:!0});return()=>{s==null||s.off()}},[r,E]),j(()=>{if(!r)return;const t=B.on("checkout/updated",E,{eager:!1});return()=>{t==null||t.off()}},[r,E]);const z=h[(d==null?void 0:d.code)||""],re=z?a(H,{context:{additionalData:d==null?void 0:d.additionalData,cartId:ce.cartId??"",replaceHTML(t){this.replaceWith(t)},setAdditionalData:Y},name:"PaymentMethodContent",slot:z.render},d==null?void 0:d.code):void 0,ne=$(()=>{if(m)return a(H,{name:"checkout-payment-methods-title",slot:n==null?void 0:n.Title,children:a("h2",{children:x})})},[m,n==null?void 0:n.Title,x]);return a(be,{UIComponentType:e,busy:Q,error:l,initialized:C,options:X,paymentMethodContent:re,selection:d,title:ne,visible:r,onDismissError:ee,onSelectionChange:te})};export{Oe as HandlerCode,ft as PaymentMethods,G as createHandler,ft as default,Ve as defaultHandlers,Le as handleRefNumberChange,pt as resetHandlersCache};
3
+ import{h as ae,s as ce}from"../chunks/fetch-graphql.js";import{classes as V,VComponent as se,deepmerge as ie,Slot as j}from"@dropins/tools/lib.js";import{events as F}from"@dropins/tools/event-bus.js";import{v as me}from"../chunks/validation.js";import{s as K}from"../chunks/setPaymentMethod.js";import{jsxs as W,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{useState as N,useMemo as T,useCallback as E,useEffect as D}from"@dropins/tools/preact-hooks.js";import"../chunks/TermsAndConditions.js";import{Skeleton as de,SkeletonRow as I,IllustratedMessage as ue,Icon as Q,InLineAlert as le,ToggleButton as he,RadioButton as pe}from"@dropins/tools/components.js";/* empty css */import*as O from"@dropins/tools/preact-compat.js";import{useRef as fe,useEffect as ye}from"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css *//* empty css */import{P as ke}from"../chunks/PurchaseOrder.js";import{P as ge}from"../chunks/PaymentOnAccount2.js";import{r as Me}from"../chunks/render.js";import{i as Se}from"../chunks/events.js";import{h as ve,a as Ce}from"../chunks/events2.js";import{g as L,n as Z}from"../chunks/values.js";import{W as Pe}from"../chunks/ConditionalWrapper.js";import{s as Ee}from"../chunks/dom.js";import{useText as X}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/guards.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/getCompanyCredit.js";const be=e=>O.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},O.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),O.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),O.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),_e=()=>W(de,{"data-testid":"payment-methods-skeleton",children:[s(I,{size:"medium",variant:"heading"}),s(I,{size:"medium",variant:"empty"}),s(I,{fullWidth:!0,size:"xlarge"}),s(I,{fullWidth:!0,size:"xlarge"})]}),we=({UIComponentType:e="ToggleButton",busy:n,code:c,icon:m,onSelectionChange:o,selected:i,title:d})=>{const l={busy:n,className:"checkout-payment-methods__method",label:d,name:"payment-method",onChange:()=>o({code:c,title:d}),value:c};return e==="ToggleButton"?s(he,{...l,icon:m?s(Q,{source:m}):void 0,selected:i}):s(pe,{...l,checked:i,icon:m??void 0})},Ne=({className:e,error:n=null,busy:c=!1,onDismissError:m,onSelectionChange:o=()=>{},options:i,paymentMethodContent:d,selection:l,title:g,UIComponentType:P})=>{const M=X({EmptyState:"Checkout.PaymentMethods.emptyState"}),h=n!==null,S=fe(null);return ye(()=>{h&&S.current&&Ee(S.current)},[h]),W("div",{className:V(["checkout-payment-methods",e]),"data-testid":"checkout-payment-methods",children:[g&&s(se,{className:"checkout-payment-methods__title",node:g}),!c&&i.length===0&&s(ue,{"data-testid":"checkout-payment-methods-empty",icon:s(Q,{source:be}),message:s("p",{children:M.EmptyState})}),W("div",{className:V(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--busy",c]]),"data-testid":"checkout-payment-methods-wrapper",children:[s("div",{className:V(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",i.length%2!==0]]),children:i==null?void 0:i.map(k=>s(we,{UIComponentType:P,busy:c,code:k.code,icon:k.icon,selected:(l==null?void 0:l.code)===k.code,title:k.displayLabel??!0?k.title:"",onSelectionChange:o},k.code))}),d&&s("div",{className:"checkout-payment-methods__content",children:d})]}),h&&s("div",{ref:S,className:"checkout-payment-methods__error","data-testid":"checkout-payment-methods-alert",children:s(le,{heading:n,type:"error",variant:"primary",onDismiss:m})})]})},Te=Pe(Ne,_e),Ie=(e,n)=>{let c;return function(...m){clearTimeout(c),c=setTimeout(()=>e.apply(this,m),n)}};var Oe=(e=>(e.PaymentOnAccount="companycredit",e.PurchaseOrder="purchaseorder",e))(Oe||{});const G={companycredit:{Container:ge,autoSync:!0,formName:"payment-on-account",validateRefNumber:!1},purchaseorder:{Container:ke,autoSync:!1,formName:"purchase-order",validateRefNumber:!0}},A=new Map,Le=(e,n)=>{const c=`${e}-${n}`;if(!A.has(c)){const m=Ie(async o=>{if(!n||me(o))try{await K({code:e,purchase_order_number:o})}catch(i){console.error(`Failed to set payment method for ${e}:`,i)}},1e3);A.set(c,m)}return A.get(c)},w={},ht=()=>{Object.keys(w).forEach(e=>{delete w[e]}),A.clear()},q=e=>{if(!(e in G))throw new Error(`Invalid handler code: ${e}`);if(w[e])return w[e];const n=G[e],{autoSync:c,Container:m,formName:o,validateRefNumber:i}=n,d={enabled:!0,autoSync:c,render:l=>{var M;const g=String(((M=l.additionalData)==null?void 0:M.purchase_order_number)??""),P=document.createElement("div");Me.render(m,{name:o,initialReferenceNumber:g,onReferenceNumberChange:Le(e,i)})(P),l.replaceHTML(P)}};return w[e]=d,d},Ue={companycredit:q("companycredit"),purchaseorder:q("purchaseorder")};function U(e,n){return e?n.some(c=>c.code===e.code):!1}function J(e,n){return!e||!n?!1:e.code===n.code}function Ae(e){return e?!!e.code&&!!e.title:!1}const pt=({UIComponentType:e="ToggleButton",active:n=!0,autoSync:c=!0,displayTitle:m=!0,slots:o,onCartSyncError:i,onSelectionChange:d})=>{const[l,g]=N(null),[P,M]=N(!1),[h,S]=N(null),[k,x]=N([]),Y=ae.value,{cartSyncError:z,defaultTitle:H}=X({cartSyncError:"Checkout.PaymentMethods.cartSyncError",defaultTitle:"Checkout.PaymentMethods.title"}),p=T(()=>{const t=(o==null?void 0:o.Methods)??{};return ie(Ue,t)},[o==null?void 0:o.Methods]),v=T(()=>k.filter(t=>{var a;return((a=p==null?void 0:p[t.code])==null?void 0:a.enabled)!==!1}).map(t=>{const a=(p==null?void 0:p[t.code])||{};return{...t,...a}}),[k,p]),B=E(t=>{S(r=>r&&{...r,additionalData:t});const a=L("selectedPaymentMethod");a&&Z({selectedPaymentMethod:{...a,additionalData:t}})},[]),ee=E(()=>{g(null)},[]),f=E(t=>{g(null),S(t),Z({selectedPaymentMethod:t})},[]),C=E(async(t,a)=>{if(!(Se()||ve()))return;const u=p==null?void 0:p[t.code];((u==null?void 0:u.autoSync)??c)&&K({code:t.code}).catch(y=>{f(a??null),i==null||i({method:t,error:y}),i||g(z)})},[p,c,f,i,z]),te=E(async t=>{const a=L("selectedPaymentMethod");f(t),d==null||d(t),await C(t,a)},[d,f,C]),b=E(t=>{if(!t||t.isEmpty){f(null),x([]);return}const r=t.availablePaymentMethods??[];if(x(r),r.length===0){f(null);return}const u=t.selectedPaymentMethod??null,_=Ae(u),y=L("selectedPaymentMethod"),R=U(y,r),oe=J(y,u);if(y&&R&&!oe){C(y,u);return}if((!y||!R)&&_&&U(u,r)){f(u);return}if((!y||!R)&&(!_||!U(u,r))){const $=r[0];f($),C($)}},[f,C]);D(()=>{if(!n)return;const t=Ce();if(t){M(!0);const r=L("selectedPaymentMethod");r&&S(r),b(t);return}const a=F.on("checkout/initialized",r=>{M(!0),b(r)},{eager:!0});return()=>{a==null||a.off()}},[n,b]),D(()=>{if(!n)return;const t=F.on("checkout/updated",b,{eager:!1});return()=>{t==null||t.off()}},[n,b]),D(()=>{if(v.length===0||U(h,v))return;const a=v[0],{code:r,title:u,additionalData:_}=a,y={code:r,title:u,additionalData:_};f(y),C(y)},[v,h,f,C]);const ne=T(()=>{if(m)return s(j,{name:"checkout-payment-methods-title",slot:o==null?void 0:o.Title,children:s("h2",{children:H})})},[m,o==null?void 0:o.Title,H]),re=T(()=>{var a;const t=(a=v.find(r=>J(r,h)))==null?void 0:a.render;if(t)return s(j,{context:{additionalData:h.additionalData,cartId:ce.cartId??"",replaceHTML(r){this.replaceWith(r)},setAdditionalData:B},name:"PaymentMethodContent",slot:t},h.code)},[v,h,B]);return s(Te,{UIComponentType:e,busy:Y,error:l,initialized:P,options:v,paymentMethodContent:re,selection:h,title:ne,visible:n,onDismissError:ee,onSelectionChange:te})};export{Oe as HandlerCode,pt as PaymentMethods,q as createHandler,pt as default,Ue as defaultHandlers,Le as handleRefNumberChange,ht as resetHandlersCache};
4
4
  //# sourceMappingURL=PaymentMethods.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentMethods.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Wallet.svg","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethods.tsx","../../node_modules/@adobe-commerce/elsie/src/lib/debounce.ts","/@dropins/storefront-checkout/src/containers/PaymentMethods/handlers.tsx","/@dropins/storefront-checkout/src/containers/PaymentMethods/PaymentMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgWallet = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.35 11.64H14.04V14.81H19.35V11.64Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M17.9304 11.64V8.25H15.1504\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgWallet;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const PaymentMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"payment-methods-skeleton\">\n <SkeletonRow size=\"medium\" variant=\"heading\" />\n <SkeletonRow size=\"medium\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/PaymentMethods/PaymentMethods.css';\nimport { PaymentMethodsSkeleton } from '@/checkout/components/PaymentMethods/PaymentMethodsSkeleton';\nimport { PaymentMethodConfig } from '@/checkout/containers';\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Wallet } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useEffect, useRef } from 'preact/compat';\n\ninterface ExtendedPaymentMethod extends PaymentMethodConfig, PaymentMethod {}\n\nexport interface PaymentMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n error?: string | null;\n busy?: boolean;\n onDismissError?: () => void;\n onSelectionChange?: (value: PaymentMethod) => void;\n options?: ExtendedPaymentMethod[];\n paymentMethodContent?: VNode;\n selection: PaymentMethod | null;\n title?: VNode;\n UIComponentType?: UIComponentType;\n}\n\ninterface PaymentOptionProps {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n code: string;\n icon?: string;\n onSelectionChange: (value: PaymentMethod) => void;\n selected: boolean;\n title: string;\n}\n\nconst PaymentOption: FunctionComponent<PaymentOptionProps> = ({\n UIComponentType = 'ToggleButton',\n busy,\n code,\n icon,\n onSelectionChange,\n selected,\n title,\n}) => {\n const commonProps = {\n busy,\n className: 'checkout-payment-methods__method',\n label: title,\n name: 'payment-method',\n onChange: () => onSelectionChange({ code, title }),\n value: code,\n };\n\n return UIComponentType === 'ToggleButton' ? (\n <ToggleButton\n {...commonProps}\n // @ts-ignore\n icon={icon ? <Icon source={icon} /> : undefined}\n selected={selected}\n />\n ) : (\n <RadioButton {...commonProps} checked={selected} icon={icon ?? undefined} />\n );\n};\n\nconst PaymentMethodsComponent: FunctionComponent<PaymentMethodsProps> = ({\n className,\n error = null,\n busy = false,\n onDismissError,\n onSelectionChange = () => {},\n options,\n paymentMethodContent,\n selection,\n title,\n UIComponentType,\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.PaymentMethods.emptyState',\n });\n\n const hasError = error !== null;\n const errorRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (hasError && errorRef.current) {\n scrollToElement(errorRef.current);\n }\n }, [hasError]);\n\n return (\n <div\n className={classes(['checkout-payment-methods', className])}\n data-testid=\"checkout-payment-methods\"\n >\n {title && (\n <VComponent className=\"checkout-payment-methods__title\" node={title} />\n )}\n\n {!busy && options!.length === 0 && (\n <IllustratedMessage\n data-testid=\"checkout-payment-methods-empty\"\n icon={<Icon source={Wallet} />}\n message={<p>{translations.EmptyState}</p>}\n />\n )}\n\n <div\n className={classes([\n 'checkout-payment-methods__wrapper',\n ['checkout-payment-methods__wrapper--busy', busy],\n ])}\n data-testid=\"checkout-payment-methods-wrapper\"\n >\n <div\n className={classes([\n 'checkout-payment-methods__methods',\n ['checkout-payment-methods--full-width', options!.length % 2 !== 0],\n ])}\n >\n {options?.map((method) => (\n <PaymentOption\n key={method.code}\n UIComponentType={UIComponentType}\n busy={busy}\n code={method.code}\n icon={method.icon}\n selected={selection?.code === method.code}\n title={method.displayLabel ?? true ? method.title : ''}\n onSelectionChange={onSelectionChange}\n />\n ))}\n </div>\n\n {paymentMethodContent && (\n <div className=\"checkout-payment-methods__content\">\n {paymentMethodContent}\n </div>\n )}\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-payment-methods__error\"\n data-testid=\"checkout-payment-methods-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const PaymentMethods = WithConditionals(\n PaymentMethodsComponent,\n PaymentMethodsSkeleton\n);\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const debounce = (fn: Function, ms: number) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setPaymentMethod } from '@/checkout/api';\nimport {\n PaymentMethodConfig,\n PaymentOnAccount,\n PurchaseOrder,\n} from '@/checkout/containers';\nimport { validateNotEmpty } from '@/checkout/lib/validation';\nimport { render as Checkout } from '@/checkout/render/render';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { debounce } from '@adobe-commerce/elsie/lib/debounce';\n\ninterface HandlerConfig {\n Container: Container<any>;\n autoSync: boolean;\n formName?: string;\n validateRefNumber: boolean;\n}\n\nexport enum HandlerCode {\n PaymentOnAccount = 'companycredit',\n PurchaseOrder = 'purchaseorder',\n}\n\nconst HANDLERS_CONFIG: Record<HandlerCode, HandlerConfig> = {\n [HandlerCode.PaymentOnAccount]: {\n Container: PaymentOnAccount,\n autoSync: true,\n formName: 'payment-on-account',\n validateRefNumber: false,\n },\n [HandlerCode.PurchaseOrder]: {\n Container: PurchaseOrder,\n autoSync: false,\n formName: 'purchase-order',\n validateRefNumber: true,\n },\n} as const;\n\n// Cache for debounced handlers to prevent memory leaks\nconst debouncedHandlers = new Map<string, ReturnType<typeof debounce>>();\n\nexport const handleRefNumberChange = (code: string, isRequired: boolean) => {\n const key = `${code}-${isRequired}`;\n\n if (!debouncedHandlers.has(key)) {\n const debouncedFn = debounce(async (refNumber: string) => {\n if (!isRequired || validateNotEmpty(refNumber)) {\n try {\n await setPaymentMethod({\n code,\n purchase_order_number: refNumber,\n });\n } catch (error) {\n console.error(`Failed to set payment method for ${code}:`, error);\n }\n }\n }, 1000);\n\n debouncedHandlers.set(key, debouncedFn);\n }\n\n return debouncedHandlers.get(key)!;\n};\n\nconst handlerCache: Partial<Record<HandlerCode, PaymentMethodConfig>> = {};\n\nexport const resetHandlersCache = () => {\n Object.keys(handlerCache).forEach((key) => {\n delete handlerCache[key as HandlerCode];\n });\n\n debouncedHandlers.clear();\n};\n\nexport const createHandler = (code: HandlerCode): PaymentMethodConfig => {\n if (!(code in HANDLERS_CONFIG)) {\n throw new Error(`Invalid handler code: ${code}`);\n }\n\n if (handlerCache[code]) {\n return handlerCache[code] as PaymentMethodConfig;\n }\n\n const config = HANDLERS_CONFIG[code];\n\n const { autoSync, Container, formName, validateRefNumber } = config;\n\n const handler: PaymentMethodConfig = {\n enabled: true,\n autoSync,\n render: (ctx) => {\n const initialReferenceNumber = String(\n ctx.additionalData?.purchase_order_number ?? ''\n );\n\n const $wrapper = document.createElement('div');\n\n Checkout.render(Container, {\n name: formName,\n initialReferenceNumber,\n onReferenceNumberChange: handleRefNumberChange(code, validateRefNumber),\n })($wrapper);\n\n ctx.replaceHTML($wrapper);\n },\n };\n\n handlerCache[code] = handler;\n\n return handler;\n};\n\nexport const defaultHandlers = {\n [HandlerCode.PaymentOnAccount]: createHandler(HandlerCode.PaymentOnAccount),\n [HandlerCode.PurchaseOrder]: createHandler(HandlerCode.PurchaseOrder),\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setPaymentMethod } from '@/checkout/api';\nimport { PaymentMethods as PaymentMethodsComponent } from '@/checkout/components/PaymentMethods/PaymentMethods';\nimport { Cart } from '@/checkout/data/models/cart';\nimport {\n AdditionalData,\n PaymentMethod,\n} from '@/checkout/data/models/payment-method';\nimport { NegotiableQuote } from '@/checkout/data/models/quote';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n hasShippingAddress,\n isVirtualCart,\n notifyValues,\n state,\n} from '@/checkout/lib';\nimport { TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n Container,\n deepmerge,\n Slot,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport { defaultHandlers } from './handlers';\n\ninterface RenderContext {\n additionalData?: AdditionalData;\n cartId: string;\n replaceHTML: (domElement: HTMLElement) => void;\n setAdditionalData: (data: AdditionalData) => void;\n}\n\nexport interface PaymentMethodConfig {\n autoSync?: boolean;\n displayLabel?: boolean;\n enabled?: boolean;\n icon?: string;\n render?: SlotProps<RenderContext>;\n}\n\nexport interface PaymentMethodHandlers {\n [code: string]: PaymentMethodConfig;\n}\n\ninterface CartSyncError {\n method: PaymentMethod;\n error: Error;\n}\n\nexport interface PaymentMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n slots?: {\n Methods?: PaymentMethodHandlers;\n } & TitleProps['slots'];\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: PaymentMethod) => void;\n}\n\nfunction isValidSelection(\n selection: PaymentMethod | null,\n options: PaymentMethod[]\n) {\n if (!selection) return false;\n return options.some((option) => option.code === selection.code);\n}\n\nfunction isEqual(a: PaymentMethod | null, b: PaymentMethod | null) {\n if (!a || !b) return false;\n return a.code === b.code;\n}\n\nfunction isValidPaymentMethod(method: PaymentMethod | null) {\n if (!method) return false;\n return !!method.code && !!method.title;\n}\n\nexport const PaymentMethods: Container<PaymentMethodsProps> = ({\n UIComponentType = 'ToggleButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n slots,\n onCartSyncError,\n onSelectionChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [selection, setSelection] = useState<PaymentMethod | null>(null);\n const [options, setOptions] = useState<PaymentMethod[]>([]);\n const isBusy = hasPendingUpdates.value;\n\n const availableHandlers = useMemo(() => {\n const customHandlers = slots?.Methods ?? {};\n return deepmerge(defaultHandlers, customHandlers);\n }, [slots?.Methods]);\n\n const enabledOptions = options\n .filter((method) => {\n return availableHandlers?.[method.code]?.enabled !== false;\n })\n .map((method) => {\n const slotMethod = availableHandlers?.[method.code] || {};\n\n return {\n ...method,\n ...slotMethod,\n };\n });\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.PaymentMethods.cartSyncError',\n defaultTitle: 'Checkout.PaymentMethods.title',\n });\n\n const setAdditionalData = useCallback((additionalData: AdditionalData) => {\n setSelection((prev) => {\n if (!prev) return prev;\n return { ...prev, additionalData };\n });\n\n const currentSelection = getValue('selectedPaymentMethod');\n\n if (!currentSelection) return;\n\n notifyValues({\n selectedPaymentMethod: {\n ...currentSelection,\n additionalData,\n },\n });\n }, []);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback((selection: PaymentMethod | null) => {\n setError(null);\n setSelection(selection);\n notifyValues({ selectedPaymentMethod: selection });\n }, []);\n\n const setUserSelectionOnCart = useCallback(\n async (selection: PaymentMethod, fallback?: PaymentMethod | null) => {\n const canSetUserSelectionOnCart = isVirtualCart() || hasShippingAddress();\n if (!canSetUserSelectionOnCart) return;\n\n const methodConfig = availableHandlers?.[selection.code];\n const shouldAutoSync = methodConfig?.autoSync ?? autoSync;\n\n if (!shouldAutoSync) return;\n\n setPaymentMethod({ code: selection.code }).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [\n availableHandlers,\n autoSync,\n setUserSelection,\n onCartSyncError,\n cartSyncError,\n ]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: PaymentMethod) => {\n const prevSelection = getValue('selectedPaymentMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\n\n await setUserSelectionOnCart(selection, prevSelection);\n },\n [onSelectionChange, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n\n if (isEmptyCart) {\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const availableOptions = data.availablePaymentMethods ?? [];\n setOptions(availableOptions);\n\n if (availableOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = data.selectedPaymentMethod ?? null;\n const hasCartSelection = isValidPaymentMethod(cartSelection);\n const userSelection = getValue('selectedPaymentMethod');\n const isAvailable = isValidSelection(userSelection, availableOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // User has valid selection that differs from cart\n if (userSelection && isAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // User has invalid selection but cart has valid selection\n if (\n (!userSelection || !isAvailable) &&\n hasCartSelection &&\n isValidSelection(cartSelection, availableOptions)\n ) {\n setUserSelection(cartSelection);\n return;\n }\n\n // Neither user nor cart has valid selection (or both selections are unavailable)\n if (\n (!userSelection || !isAvailable) &&\n (!hasCartSelection ||\n !isValidSelection(cartSelection, availableOptions))\n ) {\n const newSelection = availableOptions[0];\n setUserSelection(newSelection);\n setUserSelectionOnCart(newSelection);\n }\n },\n [setUserSelection, setUserSelectionOnCart]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedPaymentMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data: Cart | NegotiableQuote | null) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n const selectionConfig = availableHandlers[selection?.code || ''];\n\n const paymentMethodContent = selectionConfig ? (\n <Slot\n key={selection?.code}\n context={{\n additionalData: selection?.additionalData,\n cartId: state.cartId ?? '',\n replaceHTML(domElement: HTMLElement) {\n this.replaceWith(domElement);\n },\n setAdditionalData,\n }}\n name=\"PaymentMethodContent\"\n slot={selectionConfig.render}\n />\n ) : undefined;\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-payment-methods-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n return (\n <PaymentMethodsComponent\n UIComponentType={UIComponentType}\n busy={isBusy}\n error={error}\n initialized={isInitialized}\n options={enabledOptions}\n paymentMethodContent={paymentMethodContent}\n selection={selection}\n title={titleContent}\n visible={active}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgWallet","props","React","PaymentMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PaymentOption","UIComponentType","busy","code","icon","onSelectionChange","selected","title","commonProps","ToggleButton","Icon","RadioButton","PaymentMethodsComponent","className","error","onDismissError","options","paymentMethodContent","selection","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","classes","VComponent","IllustratedMessage","Wallet","method","InLineAlert","PaymentMethods","WithConditionals","debounce","fn","ms","timeoutId","args","HandlerCode","HANDLERS_CONFIG","PaymentOnAccount","PurchaseOrder","debouncedHandlers","handleRefNumberChange","isRequired","key","debouncedFn","refNumber","validateNotEmpty","setPaymentMethod","handlerCache","resetHandlersCache","createHandler","config","autoSync","Container","formName","validateRefNumber","handler","ctx","initialReferenceNumber","_a","$wrapper","Checkout","defaultHandlers","isValidSelection","option","isEqual","a","b","isValidPaymentMethod","active","displayTitle","slots","onCartSyncError","setError","useState","isInitialized","setIsInitialized","setSelection","setOptions","isBusy","hasPendingUpdates","availableHandlers","useMemo","customHandlers","deepmerge","enabledOptions","slotMethod","cartSyncError","defaultTitle","setAdditionalData","useCallback","additionalData","prev","currentSelection","getValue","notifyValues","handleDismissError","setUserSelection","setUserSelectionOnCart","fallback","isVirtualCart","hasShippingAddress","methodConfig","handleSelectionChange","prevSelection","handleCheckoutData","data","availableOptions","cartSelection","hasCartSelection","userSelection","isAvailable","haveSameSelection","newSelection","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","events","onCheckoutUpdated","selectionConfig","Slot","state","domElement","titleContent"],"mappings":"wpDACA,MAAMA,GAAaC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,gJAAiJ,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,wCAAyC,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aA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AApE,EACA,YAAagE,EACb,QAASU,EACT,qBAAAvE,GACA,UAAAC,EACA,MAAO4G,GACP,QAAStD,EACT,eAAgB2B,GAChB,kBAAmBO,EAAA,CACrB,CAEJ","x_google_ignoreList":[0,3]}
1
+ {"version":3,"file":"PaymentMethods.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Wallet.svg","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethods.tsx","../../node_modules/@adobe-commerce/elsie/src/lib/debounce.ts","/@dropins/storefront-checkout/src/containers/PaymentMethods/handlers.tsx","/@dropins/storefront-checkout/src/containers/PaymentMethods/PaymentMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgWallet = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.35 11.64H14.04V14.81H19.35V11.64Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M17.9304 11.64V8.25H15.1504\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgWallet;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const PaymentMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"payment-methods-skeleton\">\n <SkeletonRow size=\"medium\" variant=\"heading\" />\n <SkeletonRow size=\"medium\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/PaymentMethods/PaymentMethods.css';\nimport { PaymentMethodsSkeleton } from '@/checkout/components/PaymentMethods/PaymentMethodsSkeleton';\nimport { PaymentMethodConfig } from '@/checkout/containers';\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Wallet } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useEffect, useRef } from 'preact/compat';\n\ninterface ExtendedPaymentMethod extends PaymentMethodConfig, PaymentMethod {}\n\nexport interface PaymentMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n error?: string | null;\n busy?: boolean;\n onDismissError?: () => void;\n onSelectionChange?: (value: PaymentMethod) => void;\n options?: ExtendedPaymentMethod[];\n paymentMethodContent?: VNode;\n selection: PaymentMethod | null;\n title?: VNode;\n UIComponentType?: UIComponentType;\n}\n\ninterface PaymentOptionProps {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n code: string;\n icon?: string;\n onSelectionChange: (value: PaymentMethod) => void;\n selected: boolean;\n title: string;\n}\n\nconst PaymentOption: FunctionComponent<PaymentOptionProps> = ({\n UIComponentType = 'ToggleButton',\n busy,\n code,\n icon,\n onSelectionChange,\n selected,\n title,\n}) => {\n const commonProps = {\n busy,\n className: 'checkout-payment-methods__method',\n label: title,\n name: 'payment-method',\n onChange: () => onSelectionChange({ code, title }),\n value: code,\n };\n\n return UIComponentType === 'ToggleButton' ? (\n <ToggleButton\n {...commonProps}\n // @ts-ignore\n icon={icon ? <Icon source={icon} /> : undefined}\n selected={selected}\n />\n ) : (\n <RadioButton {...commonProps} checked={selected} icon={icon ?? undefined} />\n );\n};\n\nconst PaymentMethodsComponent: FunctionComponent<PaymentMethodsProps> = ({\n className,\n error = null,\n busy = false,\n onDismissError,\n onSelectionChange = () => {},\n options,\n paymentMethodContent,\n selection,\n title,\n UIComponentType,\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.PaymentMethods.emptyState',\n });\n\n const hasError = error !== null;\n const errorRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (hasError && errorRef.current) {\n scrollToElement(errorRef.current);\n }\n }, [hasError]);\n\n return (\n <div\n className={classes(['checkout-payment-methods', className])}\n data-testid=\"checkout-payment-methods\"\n >\n {title && (\n <VComponent className=\"checkout-payment-methods__title\" node={title} />\n )}\n\n {!busy && options!.length === 0 && (\n <IllustratedMessage\n data-testid=\"checkout-payment-methods-empty\"\n icon={<Icon source={Wallet} />}\n message={<p>{translations.EmptyState}</p>}\n />\n )}\n\n <div\n className={classes([\n 'checkout-payment-methods__wrapper',\n ['checkout-payment-methods__wrapper--busy', busy],\n ])}\n data-testid=\"checkout-payment-methods-wrapper\"\n >\n <div\n className={classes([\n 'checkout-payment-methods__methods',\n ['checkout-payment-methods--full-width', options!.length % 2 !== 0],\n ])}\n >\n {options?.map((method) => (\n <PaymentOption\n key={method.code}\n UIComponentType={UIComponentType}\n busy={busy}\n code={method.code}\n icon={method.icon}\n selected={selection?.code === method.code}\n title={method.displayLabel ?? true ? method.title : ''}\n onSelectionChange={onSelectionChange}\n />\n ))}\n </div>\n\n {paymentMethodContent && (\n <div className=\"checkout-payment-methods__content\">\n {paymentMethodContent}\n </div>\n )}\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-payment-methods__error\"\n data-testid=\"checkout-payment-methods-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const PaymentMethods = WithConditionals(\n PaymentMethodsComponent,\n PaymentMethodsSkeleton\n);\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const debounce = (fn: Function, ms: number) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setPaymentMethod } from '@/checkout/api';\nimport {\n PaymentMethodConfig,\n PaymentOnAccount,\n PurchaseOrder,\n} from '@/checkout/containers';\nimport { validateNotEmpty } from '@/checkout/lib/validation';\nimport { render as Checkout } from '@/checkout/render/render';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { debounce } from '@adobe-commerce/elsie/lib/debounce';\n\ninterface HandlerConfig {\n Container: Container<any>;\n autoSync: boolean;\n formName?: string;\n validateRefNumber: boolean;\n}\n\nexport enum HandlerCode {\n PaymentOnAccount = 'companycredit',\n PurchaseOrder = 'purchaseorder',\n}\n\nconst HANDLERS_CONFIG: Record<HandlerCode, HandlerConfig> = {\n [HandlerCode.PaymentOnAccount]: {\n Container: PaymentOnAccount,\n autoSync: true,\n formName: 'payment-on-account',\n validateRefNumber: false,\n },\n [HandlerCode.PurchaseOrder]: {\n Container: PurchaseOrder,\n autoSync: false,\n formName: 'purchase-order',\n validateRefNumber: true,\n },\n} as const;\n\n// Cache for debounced handlers to prevent memory leaks\nconst debouncedHandlers = new Map<string, ReturnType<typeof debounce>>();\n\nexport const handleRefNumberChange = (code: string, isRequired: boolean) => {\n const key = `${code}-${isRequired}`;\n\n if (!debouncedHandlers.has(key)) {\n const debouncedFn = debounce(async (refNumber: string) => {\n if (!isRequired || validateNotEmpty(refNumber)) {\n try {\n await setPaymentMethod({\n code,\n purchase_order_number: refNumber,\n });\n } catch (error) {\n console.error(`Failed to set payment method for ${code}:`, error);\n }\n }\n }, 1000);\n\n debouncedHandlers.set(key, debouncedFn);\n }\n\n return debouncedHandlers.get(key)!;\n};\n\nconst handlerCache: Partial<Record<HandlerCode, PaymentMethodConfig>> = {};\n\nexport const resetHandlersCache = () => {\n Object.keys(handlerCache).forEach((key) => {\n delete handlerCache[key as HandlerCode];\n });\n\n debouncedHandlers.clear();\n};\n\nexport const createHandler = (code: HandlerCode): PaymentMethodConfig => {\n if (!(code in HANDLERS_CONFIG)) {\n throw new Error(`Invalid handler code: ${code}`);\n }\n\n if (handlerCache[code]) {\n return handlerCache[code] as PaymentMethodConfig;\n }\n\n const config = HANDLERS_CONFIG[code];\n\n const { autoSync, Container, formName, validateRefNumber } = config;\n\n const handler: PaymentMethodConfig = {\n enabled: true,\n autoSync,\n render: (ctx) => {\n const initialReferenceNumber = String(\n ctx.additionalData?.purchase_order_number ?? ''\n );\n\n const $wrapper = document.createElement('div');\n\n Checkout.render(Container, {\n name: formName,\n initialReferenceNumber,\n onReferenceNumberChange: handleRefNumberChange(code, validateRefNumber),\n })($wrapper);\n\n ctx.replaceHTML($wrapper);\n },\n };\n\n handlerCache[code] = handler;\n\n return handler;\n};\n\nexport const defaultHandlers = {\n [HandlerCode.PaymentOnAccount]: createHandler(HandlerCode.PaymentOnAccount),\n [HandlerCode.PurchaseOrder]: createHandler(HandlerCode.PurchaseOrder),\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setPaymentMethod } from '@/checkout/api';\nimport { PaymentMethods as PaymentMethodsComponent } from '@/checkout/components/PaymentMethods/PaymentMethods';\nimport { Cart } from '@/checkout/data/models/cart';\nimport {\n AdditionalData,\n PaymentMethod\n} from '@/checkout/data/models/payment-method';\nimport { NegotiableQuote } from '@/checkout/data/models/quote';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n hasShippingAddress,\n isVirtualCart,\n notifyValues,\n state\n} from '@/checkout/lib';\nimport { TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n Container,\n deepmerge,\n Slot,\n SlotProps\n} from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport { defaultHandlers } from './handlers';\n\ninterface RenderContext {\n additionalData?: AdditionalData;\n cartId: string;\n replaceHTML: (domElement: HTMLElement) => void;\n setAdditionalData: (data: AdditionalData) => void;\n}\n\nexport interface PaymentMethodConfig {\n autoSync?: boolean;\n displayLabel?: boolean;\n enabled?: boolean;\n icon?: string;\n render?: SlotProps<RenderContext>;\n}\n\nexport interface PaymentMethodHandlers {\n [code: string]: PaymentMethodConfig;\n}\n\ninterface CartSyncError {\n method: PaymentMethod;\n error: Error;\n}\n\ntype EnabledOption = PaymentMethod & PaymentMethodConfig;\n\nexport interface PaymentMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n slots?: {\n Methods?: PaymentMethodHandlers;\n } & TitleProps['slots'];\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: PaymentMethod) => void;\n}\n\nfunction isAvailable(\n selection: PaymentMethod | null,\n options: PaymentMethod[]\n) {\n if (!selection) return false;\n return options.some((option) => option.code === selection.code);\n}\n\nfunction isEqual(a: PaymentMethod | null, b: PaymentMethod | null) {\n if (!a || !b) return false;\n return a.code === b.code;\n}\n\nfunction isValid(method: PaymentMethod | null) {\n if (!method) return false;\n return !!method.code && !!method.title;\n}\n\nexport const PaymentMethods: Container<PaymentMethodsProps> = ({\n UIComponentType = 'ToggleButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n slots,\n onCartSyncError,\n onSelectionChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [selection, setSelection] = useState<PaymentMethod | null>(null);\n const [options, setOptions] = useState<PaymentMethod[]>([]);\n const isBusy = hasPendingUpdates.value;\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.PaymentMethods.cartSyncError',\n defaultTitle: 'Checkout.PaymentMethods.title',\n });\n\n const availableHandlers = useMemo(() => {\n const customHandlers = slots?.Methods ?? {};\n return deepmerge(defaultHandlers, customHandlers);\n }, [slots?.Methods]);\n\n const enabledOptions: EnabledOption[] = useMemo(\n () =>\n options\n .filter((method) => availableHandlers?.[method.code]?.enabled !== false)\n .map((method) => {\n const slotMethod = availableHandlers?.[method.code] || {};\n\n return {\n ...method,\n ...slotMethod,\n };\n }),\n [options, availableHandlers]\n );\n\n const setAdditionalData = useCallback((additionalData: AdditionalData) => {\n setSelection((prev) => {\n if (!prev) return prev;\n return { ...prev, additionalData };\n });\n\n const currentSelection = getValue('selectedPaymentMethod');\n\n if (!currentSelection) return;\n\n notifyValues({\n selectedPaymentMethod: {\n ...currentSelection,\n additionalData,\n },\n });\n }, []);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback((selection: PaymentMethod | null) => {\n setError(null);\n setSelection(selection);\n notifyValues({ selectedPaymentMethod: selection });\n }, []);\n\n const setUserSelectionOnCart = useCallback(\n async (selection: PaymentMethod, fallback?: PaymentMethod | null) => {\n const canSetUserSelectionOnCart = isVirtualCart() || hasShippingAddress();\n if (!canSetUserSelectionOnCart) return;\n\n const methodConfig = availableHandlers?.[selection.code];\n const shouldAutoSync = methodConfig?.autoSync ?? autoSync;\n\n if (!shouldAutoSync) return;\n\n setPaymentMethod({ code: selection.code }).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [\n availableHandlers,\n autoSync,\n setUserSelection,\n onCartSyncError,\n cartSyncError,\n ]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: PaymentMethod) => {\n const prevSelection = getValue('selectedPaymentMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\n\n await setUserSelectionOnCart(selection, prevSelection);\n },\n [onSelectionChange, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n\n if (isEmptyCart) {\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const availableOptions = data.availablePaymentMethods ?? [];\n setOptions(availableOptions);\n\n if (availableOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = data.selectedPaymentMethod ?? null;\n const hasCartSelection = isValid(cartSelection);\n const userSelection = getValue('selectedPaymentMethod');\n const isUserSelectionAvailable = isAvailable(userSelection, availableOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // User has valid selection that differs from cart\n if (userSelection && isUserSelectionAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // User has invalid selection but cart has valid selection\n if (\n (!userSelection || !isUserSelectionAvailable) &&\n hasCartSelection &&\n isAvailable(cartSelection, availableOptions)\n ) {\n setUserSelection(cartSelection);\n return;\n }\n\n // Neither user nor cart has valid selection (or both selections are unavailable)\n if (\n (!userSelection || !isUserSelectionAvailable) &&\n (!hasCartSelection ||\n !isAvailable(cartSelection, availableOptions))\n ) {\n const newSelection = availableOptions[0];\n setUserSelection(newSelection);\n setUserSelectionOnCart(newSelection);\n }\n },\n [setUserSelection, setUserSelectionOnCart]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedPaymentMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data: Cart | NegotiableQuote | null) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n // When the current selection is disabled, this effect automatically selects the first available method\n useEffect(() => {\n if (enabledOptions.length === 0) return;\n\n const isEnabled = isAvailable(selection, enabledOptions);\n if (isEnabled) return;\n\n const firstAvailableOption = enabledOptions[0];\n const { code, title, additionalData } = firstAvailableOption;\n const selectedMethod = { code, title, additionalData };\n setUserSelection(selectedMethod);\n setUserSelectionOnCart(selectedMethod);\n }, [enabledOptions, selection, setUserSelection, setUserSelectionOnCart]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-payment-methods-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n const paymentMethodContent = useMemo(() => {\n const slot = enabledOptions.find((method) => isEqual(method, selection))?.render;\n if (!slot) return undefined;\n\n return (\n <Slot\n key={selection!.code}\n context={{\n additionalData: selection!.additionalData,\n cartId: state.cartId ?? '',\n replaceHTML(domElement: HTMLElement) {\n this.replaceWith(domElement);\n },\n setAdditionalData,\n }}\n name=\"PaymentMethodContent\"\n slot={slot}\n />\n );\n\n }, [enabledOptions, selection, setAdditionalData])\n\n return (\n <PaymentMethodsComponent\n UIComponentType={UIComponentType}\n busy={isBusy}\n error={error}\n initialized={isInitialized}\n options={enabledOptions}\n paymentMethodContent={paymentMethodContent}\n selection={selection}\n title={titleContent}\n visible={active}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgWallet","props","React","PaymentMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PaymentOption","UIComponentType","busy","code","icon","onSelectionChange","selected","title","commonProps","ToggleButton","Icon","RadioButton","PaymentMethodsComponent","className","error","onDismissError","options","paymentMethodContent","selection","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","classes","VComponent","IllustratedMessage","Wallet","method","InLineAlert","PaymentMethods","WithConditionals","debounce","fn","ms","timeoutId","args","HandlerCode","HANDLERS_CONFIG","PaymentOnAccount","PurchaseOrder","debouncedHandlers","handleRefNumberChange","isRequired","key","debouncedFn","refNumber","validateNotEmpty","setPaymentMethod","handlerCache","resetHandlersCache","createHandler","config","autoSync","Container","formName","validateRefNumber","handler","ctx","initialReferenceNumber","_a","$wrapper","Checkout","defaultHandlers","isAvailable","option","isEqual","a","b","isValid","active","displayTitle","slots","onCartSyncError","setError","useState","isInitialized","setIsInitialized","setSelection","setOptions","isBusy","hasPendingUpdates","cartSyncError","defaultTitle","availableHandlers","useMemo","customHandlers","deepmerge","enabledOptions","slotMethod","setAdditionalData","useCallback","additionalData","prev","currentSelection","getValue","notifyValues","handleDismissError","setUserSelection","setUserSelectionOnCart","fallback","isVirtualCart","hasShippingAddress","methodConfig","handleSelectionChange","prevSelection","handleCheckoutData","data","availableOptions","cartSelection","hasCartSelection","userSelection","isUserSelectionAvailable","haveSameSelection","newSelection","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","events","onCheckoutUpdated","firstAvailableOption","selectedMethod","titleContent","Slot","slot","state","domElement"],"mappings":"wpDACA,MAAMA,GAAaC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,gJAAiJ,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,wCAAyC,OAAQ,eAAgB,YAAa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pB,GAED,CAACZ,EAAcC,GAAA,YAAAA,EAAO,MAAOW,CAAY,CAAC,EAEvCpE,GAAuBsE,EAAQ,IAAM,OACnC,MAAAuC,GAAOhE,EAAA4B,EAAe,KAAM5D,GAAWsC,EAAQtC,EAAQZ,CAAS,CAAC,IAA1D,YAAA4C,EAA6D,OACtE,GAACgE,EAGH,OAAAhI,EAAC+H,EAAA,CAEC,QAAS,CACP,eAAgB3G,EAAW,eAC3B,OAAQ6G,GAAM,QAAU,GACxB,YAAYC,EAAyB,CACnC,KAAK,YAAYA,CAAU,CAC7B,EACA,kBAAApC,CACF,EACA,KAAK,uBACL,KAAAkC,CAAA,EAVK5G,EAAW,IAWlB,CAGD,EAAA,CAACwE,EAAgBxE,EAAW0E,CAAiB,CAAC,EAG/C,OAAA9F,EAACc,GAAA,CACC,gBAAiBX,EACjB,KAAMiF,EACN,MAAApE,EACA,YAAagE,EACb,QAASY,EACT,qBAAAzE,GACA,UAAAC,EACA,MAAO0G,GACP,QAASpD,EACT,eAAgB2B,GAChB,kBAAmBO,EAAA,CACrB,CAEJ","x_google_ignoreList":[0,3]}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{P as d,P as l}from"../chunks/PaymentOnAccount2.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/lib.js";/* empty css */import"../chunks/ConditionalWrapper.js";import"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getCompanyCredit.js";export{d as PaymentOnAccount,l as default};
3
+ import{P as d,P as l}from"../chunks/PaymentOnAccount2.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"../chunks/ConditionalWrapper.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getCompanyCredit.js";export{d as PaymentOnAccount,l as default};
4
4
  //# sourceMappingURL=PaymentOnAccount.js.map
@@ -88,7 +88,8 @@ declare const _default: {
88
88
  "button": "Try again",
89
89
  "contactSupport": "If you continue to have issues, please contact support.",
90
90
  "title": "We were unable to process your order",
91
- "unexpected": "An unexpected error occurred while processing your order. Please try again later."
91
+ "unexpected": "An unexpected error occurred while processing your order. Please try again later.",
92
+ "permissionDenied": "You do not have permission to complete checkout. Please contact your administrator for assistance."
92
93
  },
93
94
  "Quote": {
94
95
  "permissionDenied": "You do not have permission to checkout with this quote.",
@@ -21,7 +21,8 @@ export declare enum ErrorCodes {
21
21
  UNAUTHENTICATED = "UNAUTHENTICATED",
22
22
  UNKNOWN_ERROR = "UNKNOWN_ERROR",
23
23
  QUOTE_DATA_ERROR = "QUOTE_DATA_ERROR",
24
- QUOTE_PERMISSION_DENIED = "QUOTE_PERMISSION_DENIED"
24
+ QUOTE_PERMISSION_DENIED = "QUOTE_PERMISSION_DENIED",
25
+ PERMISSION_DENIED = "PERMISSION_DENIED"
25
26
  }
26
27
  export interface ErrorClassifier {
27
28
  /**
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-checkout", "version": "2.2.0-alpha3", "@dropins/tools": "^1.5.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-checkout", "version": "2.2.0-alpha4", "@dropins/tools": "1.6.0-alpha11", "license": "SEE LICENSE IN LICENSE.md"}
package/types/index.d.ts CHANGED
@@ -17,6 +17,6 @@
17
17
  export type { InitializeInput, Nullable, SynchronizeInput } from './api';
18
18
  export type { TitleProps, UIComponentType } from './components';
19
19
  export * from './guards';
20
- export type { CartModel, FormRef, Item, NegotiableQuoteModel, RenderAPI, } from './storefront';
20
+ export type { CartModel, FormRef, Item, NegotiableQuoteModel, PermissionsModel, RenderAPI, } from './storefront';
21
21
  export type { Filter, Selector } from './utils';
22
22
  //# sourceMappingURL=index.d.ts.map