import React, { FC, PropsWithChildren } from "react"; //#region src/extensions/gift-card/providers/gift-card-context-provider/validate-buyer-selections.d.ts type RecipientPhoneError = 'empty' | 'invalid'; //#endregion //#region ../../node_modules/type-fest/source/observable-like.d.ts declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged. interface SymbolConstructor { readonly observable: symbol; } } /** @remarks The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021. As well, some guidance on making an `Observable` to not include `closed` property. @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130 @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85 @see https://github.com/benlesh/symbol-observable#making-an-object-observable @category Observable */ //#endregion //#region ../../node_modules/@wix/sdk-types/internal/build/index.d.ts declare global { interface ContextualClient {} } /** * Creates concrete types from SDK descriptors when a contextual client is * available. * * For a REST descriptor the built (bound) API is intersected with the original * descriptor, matching what `contextualizeRESTModuleV2` returns at runtime — a * value callable as the bound API and still usable as a descriptor. Keeping the * descriptor half lets contextual modules be passed to descriptor-constrained * helpers such as `elevate` from `@wix/sdk/context` (FEDINF-14092). * * The `& T` is scoped to REST descriptors — the only shape codegen wraps in * `MaybeContext` — so `BuildDescriptors` (used by `createClient().use`) is left * unchanged and stays bound-only. The fix lives here rather than in `elevate`, * which is kept strict on purpose (see #941) so it still rejects bound-only * functions that are unsafe through `createRESTModule`. */ declare global { /** * A global interface to set the exposure toggle for the SDK. * @example * ```ts * declare global { * interface SDKExposureToggle { * alpha: true; * } * } */ interface SDKExposureToggle {} } declare global { /** * A global interface to set the type mode for the SDK. * @example * ```ts * declare global { * interface SDKTypeMode { * strict: true; * } * } */ interface SDKTypeMode {} } //#endregion //#region ../../node_modules/@wix/auto_sdk_gift-vouchers_gift-voucher-products/build/es/index.typings.d.mts /** * A gift card product is a template that defines what a purchasable gift card looks like, including * its name, description, image, available denominations, and expiration policy. * When a customer buys a gift card, an individual gift card instance is created * based on the product's configuration. */ interface GiftCardProduct$1 extends GiftCardProductExpirationDateOneOf { /** Fixed expiration date for all gift cards created from this product. */ fixedExpirationDate?: Date | null; /** Expiration period relative to the date of purchase. */ relativeExpirationDate?: RelativeExpirationDate; /** * Gift card product ID. * @format GUID * @readonly */ _id?: string | null; /** * Revision number, which increments by 1 each time the gift card product is updated. * To prevent conflicting changes, * the current revision must be passed when updating the gift card product. * * Ignored when creating a gift card product. * @readonly */ revision?: string | null; /** * Date and time the gift card product was created. * @readonly */ _createdDate?: Date | null; /** * Date and time the gift card product was last updated. * @readonly */ _updatedDate?: Date | null; /** * Gift card product name. * @maxLength 55 */ name?: string; /** * Gift card product description. * @maxLength 3000 */ description?: string | null; /** * Gift card product image. Only images from the Wix Media Manager are supported. To use an external image, first upload it to the Wix Media Manager. * * When setting the image, you must provide at least `id`, `width`, and `height`. * The `id` is the file name from the image URL. For example, for `https://static.wixstatic.com/media/5cc69183e7954e2c9760fa2383870992.jpg`, the `id` is `5cc69183e7954e2c9760fa2383870992.jpg`. */ image?: string; /** Expiration type for gift cards created from this product. */ expirationType?: ExpirationTypeWithLiterals; /** * List of preset variants with predefined denominations that buyers can choose from. A product can have both preset variants and a custom variant. * * When updating, the entire list is replaced. There's no way to update an individual preset variant. * @maxSize 200 */ presetVariants?: PresetVariant[]; /** Custom variant that allows buyers to choose their own gift card amount within a defined range. A product can have both preset variants and a custom variant. */ customVariant?: CustomVariant; /** * Custom field data for the gift card product object. * * [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions) must be configured in the app dashboard before they can be accessed with API calls. */ extendedFields?: ExtendedFields; } /** @oneof */ interface GiftCardProductExpirationDateOneOf { /** Fixed expiration date for all gift cards created from this product. */ fixedExpirationDate?: Date | null; /** Expiration period relative to the date of purchase. */ relativeExpirationDate?: RelativeExpirationDate; } declare enum ExpirationType { /** Gift cards created from this product don't expire. */ NONE = "NONE", /** Gift cards expire on a specific date. */ FIXED = "FIXED", /** Gift cards expire after a set period from the date of purchase. */ RELATIVE = "RELATIVE" } /** @enumType */ type ExpirationTypeWithLiterals = ExpirationType | 'NONE' | 'FIXED' | 'RELATIVE'; interface RelativeExpirationDate { /** * Number of time periods until expiration. For example, a `value` of `6` with a `period` of `MONTHS` means the gift card expires 6 months after purchase. * @min 1 */ value?: number; /** Unit of time for the expiration period. */ period?: TimePeriodWithLiterals; } declare enum TimePeriod { DAYS = "DAYS", WEEKS = "WEEKS", MONTHS = "MONTHS", YEARS = "YEARS" } /** @enumType */ type TimePeriodWithLiterals = TimePeriod | 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; interface PresetVariant { /** * Preset variant ID. * @format GUID * @readonly */ _id?: string | null; /** Price the buyer pays for the gift card. The currency is the site's default currency. */ price?: MultiCurrencyPrice; /** Balance loaded onto the gift card. Can differ from `price` to support promotional pricing. For example, a gift card with a `value` of $50 could have a `price` of $45. */ value?: MultiCurrencyPrice; /** * Variant-level image that overrides the product-level image. Only images from the Wix Media Manager are supported. To use an external image, first upload it to the Wix Media Manager. * * When setting the image, you must provide at least `id`, `width`, and `height`. * The `id` is the file name from the image URL. For example, for `https://static.wixstatic.com/media/5cc69183e7954e2c9760fa2383870992.jpg`, the `id` is `5cc69183e7954e2c9760fa2383870992.jpg`. */ image?: string; } interface MultiCurrencyPrice { /** * Amount. * @decimalValue options { gte:0, lte:1000000000000000 } */ amount?: string; /** * Converted amount. * @readonly * @decimalValue options { gte:0, lte:1000000000000000 } */ convertedAmount?: string; /** * Amount formatted with currency symbol. * @readonly */ formattedAmount?: string; /** * Converted amount formatted with currency symbol. * @readonly */ formattedConvertedAmount?: string; } interface CustomVariant { /** Minimum gift card amount a buyer can choose. The currency is the site's default currency. */ minValue?: MultiCurrencyPrice; /** Maximum gift card amount a buyer can choose. The currency is the site's default currency. */ maxValue?: MultiCurrencyPrice; /** * Variant-level image that overrides the product-level image. Only images from the Wix Media Manager are supported. To use an external image, first upload it to the Wix Media Manager. * * When setting the image, you must provide at least `id`, `width`, and `height`. * The `id` is the file name from the image URL. For example, for `https://static.wixstatic.com/media/5cc69183e7954e2c9760fa2383870992.jpg`, the `id` is `5cc69183e7954e2c9760fa2383870992.jpg`. */ image?: string; } interface ExtendedFields { /** * Extended field data. Each key corresponds to the namespace of the app that created the extended fields. * The value of each key is structured according to the schema defined when the extended fields were configured. * * You can only access fields for which you have the appropriate permissions. * * Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields). */ namespaces?: Record>; } //#endregion //#region ../../node_modules/@wix/editor-react-types/dist/image.d.ts type Point = { x: number; y: number; }; type Crop = Point & { width: number; height: number; }; /** * An image from Wix Media. * * @example * ```tsx * import type { Image } from '@wix/editor-react-types'; * * interface MyComponentProps { * image?: Image; * } * * const MyComponent = ({ image }: MyComponentProps) => ( * {image?.alt} * ); * ``` */ type Image = { /** The image URI. */uri?: string; /** The image URL. */ url: string; /** The image file name. */ name?: string; /** The image height in pixels. */ height?: number; /** The image width in pixels. */ width?: number; /** Whether the image is animated (e.g. GIF). */ animated?: boolean; /** The crop region applied to the image. */ crop?: Crop; /** The image quality, as a percentage from 0 to 100. */ quality?: number; /** The image alt text for accessibility. */ alt?: string; }; //#endregion //#region ../../node_modules/@wix/editor-react-types/dist/base.d.ts /** * A local date string in ISO-8601 extended format (`YYYY-MM-DD`). * * @example * ```tsx * import type { LocalDate } from '@wix/editor-react-types'; * * interface MyComponentProps { * startDate?: LocalDate; // e.g. '2024-03-15' * } * ``` */ type LocalDate = string; //#endregion //#region src/extensions/gift-card/providers/api/gift-card-product.d.ts type SdkGiftCardProduct = GiftCardProduct$1; type SdkRelativeExpirationDate = NonNullable; interface Price { amount: number; formattedAmount: string; } interface GiftCardPresetVariant { id: string; price: Price; value?: Price; } interface GiftCardCustomVariant { minValue?: Price; maxValue?: Price; } type GiftCardExpirationType = NonNullable; interface GiftCardRelativeExpirationDate { value: number; period: NonNullable; } interface GiftCardProduct { id: string; name: string; description: string; image?: Image; presetVariants: GiftCardPresetVariant[]; customVariant?: GiftCardCustomVariant; expirationType: GiftCardExpirationType; fixedExpirationDate?: LocalDate; relativeExpirationDate?: GiftCardRelativeExpirationDate; } //#endregion //#region src/extensions/gift-card/providers/gift-card-context-provider/gift-card-context-provider.constants.d.ts declare enum CartActionState { IDLE = "idle", IN_PROGRESS = "in-progress" } declare enum PostAddToCartAction { NONE = "none", NAVIGATE_TO_CART = "navigate-to-cart", OPEN_SIDE_CART = "open-side-cart" } declare enum BuyNowState { IDLE = "idle", IN_PROGRESS = "in-progress" } //#endregion //#region src/extensions/gift-card/providers/gift-card-context-provider/gift-card-context-provider.d.ts declare const useGiftCardContextValue: () => { giftCard: GiftCardProduct; buyerSelections: { presetVariantId: string; customAmount: { amount: number; formattedAmount: string; } | undefined; quantity: number; recipientEmail: string; recipientName: string; greetingMessage: string; deliverAt: string | undefined; isGift: boolean; isWhatsAppSelected: boolean; isSmsSelected: boolean; recipientPhone: string; }; addToCartState: CartActionState; buyNowState: BuyNowState; selectionValidationErrors: { recipientEmail: "invalid" | undefined; recipientPhone: RecipientPhoneError | undefined; }; hasAttemptedPurchase: boolean; actions: { addToCart: (postAction?: PostAddToCartAction) => Promise; buyNow: () => Promise; selectPresetVariant: React.Dispatch>; updateCustomAmount: React.Dispatch>; updateQuantity: React.Dispatch>; updateRecipientEmail: React.Dispatch>; updateRecipientName: React.Dispatch>; updateGreetingMessage: React.Dispatch>; updateDeliverAt: React.Dispatch>; updateIsGift: React.Dispatch>; updateIsWhatsAppSelected: React.Dispatch>; updateIsSmsSelected: React.Dispatch>; updateRecipientPhone: React.Dispatch>; }; } | undefined; /** The gift card product, the buyer's selections, and the actions that update them. */ type GiftCardContextValue = NonNullable>; /** Reads the gift card context supplied by a surrounding gift card context provider. */ declare const useGiftCardContext: () => GiftCardContextValue; /** Props accepted by {@link GiftCardContextProvider}. */ type GiftCardContextProviderProps = PropsWithChildren; /** Loads the site's gift card product and supplies it, with the buyer's selections and update actions, to descendant components. */ declare const GiftCardContextProvider: FC; //#endregion export { GiftCardContextProviderProps, GiftCardContextValue, GiftCardContextProvider as default, useGiftCardContext };