import SdkSettings from '../settings'; import { Logger } from '../utils/logger'; import { Context } from '../api'; import { PerProductConfig } from './perProductConfig'; /** @internal */ export declare const attachIframeContextListener: (context: Context) => void; /** @internal */ export interface EnhancedContentApiOptions { beforeRender?: (productId: string, idType?: string) => void; afterRender?: (productId: string, idType?: string) => void; } /** @internal */ export interface EcRenderConfig { productId: string; idType: string; content: PerProductConfig['content'] | null; allContentExists: boolean; source: string | null; sourceExists: boolean; } /** * The Enhanced Content API. * * This API is used to check for the existence of and to render Enhanced Content. */ export default class EnhancedContentApi { #private; /** @internal */ constructor(settings: SdkSettings, context: Context, logger: Logger, options?: EnhancedContentApiOptions); /** * Checks if Enhaned Content exists for the given combination of `productId` and `idType` * * This is an asynchronous request and uses a promise-based API. You must wait for the promise to resolve and use the * _resolved_ value to determine existence of EC. This can be done using async/await or a `then` callback. * * @example * Using `async/await`: * ```typescript * const ecExists = await salsify.enhancedContent.exists("123", "SKU"); * if (ecExists) { * // ...render EC * } * ``` * * @example * Using a `then` callback: * ```typescript * salsify.enhancedContent.exists("123", "SKU").then((ecExists) => { * if (ecExists) { * // ...render EC * } * }); * ``` * * @param productId The string ID for the product. * @param idType The identifier type for the product; defaults to the value set {@link "api".SdkApi.init | on `init`}. * @returns `true` if the product has Enhanced Content to display, `false` otherwise */ exists(productId: string, idType?: string): Promise; /** * Renders Enhanced Content for the given `productId` and `idType` into an * iFrame that is inserted into the provided `container` element. * * This can only be called in a browser runtime context. * * The Salsify SDK is responsible for creating the `IFrame` element and synchronizing the * height based on content changes. * * @example * ```javascript * const salsify = window.salsifyExperiencesSdk; * const element = document.getElementById('enhanced-content-container'); * salsify.enhancedContent.renderIframe(element, productId, idType); * ``` * * @param container The DOM element within which to render Enhanced Content. * @param productId The string ID for the product. * @param idType The identifier type for the product; defaults to the value set {@link "api".SdkApi.init | on `init`}. */ renderIframe(container: HTMLElement, productId: string, idType?: string): Promise; /** * Updates the language code for subsequent Enhanced Content requests. * * This method can be used when a user updates the page language, and will * change the language of the content _without re-rendering_. * * To update the currently displayed content, the client application will * need to re-render the content after calling this method. * * @example * ```javascript * salsify.enhancedContent.updateLanguageCode('fr-CA'); * * // this call now uses the new language code, "fr-CA" * salsify.enhancedContent.exists(productId, idType); * ``` * * @param languageCode The language code to use for subsequent calls. */ updateLanguageCode(languageCode: string): void; /** @internal */ get lastRenderConfig(): EcRenderConfig | undefined; }