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CAAA;UAC5E,YAAY,CAAC,eAA2B;UACzC,SAAS,CAAC;IAEhB,MAAM,OAAO,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,IAAG,cAAc,GAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,gBAA4B,CAAC;IAEtG,IAAI,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA;QAAE,OAAO,SAAS,CAAC;IAEvC,OAAO,OAAO,CAAC;AACjB,EAAE;AAEF;;;;;;;MAOa,uBAAuB,GAAG,CAAC,QAAmB;;IACzD,MAAM,YAAY,GAAG,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC;IAChD,OAAO,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,MAAI,MAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAqB,0CAAE,KAAK,CAAA,KAAIA,OAAS,aAATA,OAAS,uBAATA,OAAS,CAAE,KAAK,CAAA,IAAI,SAAS,CAAC;AAC7G,EAAE;AAEF;;;MAGa,eAAe,GAAG,CAAC,OAAiB;IAC/C,IAAI,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA;QAAE,OAAO,SAAS,CAAC;IAEvC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAClG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAC3E;;;;","names":["userState"],"sources":["src/store/checkout/getters.ts"],"sourcesContent":["import { Product, Address, Checkout, Customer } from 'src/types';\nimport { getCheckout } from '../checkouts/mutations';\nimport state from './store';\nimport { state as userState } from '../user';\nimport { isAddressComplete } from 'src/functions/address';\n\n/**\n * Gets the current checkout for the page.\n */\nexport const currentCheckout = () => getCheckout(state.formId, state.mode);\n\n/**\n * Is the checkout currently locked.\n * Pass an optional lock name to find if a\n * specific lock name is locking checkout.\n */\nexport const checkoutIsLocked = (lockName = ''): boolean => (lockName ? state.locks.some(name => name === lockName) : !!state.locks?.length);\n\n/**\n * Get a line item by product id.\n */\nexport const getLineItemByProductId = (productId: string) => (state.checkout?.line_items?.data || []).find(line_item => (line_item?.price?.product as Product)?.id === productId);\n\n/**\n * Is the shipping address required?\n */\nexport const fullShippingAddressRequired = () => state.checkout?.shipping_address_accuracy_requirement === 'full';\n\n/**\n * Is the address required?\n */\nexport const shippingAddressRequired = () => state.checkout?.shipping_address_accuracy_requirement === 'full' || state.checkout?.shipping_address_accuracy_requirement === 'tax';\n\n/**\n * Get a complete address by type, with Stripe-formatted field names (line1/line2).\n */\nexport const getCompleteAddress = (type: 'shipping' | 'billing' = 'shipping') => {\n const isComplete = isAddressComplete(state.checkout?.[`${type}_address`] as Address);\n if (!isComplete) return;\n\n const { line_1: line1, line_2: line2, ...otherProps } = (state.checkout?.[`${type}_address`] as Address) || {};\n\n return {\n line1,\n line2,\n ...otherProps,\n };\n};\n\n/**\n * Get the resolved billing address for payment processors.\n * Falls back to shipping address when billing matches shipping.\n * Returns canonical Address format (line_1/line_2).\n */\nexport const getResolvedBillingAddress = (checkout?: Checkout): Address | undefined => {\n const currentOrder = checkout || state.checkout;\n\n const billingAddress =\n currentOrder?.billing_matches_shipping === false && currentOrder?.billing_address\n ? (currentOrder.billing_address as Address)\n : undefined;\n\n const address = billingAddress?.line_1 ? billingAddress : (currentOrder?.shipping_address as Address);\n\n if (!address?.line_1) return undefined;\n\n return address;\n};\n\n/**\n * Resolve the billing email for payment processors.\n *\n * The Stripe Payment Element is created with `fields.billing_details.email = 'never'`,\n * so an email must always be passed on confirm. Logged-in customers never fill the email\n * input, so fall back to the linked customer and the logged-in user session.\n */\nexport const getResolvedBillingEmail = (checkout?: Checkout): string | undefined => {\n const currentOrder = checkout || state.checkout;\n return currentOrder?.email || (currentOrder?.customer as Customer)?.email || userState?.email || undefined;\n};\n\n/**\n * Convert a canonical Address to Stripe's expected format (line1/line2 instead of line_1/line_2).\n */\nexport const toStripeAddress = (address?: Address) => {\n if (!address?.line_1) return undefined;\n\n const { line_1: line1, line_2: line2, city, state: addressState, country, postal_code } = address;\n return { line1, line2, city, state: addressState, postal_code, country };\n};\n"],"version":3}