import { KMCRootObject } from "@klevu/core"; import { EventEmitter } from "../../stencil-public-runtime"; import { KlevuUIGlobalSettings } from "../../utils/utils"; import en from "../../translations/en.json"; /** * List of available translations */ export type Translations = "en" | "fi"; /** * Translation typing to auto complete */ export type Translation = typeof en; /** * * `klevu-init` is the most important component of the whole library. Place one in your document. It should be * one of the first ones in the `` tag. Currently only one `klevu-init` per page is supported. It is used to define * configuration for all components on the page and provide few global settings for all components: * * - **onItemClick:** what happens when product is clicked. Typically this places default action of * _klevu-product_ click. For example you can make your own frontend router to act in this function. Is * provided with product and click event as attributes. Remember to preventDefault and return false to prevent anchor * link following. * - **generateProductUrl:** what kind of URL's should be generated for products. If _onItemClick_ * is not used this can be used for it. Has product as attribute. * - **renderPrice:** generic function for price rendering. If you wish to have your own formatting for price * rendering then this is the place. Has two attribute amount and currency of item. * Initializes components to fetch data from correct Klevu backend * * * **Note: All global CSS variables are documented in `klevu-init` even thought they are not defined in it.** * */ export declare class KlevuInit { #private; /** * Read only API key to Klevu */ apiKey: string; /** * Klevu Server URL */ url: string; /** * Override the default events v1 URL */ eventsV1Url?: string; /** * Override the default events v2 URL */ eventsV2Url?: string; /** * Override the default recommendations API URL */ recommendationsApiUrl?: string; /** * Override the default session API URL */ visitorServiceUrl?: string; /** * Ipv6 ServiceUrl for ipv6 retrieval used in analytics */ ipv6ServiceUrl?: string; /** * Ipv4 ServiceUrl for ipv4 retrieval used in analytics */ ipv4ServiceUrl?: string; /** * Override the default moi API URL */ moiApiUrl?: string; /** * Global settings */ settings: KlevuUIGlobalSettings; /** * Which language to load */ language: Translations; /** * Provide your own translations */ translation?: Translation; /** * Enable Klaviyo integration */ enableKlaviyoConnector?: boolean; /** * Enable Data Protection */ useConsent?: boolean; /** * Data read consent given */ consentGiven?: boolean; /** * Override the default assets path. Will use format of `${assetsPath}/assets/${resource}` */ assetsPath?: string; settingsUrl?: string; /** * Override the default translation URL prefix. Will use format of * `${translationUrlPrefix}/translations/${lang}.json` */ translationUrlPrefix?: string; kmcLoadDefaults?: boolean; /** * disableUserSession and stop making calls to visitor service when this is true, defaults to false. */ disableUserSession?: boolean; klevuInitSettingsUpdated: EventEmitter; settingsChanged(newValue: KlevuUIGlobalSettings, oldValue: KlevuUIGlobalSettings): Promise; connectedCallback(): Promise; /** * * @returns KlevuConfig, but due to typescript problems it is any */ getConfig(): Promise; /** * Get settings defined in klevu-init * * @returns */ getSettings(): Promise; /** * Get settings defined in klevu-init * * @returns */ isSettingsDefined(): Promise; getAssetsPath(): Promise; setConsentGiven(val: boolean): Promise; setUseConsent(val: boolean): Promise; /** * To make sure that components in the page wait for klevu-init to run and set the settings this method is required to use. * In `connectedCallback()` function should call this method. So for example: * * ``` * async connectedCallback() { * await KlevuInit.ready() * } * ``` * * @returns Promise when klevu-init is loaded */ static ready(): Promise; render(): any; } declare global { interface Window { klevu_ui_translations?: typeof en; klevu_page_meta?: { pageType?: string; itemName?: string; itemUrl?: string; itemId?: string; itemGroupId?: string; itemSalePrice?: string; itemCurrency?: string; }; klevu_ui_kmc_settings?: KMCRootObject; } }