// Generated by dts-bundle-generator v6.13.0 export interface IMerchantDetails { id: string; name: string; } declare enum MerchantPriceFormatEnum { MINOR = "MINOR", MAJOR = "MAJOR" } export interface IBlackCartProduct { id: string | number; sampleProduct?: any; tags?: string[]; } export interface IConfigImplementation { merchantDetails?: IMerchantDetails; checkoutUrl?: string; apiUrl?: string; autoOptIn: boolean; useCustomPricing?: boolean; priceFormat: MerchantPriceFormatEnum; currency?: string; isActive?: boolean; isPreviewMode?: boolean; previewURL?: string; isDefaultTBYB?: boolean | TBYBToggleOptionsEnum; tbybTogglePriceCaptioning?: TBYBTogglePriceCaptioningOption; samplesEnabled?: boolean; restockingFeePolicy?: RestockingFeePolicy; restockingFeeCondition?: RestockingFeeCondition; isExchangesEnabled?: boolean; onlyUseBlackcartApi?: boolean; } export interface IConfigRules { minAmount?: number; maxAmount?: number; minCount?: number; maxCount?: number; deposit?: number; restockingFee?: number; tryDays?: number; maxCountPerItem?: number; carrier?: string; } export interface IBlackCartConfig { rules: IConfigRules; implementation: IConfigImplementation; overrides?: IBlackCartOverrides; moneyFormatter?: (value: number) => string; meta?: { [key: string]: any; }; } export interface IBlackCartExtensible { fetchCart?(): Promise; fetchProducts?(): Promise; isProductEligible?(product: TProduct, autoOptIn?: boolean): boolean; isVariantEligible?(product: TProduct, variantId: string, autoOptIn?: boolean): boolean; onVariantsChange?(handler: (value: IVariantEntity[]) => void): void; onProductsChange?(handler: (products: TProduct[]) => void): void; getCustomPricing?(cart: TCart): Promise; exitPreview?(): void; } export interface IBlackCartOverrides extends Omit, "exitPreview" | "onVariantsChange" | "onProductsChange"> { } export interface IFeatureCheck { name: string; check: () => boolean; } export interface IVariantEntity { variant: ISelectedVariant; productId: string; } export interface IUrlQueryParam { [key: string]: string; } export interface ISelectedVariant { id: string; name?: string; price: number; compare_at_price?: number; formattedPrice?: string; } export interface IUTMParams { utm_source?: string; utm_medium?: string; utm_campaign?: string; utm_term?: string; utm_content?: string; } declare enum TBYBToggleOptionsEnum { TBYB = "tbyb", PAY_TODAY = "pay_today" } declare enum TBYBTogglePriceCaptioningOption { DISABLED = "disabled", ENABLED = "enabled" } declare enum RestockingFeePolicy { NO_RESTOCKING_FEE = "no_restocking_fee", ORDER_FLAT_FEE = "order_flat_fee" } declare enum RestockingFeeCondition { ALL_TBYB_RETURNED = "all_tbyb_returned", ALL_ITEMS_RETURNED = "all_items_returned", ANY_TBYB_RETURNED = "any_tbyb_returned", ANY_ITEM_RETURNED = "any_item_returned" } export declare enum CartRuleViolations { EXCEEDED_MAX_QUANTITY = "EXCEEDED_MAX_QUANTITY", EXCEEDED_MAX_PRICE = "EXCEEDED_MAX_PRICE", INSUFFICIENT_MIN_QUANTITY = "INSUFFICIENT_MIN_QUANTITY", INSUFFICIENT_MIN_PRICE = "INSUFFICIENT_MIN_PRICE", EMPTY_CART = "EMPTY_CART", HAS_SUBSCRIPTIONS = "HAS_SUBSCRIPTIONS" } export declare enum WEIGHT_UNIT { GRAM = "gram" } export interface IValidatorCartItem { productId: string; name: string; variantId?: string; quantity: number; price: number; originalPrice: number; linePrice?: number; isTBYB: boolean; url: string; weight?: number; weightUnit?: WEIGHT_UNIT; image: string; options?: { style?: string; size?: string; [key: string]: string; }; properties?: { [key: string]: string; }; formattedPrices?: { lineTotal: string; linePrice: string; }; sellingPlanAllocation?: any[]; } export interface IValidatorCart { items: IValidatorCartItem[]; currency: string; discountCode?: string | null; noteAttributes?: { [key: string]: string; }; totalPrice?: number; } export interface IValidatedCartInfo { deposit?: string; isQualified: boolean; maxCountPerItem: number; warning: IViolationMessage | null; payTodayTotal: string; } export interface IViolationMessage { type: CartRuleViolations; message: string; details?: string; } declare class CartValidator { private _cart; private rules; private readonly maxCountPerItem; readonly moneyFormatter: (_: number) => string; ruleViolations: CartRuleViolations[]; constructor(rules: IConfigRules, moneyFormatter: (value: number) => string); get cart(): IValidatorCart; set cart(newCart: IValidatorCart); private getLineItemTotal; get totalItemCount(): number; get isQualified(): boolean; get blackcartItems(): IValidatorCartItem[]; get blackCartItemCount(): number; get sampleItemCount(): number; get blackcartTotal(): number; private hasSubscriptions; get sampleTotal(): number; private get payTodayTotal(); private getRuleViolations; private getWarningFragment; private get deposit(); get validatedCartInfo(): IValidatedCartInfo; canAddTbybItemToCart(productId: string, variantId?: string): boolean; canAddSampleItemToCart(tags: string[]): boolean; isTBYBItem(variantId: any): boolean; private isItemLessThanMaxCountPerItem; private cartChangeNotifier; onCartChange: (handler: (cart: IValidatorCart) => void) => void; } export interface ICartUpdateRequestBody { currency: string; cartData: ICartData; } export interface ICartCreateRequestBody extends ICartUpdateRequestBody { storeId: string; } export interface ICartData { products: IApiProduct[]; test?: string; discountCode?: string | null; noteAttributes?: { name: string; value: string; }[]; } export interface IApiProduct { id: string; variantId?: string; quantity: number; tbyb: boolean; price: number; name: string; originalPrice?: number; thumbnail?: string; url?: string; weight?: number; weight_unit?: WEIGHT_UNIT; options?: IApiProductOptions; properties?: IApiProductProperties; discountPrice?: number; } export interface IApiProductOptions { [key: string]: string; } export interface IApiProductProperties { [key: string]: string; } export interface IApiCart extends ICartUpdateRequestBody { id: string; createdAt: string; storeId?: number; sourceId?: number; customerId?: number; orderId?: string; shippingSourceId?: number; shippingName?: string; storesDiscountsId?: number; sequenceNumber?: number; updatedAt?: Date; deletedAt?: Date; shippingAddress?: string; shippingMethods?: string; taxes?: any; } declare class BlackCartAPIClient { protected storeId: string; protected baseUrl: string; protected mockApiMode: boolean; protected csrfEnabled: boolean; private initPromise; private csrfTokenFetched; get isInitialized(): boolean; get onInitialized(): Promise; constructor(storeId: string, baseUrl: string, mockApiMode?: boolean, csrfEnabled?: boolean); init(): Promise; getCart(cartId: string): Promise; createCart(cart: IValidatorCart): Promise; updateCart(cartId: string, cart: IValidatorCart): Promise; protected fetchCsrfToken(): Promise; protected buildUrl(path: string): string; protected serializeCreateCart(cart: IValidatorCart): ICartCreateRequestBody; protected serializeUpdateCart(cart: IValidatorCart): ICartUpdateRequestBody; protected serializeNoteAttributes(noteAttributes?: IValidatorCart["noteAttributes"]): ICartData["noteAttributes"]; } export interface IQueuedCartUpdate { cart: IValidatorCart; resolve: (value: IApiCart) => void; reject: (reason: Error) => void; isValid: boolean; isFinalUpdate: boolean; } declare abstract class BlackCartCartSynchronizer { abstract initCart(): Promise; protected apiClient: BlackCartAPIClient; protected cartUpdateQueue: IQueuedCartUpdate[]; protected _cartId: string | null; private createCartPromise?; initPromise?: Promise; get isCreatingCart(): boolean; get isInitialized(): Promise; get cartId(): string; constructor(apiClient: BlackCartAPIClient); synchronizeCart(cart: IValidatorCart, isValid: boolean, isFinalUpdate?: boolean): Promise; resetCart: () => void; protected createOrUpdateCart(cart: IValidatorCart, isValid: boolean, isFinalUpdate: boolean): Promise; protected queueCartUpdate(cart: IValidatorCart, isValid: boolean, isFinalUpdate: boolean): Promise; protected processCartUpdateQueue(): Promise; protected createCart(cart: IValidatorCart): Promise; protected updateCart(cart: IValidatorCart, isFinalUpdate: boolean): Promise; } export interface LocalStorage { getValue(): T | null; setValue(value: T): void; } declare class UTMManager { static UTM_PARAM_LOCAL_STORAGE_KEY: string; protected storage: LocalStorage; constructor(); init(queryString: URLSearchParams): void; protected parse(params: URLSearchParams): IUTMParams | null; getStoredParams(): IUTMParams; } declare abstract class BlackCart { protected config: IBlackCartConfig; protected apiClient: BlackCartAPIClient; protected cartSynchronizer: BlackCartCartSynchronizer; protected utmManager: UTMManager; protected abstract fetchCart(): Promise; protected abstract isProductEligible(product: TProduct, autoOptIn: boolean): boolean; protected abstract isVariantEligible(product: TProduct, variantId: string, autoOptIn: boolean): boolean; protected abstract initializeCartSynchronizer(): void; protected abstract validator: CartValidator; protected constructor(config: IBlackCartConfig); protected init(): void; protected redirectToCheckout: (cart: IValidatorCart, isValid: boolean, customQueryParams?: IUrlQueryParam) => Promise; /** * url query params passed to checkout * can include ga or event discount codes as custom params * * @returns - should return a valid url query param if either GA or custom param exists. otherwise, should just return an empty string. So the result won't interfer with checkout url */ protected generateCheckoutQueryParams: (customParams: IUrlQueryParam) => string; protected getGAParams: () => IUrlQueryParam; protected onCartUpdate(): Promise; protected initializeApiClient(): Promise; protected earlyAbortIfNewVersionRequested(): void; protected bootstrapNewSDKVersion: (version: string) => void; protected earlyAbortIfUnsupported(): void; protected getUnsupportedFeatures(): string[]; protected getRequiredFeatureChecks(): IFeatureCheck[]; protected initGoogleTagManager(): void; /** Populate the data layer with merchant-specific properties * so GTM can read them */ private initDataLayer; protected initUTMParams(): void; protected destroy(): void; /** @description * Sets preview mode flag to the config if preview JWT or cookie is detected * */ protected initPreviewMode(): void; exitPreviewMode: () => void; } export declare class CartSynchronizer extends BlackCartCartSynchronizer { private readonly clearCart; constructor(apiClient: BlackCartAPIClient, clearCart: () => void); initCart: () => Promise; protected verifyCart: () => Promise; } export declare class BlackcartError extends Error { status: string; constructor(status: string, message?: string); } export declare class FetchConfigError extends BlackcartError { constructor(message?: string); } export declare class UnsupportedCurrencyError extends BlackcartError { constructor(message?: string); } export declare class ActivationError extends BlackcartError { constructor(message?: string); } export declare enum ErrorCodes { CONFIG_ERROR = "BC-001", CURRENCY_ERROR = "BC-002", ACTIVE_ERROR = "BC-003" } export declare const BC_CODE_ERROR_MAPPING: Readonly<{ "BC-001": typeof FetchConfigError; "BC-002": typeof UnsupportedCurrencyError; "BC-003": typeof ActivationError; }>; export declare const isDefinedErrCode: (status?: string) => status is ErrorCodes; export interface IMoneyData { amount: number; formatted: string; } export declare enum SIZE { SMALL = "small", REGULAR = "regular", LARGE = "large" } export declare enum STYLE { SOLID = "solid", OUTLINED = "outlined" } export declare enum WIDTH { FULL = "full", AUTO = "auto" } declare enum ButtonType { PRIMARY = "PRIMARY", SECONDARY = "SECONDARY" } declare enum ModalFeatureType { SHOP = 0, TRY = 1, LIKE = 2, RETURN = 3 } export declare enum VARIANT { ROUND = "round", SQUARE = "square", REGULAR = "regular" } /** * RGB object type with red, green and blue components. */ export declare type RGB = { r: number; g: number; b: number; a?: number; }; export declare type RGBArray = [ number, number, number ]; export declare type RGBAArray = [ number, number, number, number ]; export declare type RgbArray = RGBArray | RGBAArray; export declare type HexColor = string; export declare type Color = RGB | RgbArray | HexColor; export interface BlackWhite { black: HexColor; white: HexColor; threshold?: number; } export declare class ColorUtils { private static DEFAULT_BW; private static padz; private static toRGB; private static getLuminance; /** * Generates inverted (opposite) version of the given color. * @param {Color} color - Color to be inverted. * @param {BlackWhite|boolean} [bw=false] - Whether to amplify the inversion to * black or white. Provide an object to customize black/white colors. * @param {number} [contrast = 1/20] - used for BW inversion and specifies the contrast ratio; * @returns {HexColor} - Hexadecimal representation of the inverted color. */ static invert(color: Color, bw?: BlackWhite | boolean, contrast?: number): HexColor; static hexToRgbArray(hex: string): RgbArray; private static toRgbArray; private static invertToBW; static asRgbArray(color: Color, bw?: BlackWhite | boolean, contrast?: number): RgbArray; private static rgbStringToHex; static getInheritedBackgroundColor: (el: any) => any; private static getDefaultBackground; } export interface IElementTarget { targetSelector: string; } export interface IElementInsert extends IElementTarget { className?: string; container?: string; insertPosition: InsertPositionEnum; text?: string; } export interface IWarningInsert extends IElementTarget { className?: string; insertPosition: InsertPositionEnum; title?: string; width?: WIDTH; marginVertical?: number; marginHorizontal?: number; color?: string; buttonStyle?: STYLE; } /** * @property {STYLE} style - Tag style (e.g Outlined) * @property {SIZE} size - Tag size (e.g Small) * @property {boolean} withIcon - If true, displays the icon * @property {string} color - Default is `theme.colors.primary` */ export interface ITagElementInsert { className?: string; targetSelector?: string; insertPosition?: InsertPositionEnum; style?: STYLE; size?: SIZE; withIcon?: boolean; color?: string; } export declare type ILinePriceElementInsert = Omit; export interface ICartLineItem extends IElementTarget { tbybTag: ITagElementInsert; linePrice?: ILinePriceElementInsert; lineTotal?: ILinePriceElementInsert; quantityControlsSelector?: string; } export interface ICartAmount extends IElementTarget { text: string; price: string; } /** * @property {ICartLineItem} lineItem – Nested object containing all line-item elements to insert/replace * @property {IElementInsert} checkoutBtn – An optional object detailing where the checkout button is located. Some themes do not redirect to the checkout page from the miniCart * @property {ICartAmount} payNow – An object detailing where the cart 'pay now' line should be displayed, as well as where the text and price can be found * @property {IElementInsert} warningBanner – An object detailing where the cart validation warning banner should be inserted */ export interface ICartBaseConfig { lineItem: ICartLineItem; payNow: ICartAmount; warningBanner: IWarningInsert; checkoutBtn?: IElementInsert; hiddenElements?: string[]; } /** * @property {string} pathname – An optional string representing window.location.pathname in which to look for the cart. A platform specific default will be used if omitted */ export interface ICartPageConfig extends ICartBaseConfig { pathname?: string; } /** * @property {string} targetSelector – selector for merchant CTA (button/input element that triggers Add to Cart event) * @property {string} insertPosition – insert position enum value that represents position of an injected BlackCart CTA * @property {string} container – if insertPosition === 'CONTAINER', required selector for a container where BlackCart CTA will be rendered * @property {PositionEnum} dividerPosition – configurable position for divider element * @property {string} color – HEX color for TBYB button. */ export interface ITbybBtnConfig extends IAppButton { container?: string; insertPosition: InsertPositionEnum; targetSelector: string; dividerPosition?: PositionEnum; color?: string; } export interface IInfoConfig { classNames?: string; verticalMargin?: number; fontSize?: number; } export interface IProductPageConfig { tbybBtn: ITbybBtnConfig; info?: IInfoConfig; hiddenElements?: string[]; } declare enum InsertPositionEnum { BEFORE = "BEFORE", AFTER = "AFTER", CONTAINER = "CONTAINER", FIRST_IN_CONTAINER = "FIRST_IN_CONTAINER" } declare enum PositionEnum { TOP = "TOP", BOTTOM = "BOTTOM", LEFT = "LEFT", RIGHT = "RIGHT" } export interface IThemeConfig { brandColors?: IConfigBrandColors; variant?: VARIANT; contrast?: number; } export interface IConfigElements { globalCss?: string; theme?: IThemeConfig; productDetailPage?: IProductPageConfig; cartPage?: ICartPageConfig; minicart?: ICartBaseConfig; learnMoreModal?: ILearnMoreModalConfig; } export interface IBlackCartDOMConfig extends IBlackCartConfig { elements: IConfigElements; } export interface IAppButton { text: string; sampleText?: string; className?: string; style?: STYLE; width?: WIDTH; disabled?: boolean; type?: ButtonType; color?: string; } export interface IConfigBrandColors { primary?: string; secondary?: string; } export interface ILearnMoreModalConfig { className?: string; container?: string; title?: string; learnMoreLinkUrl?: string; learnMoreLinkText?: string; tryBeforeYouBuyText?: string; features?: IModalFeature[]; color?: string; } /** * @property {ModalFeatureType} type – A required enum that represents TRY | SHOP | LIKE | RETURN features * @property {string} title – title of a modal feature * @property {string} caption – brief description of a modal feature * @property {string} imageURL – An optional URL to an image that. If not provided the default icons will be displayed * @remarks * `title` and `caption` fields support strings that can be interpolated * - Support of values from configurable rules: * Provide a specific tag that represents a property from a 'rule' * configuration section in curly braces (i.e., `Your text {minCount}`) * and the text will be rendered with a value of minCount on LearnMore modal * - Support of countable nouns: * Provide {s:tag} in your string whenever you want to add s to * a countable noun depending on your 'tag' value. * (i.e., `Your text {minCount} item{s:minCount}` will add 's' after 'item' * if minCount is greater than 1) */ export interface IModalFeature { type: ModalFeatureType; title: string; caption?: string; imageURL?: string; } /** * BaseBlackcart * @class * @property {string} shopDomain - store shopify domain that is registered in * Blackcart system during onboarding process (e.g. my-store.myshopify.com) * @property {IValidatorCart} cart - current state of a user cart * @property {function} clearCart - callback function that will be called in case the current cart * has a completed order on it. The check for an order completion state will be made during the * service initialization. it is useful for us to check the currently saved cart on a storefront * because of the redirect we do when a user completes Blackcart checkout process. * @property {string} selectedCurrency - Currently selected currency on storefront in ISO format (e.g. USD) * @property {boolean} isProduction - default to true. If set to false the library can initialize even if * you have not set Blackcart program to Live mode via Merchant Portal * @property {boolean} useModal - default to false. Indicates if a Javascript modal * will be used on a storefront. Initiates a modal component in the constructor method. * @property {ILearnMoreModalConfig} modalConfig - if useModal set to true, the configuration for * Javascript modal can be provided. If not, the default one will be used. * @property {(value: number) => string} moneyFormatter - default to international money formatting. Can be provided * a custom function. All prices that are rendered by Blackcart will be formatted with these rules; * @classdesc BaseBlackcart class inherits Blackart Core and provides * generic methods for cart synchronization and validation. * This class helps to integrate Blackcart to any storefront. */ export declare class BaseBlackcart extends BlackCart { onInit: Promise; protected validator: CartValidator; protected config: IBlackCartDOMConfig; private initResolve; private readonly providedMoneyFormatter; private readonly clearCart; private readonly selectedCurrency; private readonly isProduction; private readonly modal; private readonly previewBar; private static instance; static getInstance: (shopDomain: string, cart: IValidatorCart, clearCart: () => void, selectedCurrency: string, isProduction?: boolean, useModal?: boolean, modalConfig?: ILearnMoreModalConfig, moneyFormatter?: (value: number) => string) => Promise; private constructor(); protected fetchCart(): Promise; protected fetchProduct(): Promise; protected isProductEligible(_product: any, _autoOptIn: boolean): boolean; protected isVariantEligible(_product: any, _variantId: string, _autoOptIn: boolean): boolean; protected initializeCartSynchronizer(): Promise; private initCartValidator; private moneyFormatter; private handleClearCart; private handleExitPreview; get settings(): IBlackCartDOMConfig; setCart(cart: IValidatorCart): Promise; isTBYBItem: (variantId: string) => boolean; get isTBYBQualifiedCart(): boolean; goToBlackcartCheckout: () => void; /** * Method that displays JS Blackcart info modal. * @param eventTrigger {EventTarget?}: if provided, the focus will be returned * to the element that is provided * */ showBlackcartModal: (eventTrigger?: EventTarget) => void; get validatedCart(): IValidatorCart | null; get cartInfo(): IValidatedCartInfo | null; get payTodayTotal(): IMoneyData | null; get deposit(): IMoneyData | null; } export {};