@monterosa/sdk-launcher-kit 0.18.8 → 0.18.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -586,24 +586,6 @@ function getBridge(id) {
586
586
  bridges.set(id, bridge);
587
587
  return bridge;
588
588
  }
589
- /**
590
- * Returns true if the page is inside an iframe.
591
- *
592
- * @internal
593
- */
594
- function isInsideIframe() {
595
- if (typeof window === 'undefined') {
596
- return false;
597
- }
598
- try {
599
- return window.self !== window.top;
600
- }
601
- catch (_a) {
602
- // SecurityError is thrown when accessing window.top in a cross-origin iframe.
603
- // If we can't access it, we're definitely in an iframe.
604
- return true;
605
- }
606
- }
607
589
  /**
608
590
  * @internal
609
591
  */
@@ -614,9 +596,6 @@ function getParentBridge() {
614
596
  if (parentBridge !== undefined) {
615
597
  return parentBridge;
616
598
  }
617
- if (!isInsideIframe()) {
618
- return null;
619
- }
620
599
  var url = new URL(window.location.href);
621
600
  var bridgeId = url.searchParams.get(exports.QueryParam.BridgeId);
622
601
  if (bridgeId === null) {
@@ -1080,7 +1059,7 @@ function unstashStyles(element) {
1080
1059
  element.removeAttribute('data-stash');
1081
1060
  }
1082
1061
 
1083
- var version = "0.18.8";
1062
+ var version = "0.18.9";
1084
1063
 
1085
1064
  /**
1086
1065
  * @license
@@ -1600,7 +1579,6 @@ exports.getExperience = getExperience;
1600
1579
  exports.getParentApplication = getParentApplication;
1601
1580
  exports.getParentBridge = getParentBridge;
1602
1581
  exports.isAutoresizesHeight = isAutoresizesHeight;
1603
- exports.isInsideIframe = isInsideIframe;
1604
1582
  exports.onMessage = onMessage;
1605
1583
  exports.onMoreDataRequested = onMoreDataRequested;
1606
1584
  exports.onReady = onReady;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/constants.ts","../src/logger.ts","../src/utils/bridge/public_types.ts","../src/types.ts","../src/utils/bridge/types.ts","../src/utils/bridge/config.ts","../src/utils/bridge/helpers.ts","../src/utils/bridge/sideeffects.ts","../src/utils/bridge/constants.ts","../src/utils/bridge/bridge_impl.ts","../src/utils/bridge/api.ts","../src/experience_impl.ts","../src/loader.ts","../src/api.ts","../src/parent_application_impl.ts","../src/parent_application.ts","../src/child_helpers.ts"],"sourcesContent":["/**\n * @license\n * constants.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-15\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nexport const RESIZE_THROTTLE_TIMEOUT = 25;\n\n/**\n * Duration of the loader fade IN/OUT animation\n */\nexport const LOADER_ANIMATION_DURATION = 750;\n\n/**\n * Final cut off timeout for the loader after which it will be hidden even\n * though Experience UI may ne not yet ready\n */\nexport const LOADER_TIMEOUT = 5000;\n\n/**\n * Bumper timeout during which the loader still visible even though Experience\n * UI may be ready\n *\n * (!) At the moment its value is 0 as loader has a fade in effect what already\n * adds a small bumper delay before Experience is injected on the page\n */\nexport const LOADER_BUMPER_TIMEOUT = 0;\n\nexport const DEFAULT_HEIGHT = 250;\n","/**\n * @license\n * logger.ts\n * interact-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-05-23\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Logger } from '@monterosa/sdk-core';\n\nexport const logger = new Logger('@monterosa/sdk-launcher-kit');\n","/**\n * @license\n * public_types.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter } from '@monterosa/sdk-util';\n\n/**\n * Android SDK registers the following functions:\n * - calls `window.monterosaSdk.receiveMessage()` if wants to send a message\n * - registers `window.monterosaSdk.postMessage()` to receive a message\n * iOS SDK:\n * - calls `window.monterosaSdk.receiveMessage()` if wants to send a message\n * - registers `window.webkit.messageHandlers.monterosaSdk.postMessage()` to receive a message\n */\n\ntype GlobalMonterosaSdk = {\n initialised: boolean;\n emitter: Emitter;\n // send message to Android\n postMessage?: (message: string) => void;\n // receive a message from Android or iOS\n receiveMessage: (message: Message) => void;\n};\n\ntype GlobalWebkitType = {\n messageHandlers?: {\n monterosaSdk: {\n // post message to iOS\n postMessage: (message: string) => void;\n };\n };\n};\n\ndeclare global {\n /**\n * Declare variables in globalThis. This solution only works by declaring\n * variables with `var`: https://stackoverflow.com/a/69429093\n */\n\n // eslint-disable-next-line\n var monterosaSdk: GlobalMonterosaSdk | undefined;\n\n // eslint-disable-next-line\n var webkit: GlobalWebkitType | undefined;\n\n interface Window {\n monterosaSdk?: GlobalWebkitType;\n webkit?: GlobalWebkitType;\n }\n}\n\n/**\n * The Payload type is a type alias that represents a key-value hash object\n * in which the keys are strings and the values can be of any type.\n * This is a flexible way to define the content of the message being sent,\n * as the keys can be customized to match the specific needs of the application,\n * and the values can be any valid JavaScript type.\n */\nexport type Payload = { [string: string]: any };\n\n/**\n * The Message interface is used to define the structure of a message that\n * is passed between two applications via a communication bridge.\n */\nexport interface Message {\n /**\n * Id of the message. Its autogenerated by the communication bridge\n */\n id: string;\n /**\n * Id of the message this message responds to.\n */\n respondingTo: string | null;\n /**\n * The source of message. Used to distinguish Monterosa SDK messages from other\n * broadcasted messages. In the future can be used for a more fine grade targeting\n */\n sourceName: Source | string;\n /**\n * The current timestamp in milliseconds\n */\n timestamp: number;\n /**\n * Defines the message action\n */\n action: Action | string;\n /**\n * Hash of key-value pairs. Values constrained by json format:\n * four primitive types (strings, numbers, booleans,\n * and null) and two structured types (objects and arrays).\n */\n payload: Payload;\n /**\n * Used to identify if the message belongs to the communication\n * bridge established between parent and child\n */\n bridgeId: string;\n /**\n * Message protocol version\n */\n version: string;\n}\n\n/**\n * @internal\n */\nexport interface Bridge extends Emitter {\n id: string;\n iFrameId: string;\n iFrameSelector: string;\n childIFrame: HTMLIFrameElement | null;\n send: (\n action: string,\n payload?: Payload,\n sourceName?: Source,\n id?: string,\n ) => Message;\n request: (\n action: string,\n payload?: Payload,\n timeout?: number,\n sourceName?: Source,\n ) => Promise<Message>;\n}\n\n/**\n * @internal\n */\nexport interface Bridged {\n bridge: Bridge;\n}\n\n/**\n * A list of possible actions in communications between\n * parent application and child Experience\n *\n * @internal\n */\nexport enum Action {\n /**\n * Notifies that communication channel is ready and\n * messages can be {@link sendSdkMessage | sent}\n */\n OnReady = 'onBridgeReady',\n /**\n * Notifies that intrisic size of child Experience has changed\n */\n OnResize = 'onIntrinsicSizeChanged',\n /**\n * Notifies that UI of child Experience is loaded.\n * When this action is fired the loader will be hidden\n */\n OnUILoaded = 'onUILoaded',\n /**\n * Notifies child Experience about the request to load more data\n */\n OnMoreDataRequested = 'onMoreDataRequested',\n}\n\n/**\n * @internal\n */\nexport enum Source {\n Sdk = 'sdk',\n User = 'user',\n}\n","/**\n * @license\n * types.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-01-19\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { Unsubscribe } from '@monterosa/sdk-util';\n\nimport { Bridged } from './utils/bridge/public_types';\n\n/**\n * Reserved query parameter names for controlling the behaviour of Experience.\n */\nexport enum QueryParam {\n /**\n * Represents the host of the application. This parameter is added by Studio\n * and the embed URL already contains it.\n */\n Host = 'h',\n /**\n * Represents the Project Id of the application. This parameter is added by\n * Studio and the embed URL already contains it.\n */\n Project = 'p',\n /**\n * Represents the Event Id of the application. This parameter is added to the\n * experience URL when the eventId is provided in the experience config.\n */\n Event = 'e',\n /**\n * Used to identify the unique ID of the communication bridge between\n * the parent application and the child experience.\n */\n BridgeId = 'micBridgeId',\n /**\n * Determines whether the header and footer views of the application should be\n * hidden. This parameter can be used to control the visibility of the\n * application's header and footer components.\n */\n HideHeaderAndFooter = 'micHideHeaderAndFooter',\n /**\n * Determines whether autoresize is enabled for the application. When autoresize\n * is enabled, the application's height will adjust automatically based on its\n * content.\n */\n AutoresizesHeight = 'micAutoresizesHeight',\n}\n\n/**\n * Interface of user Experience provided by the Monterosa / Interaction Cloud\n */\nexport interface Experience extends Bridged {\n /**\n * Instance of SDK\n *\n * @internal\n */\n sdk: MonterosaSdk;\n /**\n * Config\n */\n config: ExperienceConfiguration;\n /**\n * Generates the URL to use when embedding the experience by\n * reconciling multiple data sources:\n *\n * 1. The embed URL as specified in App spec and obtained via Listings\n *\n * 2. The `host` and `projectId` used to configure the SDK instance\n *\n * 3. The `experienceUrl` passed via {@link ExperienceConfiguration}\n *\n * 4. `host`, `projectId` and `eventId` parameters passed via {@link ExperienceConfiguration}\n *\n * 5. Custom `parameters` dictionary passed via {@link ExperienceConfiguration}\n *\n * To reconcile all of those data sources, the SDK . Also we protect\n * {@link QueryParam | reserved parameters} required for the functioning\n * of the SDK.\n *\n * This implies:\n *\n * - SDK will always prioritise using the values lower in the list above.\n *\n * - SDK {@link QueryParam | reserved parameters} will be stripped out from\n * embed URL, `experienceURL` and custom\n * {@link ExperienceConfiguration | parameters dictionary}.\n *\n * - `h`, `e`, `p` query parameters provided in custom parameters dictionary\n * will be ignored\n *\n * @returns the URL to use when embedding the Experience.\n */\n getUrl(): Promise<string>;\n}\n\n/**\n * Interface of parent application\n *\n * @remarks\n * Parent application is a reference to the parent window where Experience\n * resides. It is used to establish communication bridge between Experience and\n * parent application. It can be get with {@link getParentApplication}\n */\nexport interface ParentApplication extends Bridged {}\n\n/**\n * Experience configuration options\n */\nexport interface ExperienceConfiguration {\n /**\n * The user is able to override default experience URL. If its not empty,\n * default experience URL will be overwritten with the provided one. At the\n * same time URL query parameters will remain.\n */\n experienceUrl?: string | null;\n /**\n * Overrides the host portion of the resulting experience URL. This property\n * takes precedence over `experienceUrl`. For example, if `experienceUrl` is\n * \"https://example.com?h=h1\" and the `host` is set to \"h2\", the resulting URL\n * will be: https://example.com?h=h2\n */\n host?: string;\n /**\n * Overrides the project id portion of the resulting experience URL. This\n * property takes precedence over `experienceUrl`. For example,\n * if `experienceUrl` is \"https://example.com?p=p1\" and the `projectId` is\n * set to \"p2\", the resulting URL will be: https://example.com?p=p2\n */\n projectId?: string;\n /**\n * If event id is provided, Experience can automatically displays elements\n * associated with this event. It is worth to mention that the behaviour of\n * Experiences depend on their implementation and can vary.\n *\n * This property takes precedence over `experienceUrl`. For example, if\n * `experienceUrl` is \"https://example.com?e=e1\" and the `eventId` is set to\n * \"e2\", the resulting URL will be: https://example.com?e=e2\n */\n eventId?: string;\n /**\n * A key/value dictionary of custom parameters that will be passed on to the\n * embedded Experience as URL query parameter. There are several reserved\n * parameter keys: \"p\", \"h\", \"e\", \"micHideHeaderAndFooter\" and \"micBridgeId\".\n * When one of reserved keys is provided it will be ignored.\n */\n parameters?: { [key: string]: string };\n /**\n * If true the container adjusts its height according to the intrinsic\n * height of embedded Experience\n */\n autoresizesHeight?: boolean;\n /**\n * If true removes the headers and footers of embedded Experience,\n * so that the resulting UI does not display two headers/footers.\n */\n hidesHeadersAndFooters?: boolean;\n /**\n * The user is able to control wether loading state is enabled or disabled\n * using this property. By default, it is true meaning that the loading state\n * will be enabled.\n */\n supportsLoadingState?: boolean;\n /**\n * Loading template is a function that returns html markup which can be used\n * to substitute default loader UI. Make sure that the template is wrapped in\n * a single html element, e.g. `() => '<div>...loading...</div>'`\n */\n loadingTemplate?: () => string;\n /*\n * Defines a Permissions Policy for the <iframe>. This policy outlines the\n * available features for the <iframe> (e.g., access to the microphone,\n * camera, battery, web-share, etc.) based on the origin of the request.\n *\n * Additional information can be found at: https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy\n */\n allow?: string;\n /**\n * Set this to true to enable iframe's fullscreen mode compatibility with\n * older browsers.\n */\n allowFullScreen?: boolean;\n /**\n * Custom title for the iframe element. If provided, this title will be set\n * on the iframe's title attribute in the generated embed code.\n */\n title?: string;\n}\n\n/**\n * @internal\n */\nexport interface Integration {\n experience: Experience;\n controller: AbortController;\n resizeUnsubscribe?: Unsubscribe;\n storageUnsubscribe?: Unsubscribe;\n hooksUnsubscribe: Unsubscribe[];\n}\n\n/**\n * @internal\n */\nexport type EmbedHook = (\n experience: Experience,\n container: HTMLElement,\n) => Unsubscribe;\n","/**\n * @license\n * types.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2024-01-02\n * Copyright © 2024 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Defines a set of error codes that may be encountered when using the\n * Launcher Kit bridge\n *\n * @example\n * ```javascript\n * try {\n * // some code that uses the LauncherKit's bridge\n * } catch (err) {\n * if (err.code === BridgeError.InvalidRequestTimeoutError) {\n * // handle invalid request timeout error\n * } else {\n * // handle other error types\n * }\n * }\n * ```\n *\n * @remarks\n * - The `BridgeError` enum provides a convenient way to handle errors\n * encountered when using the `LauncherKit` module. By checking the code\n * property of the caught error against the values of the enum, the error\n * type can be determined and appropriate action taken.\n *\n * - The `BridgeError` enum is not intended to be instantiated or extended.\n */\nexport enum BridgeError {\n /**\n * Indicates an error occurred due to an invalid timeout value being provided.\n * This error is thrown when the specified timeout is not a positive number.\n */\n InvalidRequestTimeoutError = 'invalid_request_timeout_error',\n /**\n * Indicates a request timed out waiting for a response.\n * This error is thrown when a bridge request exceeds the specified timeout duration.\n */\n RequestTimeoutError = 'request_timeout_error',\n}\n\nexport const BridgeErrorMessages = {\n [BridgeError.InvalidRequestTimeoutError]: () =>\n 'Request timeout must be greater than 0',\n [BridgeError.RequestTimeoutError]: (action: string, timeout: number) =>\n `Request timeout: action \"${action}\" did not receive a response within ${timeout}ms`,\n};\n","/**\n * @license\n * config.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2024-01-02\n * Copyright © 2024 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { createError } from '@monterosa/sdk-util';\n\nimport { BridgeError, BridgeErrorMessages } from './types';\n\n/**\n * @internal\n */\nconst Config = {\n requestTimeout: 20_000,\n};\n\n/**\n * Sets a new timeout value for requests (default is 20_000 mseconds).\n *\n * This function updates the request timeout in the application's configuration.\n * It ensures that the new timeout value is a positive number, and throws\n * an error if the value is non-positive.\n *\n * @param newTimeout - The new timeout value in milliseconds. Must be\n * a positive number.\n *\n * @throws\n * Throws {@link BridgeError | BridgeError.InvalidRequestTimeoutError}\n * if `newTimeout` is less than or equal to 0.\n *\n * @example\n * ```javascript\n * // Set the request timeout to 3000 milliseconds\n * setRequestTimeout(3000);\n * ```\n */\nexport function setRequestTimeout(newTimeout: number) {\n if (newTimeout <= 0) {\n throw createError(\n BridgeError.InvalidRequestTimeoutError,\n BridgeErrorMessages,\n );\n }\n\n Config.requestTimeout = newTimeout;\n}\n\nexport default Config;\n","/**\n * @license\n * helpers.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Message } from './public_types';\n\nexport function isMessage(message: Message | any): message is Message {\n return (\n message instanceof Object &&\n Object.prototype.hasOwnProperty.call(message, 'bridgeId')\n );\n}\n","/**\n * @license\n * sideeffect.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint no-console: \"off\" */\n\nimport { Emitter, getGlobal, getErrorMessage } from '@monterosa/sdk-util';\n\nimport { isMessage } from './helpers';\n\nconst globals = getGlobal();\n\nconst receiveMessage = (message: any) => {\n if (!isMessage(message)) {\n // data does not match message format\n return;\n }\n\n globals.monterosaSdk!.emitter.emit('message', message);\n};\n\nfunction handleWindowMessage({ data }: MessageEvent) {\n try {\n if (typeof data !== 'string') {\n // ignore non string data\n return;\n }\n\n const message = JSON.parse(data);\n\n receiveMessage(message);\n } catch (err) {\n console.error(getErrorMessage(err));\n }\n}\n\n/**\n * Since this code operates as a side effect while updating the global space,\n * we must be very careful because it may run twice, for example, when two apps\n * using the SDK run on the same page. Additionally, the global namespace may\n * already be updated by the Android or iOS SDKs.\n */\n\n// The Monterosa SDK namespace may already exist, either because it was created\n// by a native SDK or by another web app using the JS SDK from the same scope.\nglobals.monterosaSdk ??= {\n initialised: false,\n emitter: new Emitter(),\n receiveMessage,\n};\n\n// Each of nullish coalescing assignments will only be applied when\n// the Monterosa SDK namespace exists at that moment and one of its properties\n// is not defined.\nglobals.monterosaSdk.initialised ??= false;\nglobals.monterosaSdk.emitter ??= new Emitter();\nglobals.monterosaSdk.receiveMessage ??= receiveMessage;\n\nif (!globals.monterosaSdk.initialised) {\n // Subscribe to the message only once for each app that uses the SDK on this page.\n if (typeof globals.addEventListener !== 'undefined') {\n globals.addEventListener('message', handleWindowMessage);\n }\n\n globals.monterosaSdk.initialised = true;\n}\n","/**\n * @license\n * constants.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getGlobal } from '@monterosa/sdk-util';\n\nconst globals = getGlobal();\n\n/**\n * @internal\n */\nexport const IFRAME_ID_PREFIX = 'micBridge';\n\nexport const IS_IOS =\n !!globals.webkit?.messageHandlers?.monterosaSdk?.postMessage;\nexport const IS_ANDROID = !!globals.monterosaSdk?.postMessage;\nexport const IS_WEB = globals.self !== globals.parent;\n\n/**\n * @internal\n */\nexport const VERSION = '1.0.0';\n","/**\n * @license\n * bridge_impl.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getGlobal, Emitter, createError } from '@monterosa/sdk-util';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport './sideeffects';\n\nimport { Message, Bridge, Payload, Source } from './public_types';\nimport {\n IFRAME_ID_PREFIX,\n VERSION,\n IS_IOS,\n IS_WEB,\n IS_ANDROID,\n} from './constants';\nimport Config from './config';\nimport { BridgeError, BridgeErrorMessages } from './types';\n\nimport { logger } from '../../logger';\n\nconst globals = getGlobal();\n\n/**\n * @internal\n */\nclass BridgeImpl extends Emitter implements Bridge {\n constructor(public id: string = uuidv4()) {\n super();\n\n globals.monterosaSdk!.emitter.on('message', this.handleMessage.bind(this));\n }\n\n static isMessage(message: Message | any): message is Message {\n return (\n message instanceof Object &&\n Object.prototype.hasOwnProperty.call(message, 'bridgeId') &&\n Object.prototype.hasOwnProperty.call(message, 'action')\n );\n }\n\n get iFrameId(): string {\n return `${IFRAME_ID_PREFIX}-${this.id}`;\n }\n\n get iFrameSelector(): string {\n return `iframe#${this.iFrameId}`;\n }\n\n get childIFrame(): HTMLIFrameElement | null {\n return document.querySelector(this.iFrameSelector);\n }\n\n private handleMessage(message: Message) {\n if (message.bridgeId === this.id) {\n logger.log(\n `Received a ${message.respondingTo === null ? 'message' : 'response'}`,\n message,\n );\n\n this.emit('message', message);\n }\n }\n\n private createMessage(\n action: string,\n payload: Payload,\n sourceName: Source,\n respondingTo: string | null = null,\n ): Message {\n return {\n id: uuidv4(),\n respondingTo,\n action,\n sourceName,\n\n bridgeId: this.id,\n\n payload,\n version: VERSION,\n timestamp: Date.now(),\n };\n }\n\n postMessage(message: Message) {\n const json = JSON.stringify(message);\n\n if (IS_IOS) {\n globals.webkit?.messageHandlers?.monterosaSdk.postMessage(json);\n }\n\n if (IS_ANDROID) {\n if (globals.monterosaSdk?.postMessage) {\n globals.monterosaSdk.postMessage(json);\n }\n }\n\n if (IS_WEB) {\n globals.parent.postMessage(json, '*');\n }\n\n if (this.childIFrame) {\n this.childIFrame.contentWindow?.postMessage(json, '*');\n }\n }\n\n send(\n action: string,\n payload: Payload = {},\n sourceName = Source.Sdk,\n respondingTo?: string,\n ): Message {\n const message = this.createMessage(\n action,\n payload,\n sourceName,\n respondingTo,\n );\n\n logger.log(\n `Sending a ${message.respondingTo === null ? 'message' : 'response'}`,\n message,\n );\n\n this.postMessage(message);\n\n return message;\n }\n\n async request(\n action: string,\n payload: Payload = {},\n timeout: number = Config.requestTimeout,\n sourceName = Source.Sdk,\n ): Promise<Message> {\n let timeoutRef: ReturnType<typeof setTimeout>;\n let handler: (message: Message) => void;\n\n const message = this.createMessage(action, payload, sourceName);\n\n logger.log('Sending a request', message);\n\n /**\n * Start the timeout, when it finishes it should reject Promise.race below\n */\n const countdown: Promise<any> = new Promise((_, reject) => {\n timeoutRef = setTimeout(() => {\n reject(\n createError(\n BridgeError.RequestTimeoutError,\n BridgeErrorMessages,\n action,\n timeout,\n ),\n );\n }, timeout);\n });\n\n /**\n * Start the request and wait for the message with the respondingTo\n * equal to message id we sent\n */\n const request: Promise<Message> = new Promise((resolve) => {\n handler = (responseMessage: Message) => {\n if (responseMessage.respondingTo === message.id) {\n resolve(responseMessage);\n }\n };\n\n globals.monterosaSdk!.emitter.on('message', handler);\n\n this.postMessage(message);\n });\n\n /**\n * Start race between timeout and request\n * - if timeout wins the promise will be rejected\n * - if request wins then Message will be resolved\n */\n\n return (\n Promise.race([countdown, request])\n /**\n * As the matter of clean up we need to clear timeout id\n * and unsubscribe from the message event\n */\n .finally(() => {\n clearTimeout(timeoutRef);\n globals.monterosaSdk!.emitter.off('message', handler);\n })\n );\n }\n}\n\nexport default BridgeImpl;\n","/**\n * @license\n * api.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, subscribe } from '@monterosa/sdk-util';\n\nimport { Bridge, Bridged, Message, Source, Payload } from './public_types';\n\nimport { QueryParam } from '../../types';\n\nimport Config from './config';\nimport BridgeImpl from './bridge_impl';\n\nlet parentBridge: Bridge;\n\nconst bridges: Map<string, BridgeImpl> = new Map();\n\n/**\n * @internal\n */\nexport function getBridge(id: string): BridgeImpl {\n if (bridges.has(id)) {\n return bridges.get(id) as BridgeImpl;\n }\n\n const bridge = new BridgeImpl();\n\n bridges.set(id, bridge);\n\n return bridge;\n}\n\n/**\n * Returns true if the page is inside an iframe.\n *\n * @internal\n */\nexport function isInsideIframe(): boolean {\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n return window.self !== window.top;\n } catch {\n // SecurityError is thrown when accessing window.top in a cross-origin iframe.\n // If we can't access it, we're definitely in an iframe.\n return true;\n }\n}\n\n/**\n * @internal\n */\nexport function getParentBridge(): Bridge | null {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (parentBridge !== undefined) {\n return parentBridge;\n }\n\n if (!isInsideIframe()) {\n return null;\n }\n\n const url = new URL(window.location.href);\n\n const bridgeId = url.searchParams.get(QueryParam.BridgeId);\n\n if (bridgeId === null) {\n return null;\n }\n\n parentBridge = new BridgeImpl(bridgeId);\n\n return parentBridge;\n}\n\n/**\n * @internal\n */\nexport function sendSdkMessage(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n) {\n return bridged.bridge.send(action, payload, Source.Sdk);\n}\n\n/**\n * This function allows to send a simple message with action name and payload to\n * a recipient which can be either parent application (from Experience to parent\n * application) or child Experience (from parent page to Experience).\n *\n * @remarks\n * Usage example in parent application:\n *\n * @example\n * ```typescript\n * const experience = getExperience();\n *\n * // message to Experience can be sent only when its ready\n * onUILoaded(experience, async () => {\n * sendMessage(\n * experience,\n * 'my_action',\n * { key: 'value' }\n * );\n * });\n *\n * embed(experience);\n * ```\n *\n * Usage example in child Experience:\n *\n * @example\n * ```typescript\n * const parentApp = getParentApplication();\n *\n * if (parentApp !== null) {\n * sendMessage(\n * parentApp,\n * 'my_action',\n * { key: 'value' }\n * );\n * }\n * ```\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param action - Arbitrary action name that defines purpose of the message\n * @param payload - A key-value object that is sent in a message\n * @returns Returns {@link Message | message}\n */\nexport function sendMessage(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n) {\n return bridged.bridge.send(action, payload, Source.User);\n}\n\n/**\n * @internal\n */\nexport function sendSdkRequest(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n timeout = Config.requestTimeout,\n) {\n return bridged.bridge.request(action, payload, timeout, Source.Sdk);\n}\n\n/**\n * This function allows to send a request with action name and payload to\n * a recipient which can be either parent application (from Experience to parent\n * application) or child Experience (from parent page to Experience). It is similar\n * to {@link sendMessage} with only one difference is that it returns a Promise which\n * resolves if the recipient response with {@link respondToMessage}. Otherwise it\n * will rejects after a certain timeout.\n *\n * @remarks\n * Usage example in parent application:\n *\n * @example\n * ```typescript\n * const experience = getExperience();\n *\n * // request to Experience can be sent only when its ready\n * onUILoaded(experience, async () => {\n * const response = await sendRequest(\n * experience,\n * 'my_action',\n * { key: 'value' }\n * );\n *\n * console.log(response);\n * });\n *\n * embed(experience);\n * ```\n *\n * Usage example in child Experience:\n *\n * @example\n * ```typescript\n * const parentApp = getParentApplication();\n *\n * // parent application can be null if Experience is running stand alone\n * if (parentApp !== null) {\n * const response = await sendRequest(\n * parentApp,\n * 'my_action',\n * { key: 'value' }\n * );\n *\n * console.log(response);\n * }\n * ```\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param action - Arbitrary action name that defines purpose of the message\n * @param payload - A key-value object that is sent as in request\n * @param timeout - Configurable request timeout, if there is no response by\n * the end of this timeout then returned Promise will be rejected.\n */\nexport function sendRequest(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n timeout = Config.requestTimeout,\n) {\n return bridged.bridge.request(action, payload, timeout, Source.User);\n}\n\n/**\n * @internal\n */\nexport function respondToSdkMessage(\n bridged: Bridged,\n message: Message,\n payload: Payload = {},\n) {\n bridged.bridge.send(message.action, payload, Source.Sdk, message.id);\n}\n\n/**\n * Respond to a received message. It is used to reply to a\n * {@link sendRequest | user request}.\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param message - {@link Message | Message} to respond to\n * @param payload - A key-value object that is sent as in response\n */\nexport function respondToMessage(\n bridged: Bridged,\n message: Message,\n payload: Payload = {},\n) {\n bridged.bridge.send(message.action, payload, Source.User, message.id);\n}\n\nfunction onMessageFunc(\n bridged: Bridged,\n source: Source,\n callback: (message: Message) => void,\n) {\n return subscribe(bridged.bridge, 'message', (message: Message) => {\n if (message.sourceName === source) {\n callback(message);\n }\n });\n}\n\n/**\n * @internal\n */\nexport function onSdkMessage(\n bridged: Bridged,\n callback: (message: Message) => void,\n): Unsubscribe {\n return onMessageFunc(bridged, Source.Sdk, callback);\n}\n\n/**\n * Adds an observer for when user message is received\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param callback - The callback that is triggered when user message is received\n * @returns The unsubscribe function. When it's called,\n * the observer will be removed and user messages will no longer be received\n */\nexport function onMessage(\n bridged: Bridged,\n callback: (message: Message) => void,\n): Unsubscribe {\n return onMessageFunc(bridged, Source.User, callback);\n}\n","/**\n * @license\n * experience_impl.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-01-19\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { fetchListings } from '@monterosa/sdk-interact-interop';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { QueryParam, Experience, ExperienceConfiguration } from './types';\nimport { getBridge, Bridge } from './utils/bridge';\n\n/**\n * @internal\n */\nexport class ExperienceImpl implements Experience {\n readonly _config: Readonly<ExperienceConfiguration>;\n private _parameters: { [key: string]: string } = {};\n readonly bridge: Bridge;\n embedUrl!: string;\n\n constructor(public sdk: MonterosaSdk, config: ExperienceConfiguration) {\n this._config = config;\n this.bridge = getBridge(uuidv4());\n\n if (config.parameters !== undefined) {\n const reserved = Object.values(QueryParam) as string[];\n const ignored: string[] = [];\n\n Object.entries(config.parameters).forEach(([key, value]) => {\n if (reserved.includes(key)) {\n ignored.push(key);\n } else {\n this._parameters[key] = value;\n }\n });\n\n if (ignored.length === 1) {\n console.warn(\n `Parameter \"${ignored[0]}\" ignored as it matches reserved words`,\n );\n }\n\n if (ignored.length > 1) {\n console.warn(\n `Parameters \"${ignored.join(\n '\", \"',\n )}\" ignored as they match reserved words`,\n );\n }\n }\n }\n\n get config() {\n return Object.assign(this._config, {\n autoresizesHeight: this._config.autoresizesHeight ?? false,\n hidesHeadersAndFooters: this._config.hidesHeadersAndFooters ?? true,\n supportsLoadingState: this._config.supportsLoadingState ?? true,\n experienceUrl: this._config.experienceUrl ?? null,\n });\n }\n\n async getEmbedUrl() {\n if (this.embedUrl) {\n return Promise.resolve(this.embedUrl);\n }\n\n const {\n options: { host, projectId },\n } = this.sdk;\n\n const listings = await fetchListings(host, projectId);\n\n this.embedUrl = listings.project.embed;\n\n return this.embedUrl;\n }\n\n async getUrl(): Promise<string> {\n const embedUrl = await this.getEmbedUrl();\n\n // sanitise and create an object from an url\n let url = new URL(ExperienceImpl.sanitiseUrl(embedUrl));\n\n // override host and project with those that are set in SDK instance\n url.searchParams.set(QueryParam.Host, this.sdk.options.host);\n url.searchParams.set(QueryParam.Project, this.sdk.options.projectId);\n\n // if custom experienceUrl is set:\n // * take experienceUrl as the base\n // * search params from experienceUrl have priority\n if (this.config.experienceUrl !== null) {\n // sanitise and create an object from a custom url\n const customUrl = new URL(\n ExperienceImpl.sanitiseUrl(this.config.experienceUrl),\n );\n\n // apply embedUrl query parameters if they don't exist in experienceUrl\n Array.from(url.searchParams.entries())\n .filter(([key]) => !customUrl.searchParams.has(key))\n .forEach(([key, value]) => customUrl.searchParams.set(key, value));\n\n url = customUrl;\n }\n\n // Prepare a final list of query parameters\n const queryParameters = {\n ...(this.config.host !== undefined && {\n [QueryParam.Host]: this.config.host,\n }),\n\n ...(this.config.projectId !== undefined && {\n [QueryParam.Project]: this.config.projectId,\n }),\n\n ...(this.config.eventId !== undefined && {\n [QueryParam.Event]: this.config.eventId,\n }),\n\n [QueryParam.BridgeId]: this.bridge.id,\n\n [QueryParam.HideHeaderAndFooter]: this.config.hidesHeadersAndFooters\n ? '1'\n : '0',\n\n [QueryParam.AutoresizesHeight]: this.config.autoresizesHeight ? '1' : '0',\n\n // Adding user defined parameters to the URL search parameters if exists\n ...this._parameters,\n };\n\n Object.entries(queryParameters).forEach(([key, value]) => {\n url.searchParams.set(key, value);\n });\n\n return url.href;\n }\n\n private static sanitiseUrl(\n url: string,\n options?: {\n stripReservedParameters?: 'all' | 'mic';\n },\n ): string {\n const stripReservedParameters = options?.stripReservedParameters || 'mic';\n\n // Ensure the URL includes a protocol.\n if (/^http/.test(url) === false) {\n // If none are found, use the same as the document.\n url = `${document.location.protocol}${url}`;\n }\n\n const urlObj = new URL(url);\n\n Object.values(QueryParam)\n .filter((key) => {\n if (stripReservedParameters === 'mic') {\n return key.startsWith('mic');\n }\n\n return key;\n })\n .forEach((key) => urlObj.searchParams.delete(key));\n\n return urlObj.href;\n }\n}\n","/**\n * @license\n * loader.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-08-04\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { delay } from '@monterosa/sdk-util';\n\nimport { LOADER_ANIMATION_DURATION, DEFAULT_HEIGHT } from './constants';\n\n/* eslint-disable */\ntype CSSProperties = keyof Omit<\n CSSStyleDeclaration,\n | typeof Symbol.iterator\n | number\n | 'length'\n | 'parentRule'\n | 'getPropertyPriority'\n | 'getPropertyValue'\n | 'item'\n | 'removeProperty'\n | 'setProperty'\n>;\n/* eslint-enable */\n\nfunction getLoadingTemplate(): string {\n return `\n <div>\n <style type=\"text/css\">\n .__mic-loader {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 9;\n box-sizing: border-box;\n text-align: center;\n background: #fff;\n }\n\n .__mic-loader__container {\n padding: 20px 0;\n gap: 20px;\n min-height: ${DEFAULT_HEIGHT}px;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .__mic-loader__spinner {\n position: relative;\n width: 10px;\n height: 10px;\n border-radius: 5px;\n background-color: #0b0f1c;\n color: #0b0f1c;\n animation: mic-loader__animation 1s infinite linear alternate;\n animation-delay: 0.5s; \n }\n\n .__mic-loader__spinner::before,\n .__mic-loader__spinner::after {\n content: \"\";\n display: inline-block;\n position: absolute;\n top: 0;\n }\n\n .__mic-loader__spinner::before {\n left: -15px;\n width: 10px;\n height: 10px;\n border-radius: 5px;\n background-color: #0b0f1c;\n color: #0b0f1c;\n animation: mic-loader__animation 1s infinite alternate;\n animation-delay: 0s;\n }\n\n .__mic-loader__spinner::after {\n left: 15px;\n width: 10px;\n height: 10px;\n border-radius: 5px;\n background-color: #0b0f1c;\n color: #0b0f1c;\n animation: mic-loader__animation 1s infinite alternate;\n animation-delay: 1s;\n }\n\n @keyframes mic-loader__animation {\n 0% {\n background-color: #0b0f1c;\n }\n 50%, 100% {\n background-color: rgba(11, 15, 28, 0.2);\n }\n }\n </style>\n <div class=\"__mic-loader\">\n <div class=\"__mic-loader__container\">\n <div class=\"__mic-loader__spinner\"></div>\n </div>\n </div>\n </div>\n `;\n}\n\nexport function embed(\n container: HTMLElement,\n loadingTemplate: () => string = getLoadingTemplate,\n): HTMLElement {\n /**\n * Return existing element if it exists\n */\n let loaderElement: HTMLElement | null =\n container.querySelector('[data-role=loader]');\n\n if (loaderElement !== null) {\n return loaderElement;\n }\n\n /**\n * Stash and apply some custom styles to container element\n */\n stashStyles(container, ['minHeight', 'position']);\n\n container.style.minHeight = `${DEFAULT_HEIGHT}px`;\n\n /**\n * Inject loader element built from the html markup template\n */\n const templateElement = document.createElement('template');\n templateElement.innerHTML = loadingTemplate().trim();\n\n loaderElement = container.appendChild(\n templateElement.content.firstElementChild as Element,\n ) as HTMLElement;\n\n /**\n * Setting custom data attribute to be able to distinguish element along\n * other injected html elements if any\n */\n loaderElement.setAttribute('data-role', 'loader');\n\n return loaderElement;\n}\n\nexport function unmount(container: HTMLElement): void {\n const loaderElement = container.querySelector('[data-role=loader]');\n\n if (loaderElement === null) {\n return;\n }\n\n loaderElement.parentElement?.removeChild(loaderElement);\n\n unstashStyles(container);\n}\n\nexport async function show(\n container: HTMLElement,\n loadingTemplate: () => string = getLoadingTemplate,\n): Promise<void> {\n const loaderElement = embed(container, loadingTemplate);\n\n const { position } = getComputedStyle(container);\n\n /**\n * In order to properly position the loader,\n * the container's position should be anything but 'static'.\n */\n if (position === 'static') {\n container.style.position = 'relative';\n }\n\n /**\n * Setting styles to the loader for a nice fade in animation\n */\n loaderElement.style.opacity = '0';\n\n /**\n * Kicking fade animation in.\n */\n setTimeout(() => {\n loaderElement.style.transition = `all ${LOADER_ANIMATION_DURATION}ms`;\n loaderElement.style.opacity = '1';\n }, 0);\n\n /**\n * Wait until the animation is finished. We do not use \"transitionend\" event\n * here as it will just make the code more bloated and unnecessary complex.\n */\n await delay(LOADER_ANIMATION_DURATION);\n}\n\nexport async function hide(container: HTMLElement): Promise<void> {\n const loaderElement: HTMLElement | null =\n container.querySelector('[data-role=loader]');\n\n if (loaderElement === null) {\n return;\n }\n\n /**\n * Kicking fade out animation.\n */\n setTimeout(() => {\n loaderElement.style.opacity = '0';\n }, 0);\n\n /**\n * Wait until the animation is finished. We do not use \"transitionend\" event\n * here as it will just make the code more bloated and unnecessary complex.\n */\n await delay(LOADER_ANIMATION_DURATION);\n\n unstashStyles(container);\n unmount(container);\n}\n\nfunction stashStyles(element: HTMLElement, props: CSSProperties[]) {\n const styles = getComputedStyle(element);\n\n const stash = props\n .map((prop) => `${String(prop)}=${styles[prop]}`)\n .join(';');\n\n element.setAttribute('data-stash', stash);\n}\n\nfunction unstashStyles(element: HTMLElement) {\n const stash = element.getAttribute('data-stash');\n\n if (stash === null) {\n return;\n }\n\n const attributes: [attr: CSSProperties, value: string][] = stash\n .split(';')\n .map((attr) => attr.split('=') as [attr: CSSProperties, value: string]);\n\n for (const [attr, value] of attributes) {\n element.style[attr] = value;\n }\n\n element.removeAttribute('data-stash');\n}\n","/**\n * @license\n * api.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-02-15\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, Sdk, getSdk, LogLevel } from '@monterosa/sdk-core';\nimport { Unsubscribe, delay } from '@monterosa/sdk-util';\n\nimport {\n Experience,\n ExperienceConfiguration,\n Integration,\n EmbedHook,\n} from './types';\n\nimport { LOADER_TIMEOUT, LOADER_BUMPER_TIMEOUT } from './constants';\n\nimport { logger } from './logger';\n\nimport { sendSdkMessage, onSdkMessage, Action } from './utils/bridge';\n\nimport { ExperienceImpl } from './experience_impl';\n\nimport { show as showLoader, hide as hideLoader } from './loader';\n\nimport { version } from '../package.json';\n\n/**\n * The current SDK version.\n *\n * @internal\n */\nexport const VERSION = version;\n\nconst integrations: Map<HTMLElement, Integration> = new Map();\nconst embedHooks: EmbedHook[] = [];\n\n/**\n * Creates an iframe with the provided parameters.\n *\n * @param url Url of the web app.\n *\n * @private\n */\nfunction createIFrame(\n url: string,\n options: {\n id?: string;\n scrolling?: boolean;\n allow?: string;\n allowFullScreen?: boolean;\n title?: string;\n } = {},\n): HTMLIFrameElement {\n const iframe = document.createElement('iframe');\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.border = '0';\n iframe.style.display = 'block';\n iframe.style.boxSizing = 'border-box';\n\n iframe.setAttribute('src', url);\n\n if (options.id !== undefined) {\n iframe.setAttribute('id', options.id);\n }\n\n if (options.allow !== undefined) {\n iframe.setAttribute('allow', options.allow);\n }\n\n if (options.allowFullScreen === true) {\n iframe.setAttribute('allowfullscreen', '');\n }\n\n if (options.title !== undefined) {\n iframe.setAttribute('title', options.title);\n }\n\n /**\n * Though scrolling attribute is deprecated we still have to rely on it as some\n * browsers (e.g. Chrome, as of now version 103) just ignores overflow: hidden.\n * Hence we are setting scrolling to no in order to eliminate scroll and calculate\n * width of the child Experience correctly. If scroll persists it appears on each\n * content change what leads to incorrect width calculation.\n *\n * Later we will look into alternatives such as iframeless Experience embed\n */\n if (!options.scrolling) {\n iframe.style.overflow = 'hidden';\n iframe.setAttribute('scrolling', 'no');\n }\n\n return iframe;\n}\n\nfunction concealIFrame(iframe: HTMLIFrameElement) {\n iframe.style.opacity = '0';\n}\n\nfunction revealIFrame(iframe: HTMLIFrameElement) {\n iframe.style.opacity = '1';\n}\n\nfunction isSdk(value: MonterosaSdk | any): value is MonterosaSdk {\n return value instanceof Sdk;\n}\n\n/**\n * Returns Experience for the default given sdk\n *\n * @param config - Optional config\n */\nexport function getExperience(config?: ExperienceConfiguration): Experience;\n\n/**\n * Returns Experience for the given sdk\n *\n * @param sdk - Optional project instance whose Experience to return.\n * if no project is provided, it will attempt to use the default one\n * @param config - Optional config\n */\nexport function getExperience(\n sdk?: MonterosaSdk,\n config?: ExperienceConfiguration,\n): Experience;\n\nexport function getExperience(\n sdkOrConfig?: MonterosaSdk | ExperienceConfiguration,\n config?: ExperienceConfiguration,\n): Experience {\n let sdk: MonterosaSdk;\n let experienceConfig: ExperienceConfiguration;\n\n if (isSdk(sdkOrConfig)) {\n /**\n * Interface: getExperience(sdk, config?)\n */\n\n sdk = sdkOrConfig;\n\n if (config !== undefined) {\n experienceConfig = config;\n } else {\n experienceConfig = {};\n }\n } else if (sdkOrConfig !== undefined) {\n /**\n * Interface: getExperience(config)\n */\n\n sdk = getSdk();\n experienceConfig = sdkOrConfig;\n } else {\n /**\n * Interface: getExperience()\n */\n\n sdk = getSdk();\n experienceConfig = {};\n }\n\n const experience = new ExperienceImpl(sdk, experienceConfig);\n\n return experience;\n}\n\nfunction onResize(experience: Experience, container: HTMLElement): Unsubscribe {\n if (!experience.config.autoresizesHeight) {\n return () => {};\n }\n\n return onSdkMessage(experience, ({ action, payload }) => {\n if (action === Action.OnResize) {\n /**\n * Container width is maintained the same as it is defined in the parent\n * page to preserve its behaviour. Only the height is updated\n */\n // container.style.width = `${payload.width}px`;\n container.style.height = `${payload.height}px`;\n }\n });\n}\n\nfunction onUILoaded(experience: Experience): Promise<void> {\n return new Promise((resolve) => {\n const unsubscribe = onSdkMessage(experience, ({ action }) => {\n if (action === Action.OnUILoaded) {\n unsubscribe();\n resolve();\n }\n });\n });\n}\n\nasync function experienceReady(experience: Experience) {\n /**\n * Bumper delay during which loading state can't be hidden even\n * if Experience loaded earlier than timer reached bumper timeout\n */\n const bumper = delay(LOADER_BUMPER_TIMEOUT);\n\n /**\n * Final cut off timeout delay after which loading state must\n * be hidden even if Experience is still loading\n */\n const timeout = delay(LOADER_TIMEOUT);\n\n /**\n * Promisifying OnUILoaded communication bridge event\n */\n const loaded = onUILoaded(experience);\n\n const hasFullyLoadedExperience = Promise.all([bumper, loaded]);\n\n const eitherTimeoutOrFullyLoaded = Promise.race([\n timeout,\n hasFullyLoadedExperience,\n ]);\n\n return eitherTimeoutOrFullyLoaded;\n}\n\n/**\n * Embeds web Experience app into iframe. There is only one app can be\n * associated with Experience and it is configured in\n * Monterosa / Interaction Cloud. Please refer the developer guide to get\n * more information on what is app and how to configure it:\n * {@link https://products.monterosa.co/mic/developer-guides/whats-an-app}\n *\n * @example\n * ```javascript\n * const experience = getExperience();\n *\n * embed(experience, 'container-id');\n * ```\n * @param {Experience} - An instance of Experience\n * @param {HTMLElement | string} containerOrId - HTML element instance or\n * element id where iframe is embedded into.\n *\n * @public\n */\nexport async function embed(\n experience: Experience,\n containerOrId: HTMLElement | string,\n): Promise<void> {\n const container =\n containerOrId instanceof HTMLElement\n ? containerOrId\n : document.getElementById(containerOrId);\n\n if (container === null) {\n throw new Error(\n `Container element with id \"${containerOrId}\" doesn't exist in DOM`,\n );\n }\n\n if (integrations.has(container)) {\n return;\n }\n\n const controller = new AbortController();\n const hooksUnsubscribe: Unsubscribe[] = [];\n\n integrations.set(container, {\n experience,\n controller,\n hooksUnsubscribe,\n });\n\n if (experience.config.supportsLoadingState === true) {\n // Although showLoader is an asynchronous function, we execute\n // it synchronously to embed the iframe as quickly as possible.\n showLoader(container, experience.config.loadingTemplate);\n }\n\n for (const hook of embedHooks) {\n const unsub = hook(experience, container);\n\n hooksUnsubscribe.push(unsub);\n }\n\n const url = await experience.getUrl();\n\n if (controller.signal.aborted) {\n return;\n }\n\n const iframe = createIFrame(url, {\n id: experience.bridge.iFrameId,\n scrolling: !experience.config.autoresizesHeight,\n allow: experience.config.allow,\n allowFullScreen: experience.config.allowFullScreen,\n title: experience.config.title,\n });\n\n container.appendChild(iframe);\n\n concealIFrame(iframe);\n\n await experienceReady(experience);\n\n if (controller.signal.aborted) {\n return;\n }\n\n revealIFrame(iframe);\n\n if (experience.config.supportsLoadingState === true) {\n await hideLoader(container);\n }\n}\n\n/**\n * Unmounts web Experience app which was previously embedded in the container.\n *\n * @example\n * ```javascript\n * unmount('container-id');\n * ```\n *\n * @param {HTMLElement | string} containerOrId - HTML element instance or\n * element id where iframe is embedded into.\n *\n * @public\n */\nexport function unmount(containerOrId: HTMLElement | string): void {\n const container =\n containerOrId instanceof HTMLElement\n ? containerOrId\n : document.getElementById(containerOrId);\n\n if (container === null) {\n throw new Error(\n `Container element with id \"${containerOrId}\" doesn't exist in DOM`,\n );\n }\n\n const integration = integrations.get(container);\n\n if (!integration) {\n return;\n }\n\n integration.controller.abort();\n\n for (const unsub of integration.hooksUnsubscribe) {\n unsub();\n }\n\n while (container.lastElementChild) {\n container.removeChild(container.lastElementChild);\n }\n\n integrations.delete(container);\n\n container.style.height = '';\n}\n\n/**\n * Informs the Experience that more data should be loaded and displayed on the UI.\n *\n * @remarks\n * One example is when Experience renders items feed partially. Once a user scrolled\n * to the bottom edge of the app, more elements to load is requested.\n *\n * @param experience - Experience instance\n */\nexport function requestMoreData(experience: Experience): void {\n sendSdkMessage(experience, Action.OnMoreDataRequested);\n}\n\n/**\n * @internal\n */\nexport function registerEmbedHook(hook: EmbedHook) {\n embedHooks.push(hook);\n}\n\n/**\n * Enables logging with the specified log level.\n *\n * @param logLevel - The log level or flag to determine the logging\n * behavior. If a log level is provided, it will be used to set the log\n * level. If a boolean flag is provided, logging will be enabled or disabled\n * based on the flag value.\n */\nexport function enableLogging(logLevel?: LogLevel): void;\n\n/**\n * Enables or disables logging based on the provided flag.\n *\n * @param enable - The flag to determine the logging behavior. If a boolean flag\n * is provided, logging will be enabled or disabled based on the flag value.\n */\nexport function enableLogging(enable?: boolean): void;\n\nexport function enableLogging(logLevelOrFlag: LogLevel | boolean = true) {\n if (typeof logLevelOrFlag === 'boolean') {\n logger.logLevel = logLevelOrFlag ? LogLevel.Verbose : LogLevel.Silent;\n\n return;\n }\n\n logger.logLevel = logLevelOrFlag;\n}\n\nregisterEmbedHook(onResize);\n","/**\n * @license\n * parent_application_impl.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Bridge } from './utils/bridge';\nimport { ParentApplication } from './types';\n\n/**\n * @internal\n */\nexport class ParentApplicationImpl implements ParentApplication {\n constructor(public bridge: Bridge) {}\n}\n","/**\n * @license\n * parent_application.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-15\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { ParentApplication } from './types';\n\nimport { ParentApplicationImpl } from './parent_application_impl';\n\nimport { getParentBridge } from './utils/bridge';\n\nlet parentApplication: ParentApplication;\n\n/**\n * Returns instance of parent application.\n *\n * @returns Returns {@link ParentApplication}\n * if an Experience resides within the parent application, and it was embedded\n * using {@link embed} function. Otherwise it returns `null`.\n */\nexport function getParentApplication(): ParentApplication | null {\n if (parentApplication !== undefined) {\n return parentApplication;\n }\n\n const parentBridge = getParentBridge();\n\n if (parentBridge === null) {\n return null;\n }\n\n parentApplication = new ParentApplicationImpl(parentBridge);\n\n return parentApplication;\n}\n","/**\n * @license\n * child_helpers.ts\n * launcher-kit\n *\n * Created by Josep Rodriguez <josep.rodriguez@monterosa.co.uk> on 2022-07-13\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, throttle } from '@monterosa/sdk-util';\n\nimport { RESIZE_THROTTLE_TIMEOUT } from './constants';\n\nimport { QueryParam, Experience } from './types';\n\nimport { getParentApplication } from './parent_application';\nimport { sendSdkMessage, onSdkMessage, Action } from './utils/bridge';\n\nfunction getUrlParam(param: string) {\n let queryString = {};\n\n if (typeof window !== 'undefined') {\n queryString = window.location.search;\n }\n\n const urlParams = new URLSearchParams(queryString);\n\n return urlParams.get(param);\n}\n\n/**\n * The SDK on the parent application will by default request a child\n * Experience to hide its header and footer by setting a query parameter called\n * `micHideHeaderAndFooter` to `1`.\n *\n * This function will return true if that is the case, and false otherwise.\n *\n * When true, the developer of a child Experience is expected to hide it's headers\n * and footers as the parent application is actively providing them.\n *\n * You can test whether you are respecting this correctly by adding the following query\n * to your URL:\n *\n * \"?micHideHeaderAndFooter=1\"\n *\n * @returns Whether the header and footer views should be hidden.\n */\nexport function shouldHideHeaderAndFooter() {\n return getUrlParam(QueryParam.HideHeaderAndFooter) === '1';\n}\n\n/**\n * This function will returns true if experience is embedded in autoresize height mode.\n */\nexport function isAutoresizesHeight() {\n return getUrlParam(QueryParam.AutoresizesHeight) === '1';\n}\n\n/**\n * This function is used to notify the parent application that the Experience\n * is ready to be used. It's intended to be called by the Experience itself and\n * not by the parent application.\n *\n * @example\n * ```javascript\n * import { sendReady } from '@monterosa/sdk-launcher-kit';\n *\n * sendReady();\n * ```\n *\n * @returns void\n */\nexport function sendReady(): void {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n console.log(\n 'Unable to send finished loading UI message, as there is no parent application',\n );\n\n return;\n }\n\n sendSdkMessage(parentApp, Action.OnReady);\n}\n\n/**\n * Sends a message to the SDK of the parent application informing it that\n * the UI of this Experience has completed loading.\n *\n * You should call this method when your UI has completed loading and you are ready to\n * display data to the user. This can be when your network calls have successfully requested\n * data and you have updated the DOM for it, or when an error has occurred and you want\n * to take over the UI to provide details to the user.\n *\n * The SDK will use this message to dismiss the loading indicator, allowing a seamless\n * transition between a native loading UI, into a fully loaded, child Experience.\n *\n * If this call is not made, the parent SDK will add a grace period to ensure the web app\n * has sufficient time to load, and eventually dismiss the loading state, whether Experience\n * is ready or not, so as to avoid scenarios were a defect leaves an infinite loading state\n * presented to the user.\n */\nexport function sendFinishedLoadingUI() {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n console.log(\n 'Unable to send finished loading UI message, as there is no parent application',\n );\n\n return;\n }\n\n sendSdkMessage(parentApp, Action.OnUILoaded);\n}\n\n/**\n * Adds an observer for when more data is requested by the parent application\n *\n * @param callback - The callback that is triggered when a request for more data\n * is received\n * @returns The unsubscribe function. When it's called,\n * the observer will be removed and requests for data will no longer be received\n */\nexport function onMoreDataRequested(callback: () => void): Unsubscribe {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n console.log(\n 'Unable to subscribe to more data event, as there is no parent application',\n );\n\n return () => {};\n }\n\n return onSdkMessage(parentApp, ({ action }) => {\n if (action === Action.OnMoreDataRequested) {\n callback();\n }\n });\n}\n\n/**\n * Adds an observer for when experience is fully embedded and ready to accept\n * incoming messages\n *\n * @param experience - Experience instance\n * @param callback - The callback that is triggered when experience is embedded\n * @returns The unsubscribe function. When it's called, the observer will be\n * removed and ready event will not be received\n */\nexport function onReady(\n experience: Experience,\n callback: () => void,\n): Unsubscribe {\n return onSdkMessage(experience, ({ action }) => {\n if (action === Action.OnReady) {\n callback();\n }\n });\n}\n\n/**\n * @internal\n */\nexport const sendExperienceSizeThrottled: (\n width: number,\n height: number,\n) => void = throttle(\n (width: number, height: number) => {\n const parentApp = getParentApplication();\n\n if (parentApp === null) return;\n\n sendSdkMessage(parentApp, Action.OnResize, { width, height });\n },\n RESIZE_THROTTLE_TIMEOUT,\n {\n leading: true,\n trailing: true,\n },\n);\n\n/**\n * @internal\n */\nexport function sendExperienceSize(width: number, height: number) {\n return sendExperienceSizeThrottled(width, height);\n}\n\n/**\n * Sets up an observer to watch for the element dimensions change and\n * automatically reports their changes to the parent application.\n *\n * @param element - HTML element whose dimensions need to be watched\n * @returns The unsubscribe function. When it's called,\n * the observer will be removed and element dimensions are no longer tracked\n */\nexport function reportExperienceSizeChanges(element: HTMLElement): () => void {\n const observer = new ResizeObserver(() => {\n const width = Math.max(element.offsetWidth, element.scrollWidth);\n const height = Math.max(element.offsetHeight, element.scrollHeight);\n\n sendExperienceSize(width, height);\n });\n\n observer.observe(element);\n\n return () => observer.unobserve(element);\n}\n"],"names":["Logger","Action","Source","QueryParam","BridgeError","_a","createError","globals","getGlobal","getErrorMessage","Emitter","VERSION","uuidv4","subscribe","fetchListings","embed","unmount","delay","Sdk","getSdk","showLoader","hideLoader","LogLevel","throttle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAWO,IAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;AAGO,IAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C;;;;AAIO,IAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;;;;;;AAOO,IAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,IAAM,cAAc,GAAG,GAAG;;ACjCjC;;;;;;;;;;AAaO,IAAM,MAAM,GAAG,IAAIA,cA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M,CAAC,CAAC;KACnC,CAAC,CAAC;IAEH,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1B,OAAO,cAAM,OAAA,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,GAAA,CAAC;AAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/constants.ts","../src/logger.ts","../src/utils/bridge/public_types.ts","../src/types.ts","../src/utils/bridge/types.ts","../src/utils/bridge/config.ts","../src/utils/bridge/helpers.ts","../src/utils/bridge/sideeffects.ts","../src/utils/bridge/constants.ts","../src/utils/bridge/bridge_impl.ts","../src/utils/bridge/api.ts","../src/experience_impl.ts","../src/loader.ts","../src/api.ts","../src/parent_application_impl.ts","../src/parent_application.ts","../src/child_helpers.ts"],"sourcesContent":["/**\n * @license\n * constants.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-15\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nexport const RESIZE_THROTTLE_TIMEOUT = 25;\n\n/**\n * Duration of the loader fade IN/OUT animation\n */\nexport const LOADER_ANIMATION_DURATION = 750;\n\n/**\n * Final cut off timeout for the loader after which it will be hidden even\n * though Experience UI may ne not yet ready\n */\nexport const LOADER_TIMEOUT = 5000;\n\n/**\n * Bumper timeout during which the loader still visible even though Experience\n * UI may be ready\n *\n * (!) At the moment its value is 0 as loader has a fade in effect what already\n * adds a small bumper delay before Experience is injected on the page\n */\nexport const LOADER_BUMPER_TIMEOUT = 0;\n\nexport const DEFAULT_HEIGHT = 250;\n","/**\n * @license\n * logger.ts\n * interact-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-05-23\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Logger } from '@monterosa/sdk-core';\n\nexport const logger = new Logger('@monterosa/sdk-launcher-kit');\n","/**\n * @license\n * public_types.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter } from '@monterosa/sdk-util';\n\n/**\n * Android SDK registers the following functions:\n * - calls `window.monterosaSdk.receiveMessage()` if wants to send a message\n * - registers `window.monterosaSdk.postMessage()` to receive a message\n * iOS SDK:\n * - calls `window.monterosaSdk.receiveMessage()` if wants to send a message\n * - registers `window.webkit.messageHandlers.monterosaSdk.postMessage()` to receive a message\n */\n\ntype GlobalMonterosaSdk = {\n initialised: boolean;\n emitter: Emitter;\n // send message to Android\n postMessage?: (message: string) => void;\n // receive a message from Android or iOS\n receiveMessage: (message: Message) => void;\n};\n\ntype GlobalWebkitType = {\n messageHandlers?: {\n monterosaSdk: {\n // post message to iOS\n postMessage: (message: string) => void;\n };\n };\n};\n\ndeclare global {\n /**\n * Declare variables in globalThis. This solution only works by declaring\n * variables with `var`: https://stackoverflow.com/a/69429093\n */\n\n // eslint-disable-next-line\n var monterosaSdk: GlobalMonterosaSdk | undefined;\n\n // eslint-disable-next-line\n var webkit: GlobalWebkitType | undefined;\n\n interface Window {\n monterosaSdk?: GlobalWebkitType;\n webkit?: GlobalWebkitType;\n }\n}\n\n/**\n * The Payload type is a type alias that represents a key-value hash object\n * in which the keys are strings and the values can be of any type.\n * This is a flexible way to define the content of the message being sent,\n * as the keys can be customized to match the specific needs of the application,\n * and the values can be any valid JavaScript type.\n */\nexport type Payload = { [string: string]: any };\n\n/**\n * The Message interface is used to define the structure of a message that\n * is passed between two applications via a communication bridge.\n */\nexport interface Message {\n /**\n * Id of the message. Its autogenerated by the communication bridge\n */\n id: string;\n /**\n * Id of the message this message responds to.\n */\n respondingTo: string | null;\n /**\n * The source of message. Used to distinguish Monterosa SDK messages from other\n * broadcasted messages. In the future can be used for a more fine grade targeting\n */\n sourceName: Source | string;\n /**\n * The current timestamp in milliseconds\n */\n timestamp: number;\n /**\n * Defines the message action\n */\n action: Action | string;\n /**\n * Hash of key-value pairs. Values constrained by json format:\n * four primitive types (strings, numbers, booleans,\n * and null) and two structured types (objects and arrays).\n */\n payload: Payload;\n /**\n * Used to identify if the message belongs to the communication\n * bridge established between parent and child\n */\n bridgeId: string;\n /**\n * Message protocol version\n */\n version: string;\n}\n\n/**\n * @internal\n */\nexport interface Bridge extends Emitter {\n id: string;\n iFrameId: string;\n iFrameSelector: string;\n childIFrame: HTMLIFrameElement | null;\n send: (\n action: string,\n payload?: Payload,\n sourceName?: Source,\n id?: string,\n ) => Message;\n request: (\n action: string,\n payload?: Payload,\n timeout?: number,\n sourceName?: Source,\n ) => Promise<Message>;\n}\n\n/**\n * @internal\n */\nexport interface Bridged {\n bridge: Bridge;\n}\n\n/**\n * A list of possible actions in communications between\n * parent application and child Experience\n *\n * @internal\n */\nexport enum Action {\n /**\n * Notifies that communication channel is ready and\n * messages can be {@link sendSdkMessage | sent}\n */\n OnReady = 'onBridgeReady',\n /**\n * Notifies that intrisic size of child Experience has changed\n */\n OnResize = 'onIntrinsicSizeChanged',\n /**\n * Notifies that UI of child Experience is loaded.\n * When this action is fired the loader will be hidden\n */\n OnUILoaded = 'onUILoaded',\n /**\n * Notifies child Experience about the request to load more data\n */\n OnMoreDataRequested = 'onMoreDataRequested',\n}\n\n/**\n * @internal\n */\nexport enum Source {\n Sdk = 'sdk',\n User = 'user',\n}\n","/**\n * @license\n * types.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-01-19\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { Unsubscribe } from '@monterosa/sdk-util';\n\nimport { Bridged } from './utils/bridge/public_types';\n\n/**\n * Reserved query parameter names for controlling the behaviour of Experience.\n */\nexport enum QueryParam {\n /**\n * Represents the host of the application. This parameter is added by Studio\n * and the embed URL already contains it.\n */\n Host = 'h',\n /**\n * Represents the Project Id of the application. This parameter is added by\n * Studio and the embed URL already contains it.\n */\n Project = 'p',\n /**\n * Represents the Event Id of the application. This parameter is added to the\n * experience URL when the eventId is provided in the experience config.\n */\n Event = 'e',\n /**\n * Used to identify the unique ID of the communication bridge between\n * the parent application and the child experience.\n */\n BridgeId = 'micBridgeId',\n /**\n * Determines whether the header and footer views of the application should be\n * hidden. This parameter can be used to control the visibility of the\n * application's header and footer components.\n */\n HideHeaderAndFooter = 'micHideHeaderAndFooter',\n /**\n * Determines whether autoresize is enabled for the application. When autoresize\n * is enabled, the application's height will adjust automatically based on its\n * content.\n */\n AutoresizesHeight = 'micAutoresizesHeight',\n}\n\n/**\n * Interface of user Experience provided by the Monterosa / Interaction Cloud\n */\nexport interface Experience extends Bridged {\n /**\n * Instance of SDK\n *\n * @internal\n */\n sdk: MonterosaSdk;\n /**\n * Config\n */\n config: ExperienceConfiguration;\n /**\n * Generates the URL to use when embedding the experience by\n * reconciling multiple data sources:\n *\n * 1. The embed URL as specified in App spec and obtained via Listings\n *\n * 2. The `host` and `projectId` used to configure the SDK instance\n *\n * 3. The `experienceUrl` passed via {@link ExperienceConfiguration}\n *\n * 4. `host`, `projectId` and `eventId` parameters passed via {@link ExperienceConfiguration}\n *\n * 5. Custom `parameters` dictionary passed via {@link ExperienceConfiguration}\n *\n * To reconcile all of those data sources, the SDK . Also we protect\n * {@link QueryParam | reserved parameters} required for the functioning\n * of the SDK.\n *\n * This implies:\n *\n * - SDK will always prioritise using the values lower in the list above.\n *\n * - SDK {@link QueryParam | reserved parameters} will be stripped out from\n * embed URL, `experienceURL` and custom\n * {@link ExperienceConfiguration | parameters dictionary}.\n *\n * - `h`, `e`, `p` query parameters provided in custom parameters dictionary\n * will be ignored\n *\n * @returns the URL to use when embedding the Experience.\n */\n getUrl(): Promise<string>;\n}\n\n/**\n * Interface of parent application\n *\n * @remarks\n * Parent application is a reference to the parent window where Experience\n * resides. It is used to establish communication bridge between Experience and\n * parent application. It can be get with {@link getParentApplication}\n */\nexport interface ParentApplication extends Bridged {}\n\n/**\n * Experience configuration options\n */\nexport interface ExperienceConfiguration {\n /**\n * The user is able to override default experience URL. If its not empty,\n * default experience URL will be overwritten with the provided one. At the\n * same time URL query parameters will remain.\n */\n experienceUrl?: string | null;\n /**\n * Overrides the host portion of the resulting experience URL. This property\n * takes precedence over `experienceUrl`. For example, if `experienceUrl` is\n * \"https://example.com?h=h1\" and the `host` is set to \"h2\", the resulting URL\n * will be: https://example.com?h=h2\n */\n host?: string;\n /**\n * Overrides the project id portion of the resulting experience URL. This\n * property takes precedence over `experienceUrl`. For example,\n * if `experienceUrl` is \"https://example.com?p=p1\" and the `projectId` is\n * set to \"p2\", the resulting URL will be: https://example.com?p=p2\n */\n projectId?: string;\n /**\n * If event id is provided, Experience can automatically displays elements\n * associated with this event. It is worth to mention that the behaviour of\n * Experiences depend on their implementation and can vary.\n *\n * This property takes precedence over `experienceUrl`. For example, if\n * `experienceUrl` is \"https://example.com?e=e1\" and the `eventId` is set to\n * \"e2\", the resulting URL will be: https://example.com?e=e2\n */\n eventId?: string;\n /**\n * A key/value dictionary of custom parameters that will be passed on to the\n * embedded Experience as URL query parameter. There are several reserved\n * parameter keys: \"p\", \"h\", \"e\", \"micHideHeaderAndFooter\" and \"micBridgeId\".\n * When one of reserved keys is provided it will be ignored.\n */\n parameters?: { [key: string]: string };\n /**\n * If true the container adjusts its height according to the intrinsic\n * height of embedded Experience\n */\n autoresizesHeight?: boolean;\n /**\n * If true removes the headers and footers of embedded Experience,\n * so that the resulting UI does not display two headers/footers.\n */\n hidesHeadersAndFooters?: boolean;\n /**\n * The user is able to control wether loading state is enabled or disabled\n * using this property. By default, it is true meaning that the loading state\n * will be enabled.\n */\n supportsLoadingState?: boolean;\n /**\n * Loading template is a function that returns html markup which can be used\n * to substitute default loader UI. Make sure that the template is wrapped in\n * a single html element, e.g. `() => '<div>...loading...</div>'`\n */\n loadingTemplate?: () => string;\n /*\n * Defines a Permissions Policy for the <iframe>. This policy outlines the\n * available features for the <iframe> (e.g., access to the microphone,\n * camera, battery, web-share, etc.) based on the origin of the request.\n *\n * Additional information can be found at: https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy\n */\n allow?: string;\n /**\n * Set this to true to enable iframe's fullscreen mode compatibility with\n * older browsers.\n */\n allowFullScreen?: boolean;\n /**\n * Custom title for the iframe element. If provided, this title will be set\n * on the iframe's title attribute in the generated embed code.\n */\n title?: string;\n}\n\n/**\n * @internal\n */\nexport interface Integration {\n experience: Experience;\n controller: AbortController;\n resizeUnsubscribe?: Unsubscribe;\n storageUnsubscribe?: Unsubscribe;\n hooksUnsubscribe: Unsubscribe[];\n}\n\n/**\n * @internal\n */\nexport type EmbedHook = (\n experience: Experience,\n container: HTMLElement,\n) => Unsubscribe;\n","/**\n * @license\n * types.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2024-01-02\n * Copyright © 2024 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Defines a set of error codes that may be encountered when using the\n * Launcher Kit bridge\n *\n * @example\n * ```javascript\n * try {\n * // some code that uses the LauncherKit's bridge\n * } catch (err) {\n * if (err.code === BridgeError.InvalidRequestTimeoutError) {\n * // handle invalid request timeout error\n * } else {\n * // handle other error types\n * }\n * }\n * ```\n *\n * @remarks\n * - The `BridgeError` enum provides a convenient way to handle errors\n * encountered when using the `LauncherKit` module. By checking the code\n * property of the caught error against the values of the enum, the error\n * type can be determined and appropriate action taken.\n *\n * - The `BridgeError` enum is not intended to be instantiated or extended.\n */\nexport enum BridgeError {\n /**\n * Indicates an error occurred due to an invalid timeout value being provided.\n * This error is thrown when the specified timeout is not a positive number.\n */\n InvalidRequestTimeoutError = 'invalid_request_timeout_error',\n /**\n * Indicates a request timed out waiting for a response.\n * This error is thrown when a bridge request exceeds the specified timeout duration.\n */\n RequestTimeoutError = 'request_timeout_error',\n}\n\nexport const BridgeErrorMessages = {\n [BridgeError.InvalidRequestTimeoutError]: () =>\n 'Request timeout must be greater than 0',\n [BridgeError.RequestTimeoutError]: (action: string, timeout: number) =>\n `Request timeout: action \"${action}\" did not receive a response within ${timeout}ms`,\n};\n","/**\n * @license\n * config.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2024-01-02\n * Copyright © 2024 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { createError } from '@monterosa/sdk-util';\n\nimport { BridgeError, BridgeErrorMessages } from './types';\n\n/**\n * @internal\n */\nconst Config = {\n requestTimeout: 20_000,\n};\n\n/**\n * Sets a new timeout value for requests (default is 20_000 mseconds).\n *\n * This function updates the request timeout in the application's configuration.\n * It ensures that the new timeout value is a positive number, and throws\n * an error if the value is non-positive.\n *\n * @param newTimeout - The new timeout value in milliseconds. Must be\n * a positive number.\n *\n * @throws\n * Throws {@link BridgeError | BridgeError.InvalidRequestTimeoutError}\n * if `newTimeout` is less than or equal to 0.\n *\n * @example\n * ```javascript\n * // Set the request timeout to 3000 milliseconds\n * setRequestTimeout(3000);\n * ```\n */\nexport function setRequestTimeout(newTimeout: number) {\n if (newTimeout <= 0) {\n throw createError(\n BridgeError.InvalidRequestTimeoutError,\n BridgeErrorMessages,\n );\n }\n\n Config.requestTimeout = newTimeout;\n}\n\nexport default Config;\n","/**\n * @license\n * helpers.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Message } from './public_types';\n\nexport function isMessage(message: Message | any): message is Message {\n return (\n message instanceof Object &&\n Object.prototype.hasOwnProperty.call(message, 'bridgeId')\n );\n}\n","/**\n * @license\n * sideeffect.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/* eslint no-console: \"off\" */\n\nimport { Emitter, getGlobal, getErrorMessage } from '@monterosa/sdk-util';\n\nimport { isMessage } from './helpers';\n\nconst globals = getGlobal();\n\nconst receiveMessage = (message: any) => {\n if (!isMessage(message)) {\n // data does not match message format\n return;\n }\n\n globals.monterosaSdk!.emitter.emit('message', message);\n};\n\nfunction handleWindowMessage({ data }: MessageEvent) {\n try {\n if (typeof data !== 'string') {\n // ignore non string data\n return;\n }\n\n const message = JSON.parse(data);\n\n receiveMessage(message);\n } catch (err) {\n console.error(getErrorMessage(err));\n }\n}\n\n/**\n * Since this code operates as a side effect while updating the global space,\n * we must be very careful because it may run twice, for example, when two apps\n * using the SDK run on the same page. Additionally, the global namespace may\n * already be updated by the Android or iOS SDKs.\n */\n\n// The Monterosa SDK namespace may already exist, either because it was created\n// by a native SDK or by another web app using the JS SDK from the same scope.\nglobals.monterosaSdk ??= {\n initialised: false,\n emitter: new Emitter(),\n receiveMessage,\n};\n\n// Each of nullish coalescing assignments will only be applied when\n// the Monterosa SDK namespace exists at that moment and one of its properties\n// is not defined.\nglobals.monterosaSdk.initialised ??= false;\nglobals.monterosaSdk.emitter ??= new Emitter();\nglobals.monterosaSdk.receiveMessage ??= receiveMessage;\n\nif (!globals.monterosaSdk.initialised) {\n // Subscribe to the message only once for each app that uses the SDK on this page.\n if (typeof globals.addEventListener !== 'undefined') {\n globals.addEventListener('message', handleWindowMessage);\n }\n\n globals.monterosaSdk.initialised = true;\n}\n","/**\n * @license\n * constants.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getGlobal } from '@monterosa/sdk-util';\n\nconst globals = getGlobal();\n\n/**\n * @internal\n */\nexport const IFRAME_ID_PREFIX = 'micBridge';\n\nexport const IS_IOS =\n !!globals.webkit?.messageHandlers?.monterosaSdk?.postMessage;\nexport const IS_ANDROID = !!globals.monterosaSdk?.postMessage;\nexport const IS_WEB = globals.self !== globals.parent;\n\n/**\n * @internal\n */\nexport const VERSION = '1.0.0';\n","/**\n * @license\n * bridge_impl.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { getGlobal, Emitter, createError } from '@monterosa/sdk-util';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport './sideeffects';\n\nimport { Message, Bridge, Payload, Source } from './public_types';\nimport {\n IFRAME_ID_PREFIX,\n VERSION,\n IS_IOS,\n IS_WEB,\n IS_ANDROID,\n} from './constants';\nimport Config from './config';\nimport { BridgeError, BridgeErrorMessages } from './types';\n\nimport { logger } from '../../logger';\n\nconst globals = getGlobal();\n\n/**\n * @internal\n */\nclass BridgeImpl extends Emitter implements Bridge {\n constructor(public id: string = uuidv4()) {\n super();\n\n globals.monterosaSdk!.emitter.on('message', this.handleMessage.bind(this));\n }\n\n static isMessage(message: Message | any): message is Message {\n return (\n message instanceof Object &&\n Object.prototype.hasOwnProperty.call(message, 'bridgeId') &&\n Object.prototype.hasOwnProperty.call(message, 'action')\n );\n }\n\n get iFrameId(): string {\n return `${IFRAME_ID_PREFIX}-${this.id}`;\n }\n\n get iFrameSelector(): string {\n return `iframe#${this.iFrameId}`;\n }\n\n get childIFrame(): HTMLIFrameElement | null {\n return document.querySelector(this.iFrameSelector);\n }\n\n private handleMessage(message: Message) {\n if (message.bridgeId === this.id) {\n logger.log(\n `Received a ${message.respondingTo === null ? 'message' : 'response'}`,\n message,\n );\n\n this.emit('message', message);\n }\n }\n\n private createMessage(\n action: string,\n payload: Payload,\n sourceName: Source,\n respondingTo: string | null = null,\n ): Message {\n return {\n id: uuidv4(),\n respondingTo,\n action,\n sourceName,\n\n bridgeId: this.id,\n\n payload,\n version: VERSION,\n timestamp: Date.now(),\n };\n }\n\n postMessage(message: Message) {\n const json = JSON.stringify(message);\n\n if (IS_IOS) {\n globals.webkit?.messageHandlers?.monterosaSdk.postMessage(json);\n }\n\n if (IS_ANDROID) {\n if (globals.monterosaSdk?.postMessage) {\n globals.monterosaSdk.postMessage(json);\n }\n }\n\n if (IS_WEB) {\n globals.parent.postMessage(json, '*');\n }\n\n if (this.childIFrame) {\n this.childIFrame.contentWindow?.postMessage(json, '*');\n }\n }\n\n send(\n action: string,\n payload: Payload = {},\n sourceName = Source.Sdk,\n respondingTo?: string,\n ): Message {\n const message = this.createMessage(\n action,\n payload,\n sourceName,\n respondingTo,\n );\n\n logger.log(\n `Sending a ${message.respondingTo === null ? 'message' : 'response'}`,\n message,\n );\n\n this.postMessage(message);\n\n return message;\n }\n\n async request(\n action: string,\n payload: Payload = {},\n timeout: number = Config.requestTimeout,\n sourceName = Source.Sdk,\n ): Promise<Message> {\n let timeoutRef: ReturnType<typeof setTimeout>;\n let handler: (message: Message) => void;\n\n const message = this.createMessage(action, payload, sourceName);\n\n logger.log('Sending a request', message);\n\n /**\n * Start the timeout, when it finishes it should reject Promise.race below\n */\n const countdown: Promise<any> = new Promise((_, reject) => {\n timeoutRef = setTimeout(() => {\n reject(\n createError(\n BridgeError.RequestTimeoutError,\n BridgeErrorMessages,\n action,\n timeout,\n ),\n );\n }, timeout);\n });\n\n /**\n * Start the request and wait for the message with the respondingTo\n * equal to message id we sent\n */\n const request: Promise<Message> = new Promise((resolve) => {\n handler = (responseMessage: Message) => {\n if (responseMessage.respondingTo === message.id) {\n resolve(responseMessage);\n }\n };\n\n globals.monterosaSdk!.emitter.on('message', handler);\n\n this.postMessage(message);\n });\n\n /**\n * Start race between timeout and request\n * - if timeout wins the promise will be rejected\n * - if request wins then Message will be resolved\n */\n\n return (\n Promise.race([countdown, request])\n /**\n * As the matter of clean up we need to clear timeout id\n * and unsubscribe from the message event\n */\n .finally(() => {\n clearTimeout(timeoutRef);\n globals.monterosaSdk!.emitter.off('message', handler);\n })\n );\n }\n}\n\nexport default BridgeImpl;\n","/**\n * @license\n * api.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, subscribe } from '@monterosa/sdk-util';\n\nimport { Bridge, Bridged, Message, Source, Payload } from './public_types';\n\nimport { QueryParam } from '../../types';\n\nimport Config from './config';\nimport BridgeImpl from './bridge_impl';\n\nlet parentBridge: Bridge;\n\nconst bridges: Map<string, BridgeImpl> = new Map();\n\n/**\n * @internal\n */\nexport function getBridge(id: string): BridgeImpl {\n if (bridges.has(id)) {\n return bridges.get(id) as BridgeImpl;\n }\n\n const bridge = new BridgeImpl();\n\n bridges.set(id, bridge);\n\n return bridge;\n}\n\n/**\n * @internal\n */\nexport function getParentBridge(): Bridge | null {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (parentBridge !== undefined) {\n return parentBridge;\n }\n\n const url = new URL(window.location.href);\n\n const bridgeId = url.searchParams.get(QueryParam.BridgeId);\n\n if (bridgeId === null) {\n return null;\n }\n\n parentBridge = new BridgeImpl(bridgeId);\n\n return parentBridge;\n}\n\n/**\n * @internal\n */\nexport function sendSdkMessage(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n) {\n return bridged.bridge.send(action, payload, Source.Sdk);\n}\n\n/**\n * This function allows to send a simple message with action name and payload to\n * a recipient which can be either parent application (from Experience to parent\n * application) or child Experience (from parent page to Experience).\n *\n * @remarks\n * Usage example in parent application:\n *\n * @example\n * ```typescript\n * const experience = getExperience();\n *\n * // message to Experience can be sent only when its ready\n * onUILoaded(experience, async () => {\n * sendMessage(\n * experience,\n * 'my_action',\n * { key: 'value' }\n * );\n * });\n *\n * embed(experience);\n * ```\n *\n * Usage example in child Experience:\n *\n * @example\n * ```typescript\n * const parentApp = getParentApplication();\n *\n * if (parentApp !== null) {\n * sendMessage(\n * parentApp,\n * 'my_action',\n * { key: 'value' }\n * );\n * }\n * ```\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param action - Arbitrary action name that defines purpose of the message\n * @param payload - A key-value object that is sent in a message\n * @returns Returns {@link Message | message}\n */\nexport function sendMessage(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n) {\n return bridged.bridge.send(action, payload, Source.User);\n}\n\n/**\n * @internal\n */\nexport function sendSdkRequest(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n timeout = Config.requestTimeout,\n) {\n return bridged.bridge.request(action, payload, timeout, Source.Sdk);\n}\n\n/**\n * This function allows to send a request with action name and payload to\n * a recipient which can be either parent application (from Experience to parent\n * application) or child Experience (from parent page to Experience). It is similar\n * to {@link sendMessage} with only one difference is that it returns a Promise which\n * resolves if the recipient response with {@link respondToMessage}. Otherwise it\n * will rejects after a certain timeout.\n *\n * @remarks\n * Usage example in parent application:\n *\n * @example\n * ```typescript\n * const experience = getExperience();\n *\n * // request to Experience can be sent only when its ready\n * onUILoaded(experience, async () => {\n * const response = await sendRequest(\n * experience,\n * 'my_action',\n * { key: 'value' }\n * );\n *\n * console.log(response);\n * });\n *\n * embed(experience);\n * ```\n *\n * Usage example in child Experience:\n *\n * @example\n * ```typescript\n * const parentApp = getParentApplication();\n *\n * // parent application can be null if Experience is running stand alone\n * if (parentApp !== null) {\n * const response = await sendRequest(\n * parentApp,\n * 'my_action',\n * { key: 'value' }\n * );\n *\n * console.log(response);\n * }\n * ```\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param action - Arbitrary action name that defines purpose of the message\n * @param payload - A key-value object that is sent as in request\n * @param timeout - Configurable request timeout, if there is no response by\n * the end of this timeout then returned Promise will be rejected.\n */\nexport function sendRequest(\n bridged: Bridged,\n action: string,\n payload: Payload = {},\n timeout = Config.requestTimeout,\n) {\n return bridged.bridge.request(action, payload, timeout, Source.User);\n}\n\n/**\n * @internal\n */\nexport function respondToSdkMessage(\n bridged: Bridged,\n message: Message,\n payload: Payload = {},\n) {\n bridged.bridge.send(message.action, payload, Source.Sdk, message.id);\n}\n\n/**\n * Respond to a received message. It is used to reply to a\n * {@link sendRequest | user request}.\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param message - {@link Message | Message} to respond to\n * @param payload - A key-value object that is sent as in response\n */\nexport function respondToMessage(\n bridged: Bridged,\n message: Message,\n payload: Payload = {},\n) {\n bridged.bridge.send(message.action, payload, Source.User, message.id);\n}\n\nfunction onMessageFunc(\n bridged: Bridged,\n source: Source,\n callback: (message: Message) => void,\n) {\n return subscribe(bridged.bridge, 'message', (message: Message) => {\n if (message.sourceName === source) {\n callback(message);\n }\n });\n}\n\n/**\n * @internal\n */\nexport function onSdkMessage(\n bridged: Bridged,\n callback: (message: Message) => void,\n): Unsubscribe {\n return onMessageFunc(bridged, Source.Sdk, callback);\n}\n\n/**\n * Adds an observer for when user message is received\n *\n * @param bridged - Instance of either {@link ParentApplication} or {@link Experience}\n * @param callback - The callback that is triggered when user message is received\n * @returns The unsubscribe function. When it's called,\n * the observer will be removed and user messages will no longer be received\n */\nexport function onMessage(\n bridged: Bridged,\n callback: (message: Message) => void,\n): Unsubscribe {\n return onMessageFunc(bridged, Source.User, callback);\n}\n","/**\n * @license\n * experience_impl.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-01-19\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk } from '@monterosa/sdk-core';\nimport { fetchListings } from '@monterosa/sdk-interact-interop';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { QueryParam, Experience, ExperienceConfiguration } from './types';\nimport { getBridge, Bridge } from './utils/bridge';\n\n/**\n * @internal\n */\nexport class ExperienceImpl implements Experience {\n readonly _config: Readonly<ExperienceConfiguration>;\n private _parameters: { [key: string]: string } = {};\n readonly bridge: Bridge;\n embedUrl!: string;\n\n constructor(public sdk: MonterosaSdk, config: ExperienceConfiguration) {\n this._config = config;\n this.bridge = getBridge(uuidv4());\n\n if (config.parameters !== undefined) {\n const reserved = Object.values(QueryParam) as string[];\n const ignored: string[] = [];\n\n Object.entries(config.parameters).forEach(([key, value]) => {\n if (reserved.includes(key)) {\n ignored.push(key);\n } else {\n this._parameters[key] = value;\n }\n });\n\n if (ignored.length === 1) {\n console.warn(\n `Parameter \"${ignored[0]}\" ignored as it matches reserved words`,\n );\n }\n\n if (ignored.length > 1) {\n console.warn(\n `Parameters \"${ignored.join(\n '\", \"',\n )}\" ignored as they match reserved words`,\n );\n }\n }\n }\n\n get config() {\n return Object.assign(this._config, {\n autoresizesHeight: this._config.autoresizesHeight ?? false,\n hidesHeadersAndFooters: this._config.hidesHeadersAndFooters ?? true,\n supportsLoadingState: this._config.supportsLoadingState ?? true,\n experienceUrl: this._config.experienceUrl ?? null,\n });\n }\n\n async getEmbedUrl() {\n if (this.embedUrl) {\n return Promise.resolve(this.embedUrl);\n }\n\n const {\n options: { host, projectId },\n } = this.sdk;\n\n const listings = await fetchListings(host, projectId);\n\n this.embedUrl = listings.project.embed;\n\n return this.embedUrl;\n }\n\n async getUrl(): Promise<string> {\n const embedUrl = await this.getEmbedUrl();\n\n // sanitise and create an object from an url\n let url = new URL(ExperienceImpl.sanitiseUrl(embedUrl));\n\n // override host and project with those that are set in SDK instance\n url.searchParams.set(QueryParam.Host, this.sdk.options.host);\n url.searchParams.set(QueryParam.Project, this.sdk.options.projectId);\n\n // if custom experienceUrl is set:\n // * take experienceUrl as the base\n // * search params from experienceUrl have priority\n if (this.config.experienceUrl !== null) {\n // sanitise and create an object from a custom url\n const customUrl = new URL(\n ExperienceImpl.sanitiseUrl(this.config.experienceUrl),\n );\n\n // apply embedUrl query parameters if they don't exist in experienceUrl\n Array.from(url.searchParams.entries())\n .filter(([key]) => !customUrl.searchParams.has(key))\n .forEach(([key, value]) => customUrl.searchParams.set(key, value));\n\n url = customUrl;\n }\n\n // Prepare a final list of query parameters\n const queryParameters = {\n ...(this.config.host !== undefined && {\n [QueryParam.Host]: this.config.host,\n }),\n\n ...(this.config.projectId !== undefined && {\n [QueryParam.Project]: this.config.projectId,\n }),\n\n ...(this.config.eventId !== undefined && {\n [QueryParam.Event]: this.config.eventId,\n }),\n\n [QueryParam.BridgeId]: this.bridge.id,\n\n [QueryParam.HideHeaderAndFooter]: this.config.hidesHeadersAndFooters\n ? '1'\n : '0',\n\n [QueryParam.AutoresizesHeight]: this.config.autoresizesHeight ? '1' : '0',\n\n // Adding user defined parameters to the URL search parameters if exists\n ...this._parameters,\n };\n\n Object.entries(queryParameters).forEach(([key, value]) => {\n url.searchParams.set(key, value);\n });\n\n return url.href;\n }\n\n private static sanitiseUrl(\n url: string,\n options?: {\n stripReservedParameters?: 'all' | 'mic';\n },\n ): string {\n const stripReservedParameters = options?.stripReservedParameters || 'mic';\n\n // Ensure the URL includes a protocol.\n if (/^http/.test(url) === false) {\n // If none are found, use the same as the document.\n url = `${document.location.protocol}${url}`;\n }\n\n const urlObj = new URL(url);\n\n Object.values(QueryParam)\n .filter((key) => {\n if (stripReservedParameters === 'mic') {\n return key.startsWith('mic');\n }\n\n return key;\n })\n .forEach((key) => urlObj.searchParams.delete(key));\n\n return urlObj.href;\n }\n}\n","/**\n * @license\n * loader.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-08-04\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { delay } from '@monterosa/sdk-util';\n\nimport { LOADER_ANIMATION_DURATION, DEFAULT_HEIGHT } from './constants';\n\n/* eslint-disable */\ntype CSSProperties = keyof Omit<\n CSSStyleDeclaration,\n | typeof Symbol.iterator\n | number\n | 'length'\n | 'parentRule'\n | 'getPropertyPriority'\n | 'getPropertyValue'\n | 'item'\n | 'removeProperty'\n | 'setProperty'\n>;\n/* eslint-enable */\n\nfunction getLoadingTemplate(): string {\n return `\n <div>\n <style type=\"text/css\">\n .__mic-loader {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 9;\n box-sizing: border-box;\n text-align: center;\n background: #fff;\n }\n\n .__mic-loader__container {\n padding: 20px 0;\n gap: 20px;\n min-height: ${DEFAULT_HEIGHT}px;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .__mic-loader__spinner {\n position: relative;\n width: 10px;\n height: 10px;\n border-radius: 5px;\n background-color: #0b0f1c;\n color: #0b0f1c;\n animation: mic-loader__animation 1s infinite linear alternate;\n animation-delay: 0.5s; \n }\n\n .__mic-loader__spinner::before,\n .__mic-loader__spinner::after {\n content: \"\";\n display: inline-block;\n position: absolute;\n top: 0;\n }\n\n .__mic-loader__spinner::before {\n left: -15px;\n width: 10px;\n height: 10px;\n border-radius: 5px;\n background-color: #0b0f1c;\n color: #0b0f1c;\n animation: mic-loader__animation 1s infinite alternate;\n animation-delay: 0s;\n }\n\n .__mic-loader__spinner::after {\n left: 15px;\n width: 10px;\n height: 10px;\n border-radius: 5px;\n background-color: #0b0f1c;\n color: #0b0f1c;\n animation: mic-loader__animation 1s infinite alternate;\n animation-delay: 1s;\n }\n\n @keyframes mic-loader__animation {\n 0% {\n background-color: #0b0f1c;\n }\n 50%, 100% {\n background-color: rgba(11, 15, 28, 0.2);\n }\n }\n </style>\n <div class=\"__mic-loader\">\n <div class=\"__mic-loader__container\">\n <div class=\"__mic-loader__spinner\"></div>\n </div>\n </div>\n </div>\n `;\n}\n\nexport function embed(\n container: HTMLElement,\n loadingTemplate: () => string = getLoadingTemplate,\n): HTMLElement {\n /**\n * Return existing element if it exists\n */\n let loaderElement: HTMLElement | null =\n container.querySelector('[data-role=loader]');\n\n if (loaderElement !== null) {\n return loaderElement;\n }\n\n /**\n * Stash and apply some custom styles to container element\n */\n stashStyles(container, ['minHeight', 'position']);\n\n container.style.minHeight = `${DEFAULT_HEIGHT}px`;\n\n /**\n * Inject loader element built from the html markup template\n */\n const templateElement = document.createElement('template');\n templateElement.innerHTML = loadingTemplate().trim();\n\n loaderElement = container.appendChild(\n templateElement.content.firstElementChild as Element,\n ) as HTMLElement;\n\n /**\n * Setting custom data attribute to be able to distinguish element along\n * other injected html elements if any\n */\n loaderElement.setAttribute('data-role', 'loader');\n\n return loaderElement;\n}\n\nexport function unmount(container: HTMLElement): void {\n const loaderElement = container.querySelector('[data-role=loader]');\n\n if (loaderElement === null) {\n return;\n }\n\n loaderElement.parentElement?.removeChild(loaderElement);\n\n unstashStyles(container);\n}\n\nexport async function show(\n container: HTMLElement,\n loadingTemplate: () => string = getLoadingTemplate,\n): Promise<void> {\n const loaderElement = embed(container, loadingTemplate);\n\n const { position } = getComputedStyle(container);\n\n /**\n * In order to properly position the loader,\n * the container's position should be anything but 'static'.\n */\n if (position === 'static') {\n container.style.position = 'relative';\n }\n\n /**\n * Setting styles to the loader for a nice fade in animation\n */\n loaderElement.style.opacity = '0';\n\n /**\n * Kicking fade animation in.\n */\n setTimeout(() => {\n loaderElement.style.transition = `all ${LOADER_ANIMATION_DURATION}ms`;\n loaderElement.style.opacity = '1';\n }, 0);\n\n /**\n * Wait until the animation is finished. We do not use \"transitionend\" event\n * here as it will just make the code more bloated and unnecessary complex.\n */\n await delay(LOADER_ANIMATION_DURATION);\n}\n\nexport async function hide(container: HTMLElement): Promise<void> {\n const loaderElement: HTMLElement | null =\n container.querySelector('[data-role=loader]');\n\n if (loaderElement === null) {\n return;\n }\n\n /**\n * Kicking fade out animation.\n */\n setTimeout(() => {\n loaderElement.style.opacity = '0';\n }, 0);\n\n /**\n * Wait until the animation is finished. We do not use \"transitionend\" event\n * here as it will just make the code more bloated and unnecessary complex.\n */\n await delay(LOADER_ANIMATION_DURATION);\n\n unstashStyles(container);\n unmount(container);\n}\n\nfunction stashStyles(element: HTMLElement, props: CSSProperties[]) {\n const styles = getComputedStyle(element);\n\n const stash = props\n .map((prop) => `${String(prop)}=${styles[prop]}`)\n .join(';');\n\n element.setAttribute('data-stash', stash);\n}\n\nfunction unstashStyles(element: HTMLElement) {\n const stash = element.getAttribute('data-stash');\n\n if (stash === null) {\n return;\n }\n\n const attributes: [attr: CSSProperties, value: string][] = stash\n .split(';')\n .map((attr) => attr.split('=') as [attr: CSSProperties, value: string]);\n\n for (const [attr, value] of attributes) {\n element.style[attr] = value;\n }\n\n element.removeAttribute('data-stash');\n}\n","/**\n * @license\n * api.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-02-15\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { MonterosaSdk, Sdk, getSdk, LogLevel } from '@monterosa/sdk-core';\nimport { Unsubscribe, delay } from '@monterosa/sdk-util';\n\nimport {\n Experience,\n ExperienceConfiguration,\n Integration,\n EmbedHook,\n} from './types';\n\nimport { LOADER_TIMEOUT, LOADER_BUMPER_TIMEOUT } from './constants';\n\nimport { logger } from './logger';\n\nimport { sendSdkMessage, onSdkMessage, Action } from './utils/bridge';\n\nimport { ExperienceImpl } from './experience_impl';\n\nimport { show as showLoader, hide as hideLoader } from './loader';\n\nimport { version } from '../package.json';\n\n/**\n * The current SDK version.\n *\n * @internal\n */\nexport const VERSION = version;\n\nconst integrations: Map<HTMLElement, Integration> = new Map();\nconst embedHooks: EmbedHook[] = [];\n\n/**\n * Creates an iframe with the provided parameters.\n *\n * @param url Url of the web app.\n *\n * @private\n */\nfunction createIFrame(\n url: string,\n options: {\n id?: string;\n scrolling?: boolean;\n allow?: string;\n allowFullScreen?: boolean;\n title?: string;\n } = {},\n): HTMLIFrameElement {\n const iframe = document.createElement('iframe');\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.border = '0';\n iframe.style.display = 'block';\n iframe.style.boxSizing = 'border-box';\n\n iframe.setAttribute('src', url);\n\n if (options.id !== undefined) {\n iframe.setAttribute('id', options.id);\n }\n\n if (options.allow !== undefined) {\n iframe.setAttribute('allow', options.allow);\n }\n\n if (options.allowFullScreen === true) {\n iframe.setAttribute('allowfullscreen', '');\n }\n\n if (options.title !== undefined) {\n iframe.setAttribute('title', options.title);\n }\n\n /**\n * Though scrolling attribute is deprecated we still have to rely on it as some\n * browsers (e.g. Chrome, as of now version 103) just ignores overflow: hidden.\n * Hence we are setting scrolling to no in order to eliminate scroll and calculate\n * width of the child Experience correctly. If scroll persists it appears on each\n * content change what leads to incorrect width calculation.\n *\n * Later we will look into alternatives such as iframeless Experience embed\n */\n if (!options.scrolling) {\n iframe.style.overflow = 'hidden';\n iframe.setAttribute('scrolling', 'no');\n }\n\n return iframe;\n}\n\nfunction concealIFrame(iframe: HTMLIFrameElement) {\n iframe.style.opacity = '0';\n}\n\nfunction revealIFrame(iframe: HTMLIFrameElement) {\n iframe.style.opacity = '1';\n}\n\nfunction isSdk(value: MonterosaSdk | any): value is MonterosaSdk {\n return value instanceof Sdk;\n}\n\n/**\n * Returns Experience for the default given sdk\n *\n * @param config - Optional config\n */\nexport function getExperience(config?: ExperienceConfiguration): Experience;\n\n/**\n * Returns Experience for the given sdk\n *\n * @param sdk - Optional project instance whose Experience to return.\n * if no project is provided, it will attempt to use the default one\n * @param config - Optional config\n */\nexport function getExperience(\n sdk?: MonterosaSdk,\n config?: ExperienceConfiguration,\n): Experience;\n\nexport function getExperience(\n sdkOrConfig?: MonterosaSdk | ExperienceConfiguration,\n config?: ExperienceConfiguration,\n): Experience {\n let sdk: MonterosaSdk;\n let experienceConfig: ExperienceConfiguration;\n\n if (isSdk(sdkOrConfig)) {\n /**\n * Interface: getExperience(sdk, config?)\n */\n\n sdk = sdkOrConfig;\n\n if (config !== undefined) {\n experienceConfig = config;\n } else {\n experienceConfig = {};\n }\n } else if (sdkOrConfig !== undefined) {\n /**\n * Interface: getExperience(config)\n */\n\n sdk = getSdk();\n experienceConfig = sdkOrConfig;\n } else {\n /**\n * Interface: getExperience()\n */\n\n sdk = getSdk();\n experienceConfig = {};\n }\n\n const experience = new ExperienceImpl(sdk, experienceConfig);\n\n return experience;\n}\n\nfunction onResize(experience: Experience, container: HTMLElement): Unsubscribe {\n if (!experience.config.autoresizesHeight) {\n return () => {};\n }\n\n return onSdkMessage(experience, ({ action, payload }) => {\n if (action === Action.OnResize) {\n /**\n * Container width is maintained the same as it is defined in the parent\n * page to preserve its behaviour. Only the height is updated\n */\n // container.style.width = `${payload.width}px`;\n container.style.height = `${payload.height}px`;\n }\n });\n}\n\nfunction onUILoaded(experience: Experience): Promise<void> {\n return new Promise((resolve) => {\n const unsubscribe = onSdkMessage(experience, ({ action }) => {\n if (action === Action.OnUILoaded) {\n unsubscribe();\n resolve();\n }\n });\n });\n}\n\nasync function experienceReady(experience: Experience) {\n /**\n * Bumper delay during which loading state can't be hidden even\n * if Experience loaded earlier than timer reached bumper timeout\n */\n const bumper = delay(LOADER_BUMPER_TIMEOUT);\n\n /**\n * Final cut off timeout delay after which loading state must\n * be hidden even if Experience is still loading\n */\n const timeout = delay(LOADER_TIMEOUT);\n\n /**\n * Promisifying OnUILoaded communication bridge event\n */\n const loaded = onUILoaded(experience);\n\n const hasFullyLoadedExperience = Promise.all([bumper, loaded]);\n\n const eitherTimeoutOrFullyLoaded = Promise.race([\n timeout,\n hasFullyLoadedExperience,\n ]);\n\n return eitherTimeoutOrFullyLoaded;\n}\n\n/**\n * Embeds web Experience app into iframe. There is only one app can be\n * associated with Experience and it is configured in\n * Monterosa / Interaction Cloud. Please refer the developer guide to get\n * more information on what is app and how to configure it:\n * {@link https://products.monterosa.co/mic/developer-guides/whats-an-app}\n *\n * @example\n * ```javascript\n * const experience = getExperience();\n *\n * embed(experience, 'container-id');\n * ```\n * @param {Experience} - An instance of Experience\n * @param {HTMLElement | string} containerOrId - HTML element instance or\n * element id where iframe is embedded into.\n *\n * @public\n */\nexport async function embed(\n experience: Experience,\n containerOrId: HTMLElement | string,\n): Promise<void> {\n const container =\n containerOrId instanceof HTMLElement\n ? containerOrId\n : document.getElementById(containerOrId);\n\n if (container === null) {\n throw new Error(\n `Container element with id \"${containerOrId}\" doesn't exist in DOM`,\n );\n }\n\n if (integrations.has(container)) {\n return;\n }\n\n const controller = new AbortController();\n const hooksUnsubscribe: Unsubscribe[] = [];\n\n integrations.set(container, {\n experience,\n controller,\n hooksUnsubscribe,\n });\n\n if (experience.config.supportsLoadingState === true) {\n // Although showLoader is an asynchronous function, we execute\n // it synchronously to embed the iframe as quickly as possible.\n showLoader(container, experience.config.loadingTemplate);\n }\n\n for (const hook of embedHooks) {\n const unsub = hook(experience, container);\n\n hooksUnsubscribe.push(unsub);\n }\n\n const url = await experience.getUrl();\n\n if (controller.signal.aborted) {\n return;\n }\n\n const iframe = createIFrame(url, {\n id: experience.bridge.iFrameId,\n scrolling: !experience.config.autoresizesHeight,\n allow: experience.config.allow,\n allowFullScreen: experience.config.allowFullScreen,\n title: experience.config.title,\n });\n\n container.appendChild(iframe);\n\n concealIFrame(iframe);\n\n await experienceReady(experience);\n\n if (controller.signal.aborted) {\n return;\n }\n\n revealIFrame(iframe);\n\n if (experience.config.supportsLoadingState === true) {\n await hideLoader(container);\n }\n}\n\n/**\n * Unmounts web Experience app which was previously embedded in the container.\n *\n * @example\n * ```javascript\n * unmount('container-id');\n * ```\n *\n * @param {HTMLElement | string} containerOrId - HTML element instance or\n * element id where iframe is embedded into.\n *\n * @public\n */\nexport function unmount(containerOrId: HTMLElement | string): void {\n const container =\n containerOrId instanceof HTMLElement\n ? containerOrId\n : document.getElementById(containerOrId);\n\n if (container === null) {\n throw new Error(\n `Container element with id \"${containerOrId}\" doesn't exist in DOM`,\n );\n }\n\n const integration = integrations.get(container);\n\n if (!integration) {\n return;\n }\n\n integration.controller.abort();\n\n for (const unsub of integration.hooksUnsubscribe) {\n unsub();\n }\n\n while (container.lastElementChild) {\n container.removeChild(container.lastElementChild);\n }\n\n integrations.delete(container);\n\n container.style.height = '';\n}\n\n/**\n * Informs the Experience that more data should be loaded and displayed on the UI.\n *\n * @remarks\n * One example is when Experience renders items feed partially. Once a user scrolled\n * to the bottom edge of the app, more elements to load is requested.\n *\n * @param experience - Experience instance\n */\nexport function requestMoreData(experience: Experience): void {\n sendSdkMessage(experience, Action.OnMoreDataRequested);\n}\n\n/**\n * @internal\n */\nexport function registerEmbedHook(hook: EmbedHook) {\n embedHooks.push(hook);\n}\n\n/**\n * Enables logging with the specified log level.\n *\n * @param logLevel - The log level or flag to determine the logging\n * behavior. If a log level is provided, it will be used to set the log\n * level. If a boolean flag is provided, logging will be enabled or disabled\n * based on the flag value.\n */\nexport function enableLogging(logLevel?: LogLevel): void;\n\n/**\n * Enables or disables logging based on the provided flag.\n *\n * @param enable - The flag to determine the logging behavior. If a boolean flag\n * is provided, logging will be enabled or disabled based on the flag value.\n */\nexport function enableLogging(enable?: boolean): void;\n\nexport function enableLogging(logLevelOrFlag: LogLevel | boolean = true) {\n if (typeof logLevelOrFlag === 'boolean') {\n logger.logLevel = logLevelOrFlag ? LogLevel.Verbose : LogLevel.Silent;\n\n return;\n }\n\n logger.logLevel = logLevelOrFlag;\n}\n\nregisterEmbedHook(onResize);\n","/**\n * @license\n * parent_application_impl.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2022-07-12\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Bridge } from './utils/bridge';\nimport { ParentApplication } from './types';\n\n/**\n * @internal\n */\nexport class ParentApplicationImpl implements ParentApplication {\n constructor(public bridge: Bridge) {}\n}\n","/**\n * @license\n * parent_application.ts\n * launcher-kit\n *\n * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-15\n * Copyright © 2023 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { ParentApplication } from './types';\n\nimport { ParentApplicationImpl } from './parent_application_impl';\n\nimport { getParentBridge } from './utils/bridge';\n\nlet parentApplication: ParentApplication;\n\n/**\n * Returns instance of parent application.\n *\n * @returns Returns {@link ParentApplication}\n * if an Experience resides within the parent application, and it was embedded\n * using {@link embed} function. Otherwise it returns `null`.\n */\nexport function getParentApplication(): ParentApplication | null {\n if (parentApplication !== undefined) {\n return parentApplication;\n }\n\n const parentBridge = getParentBridge();\n\n if (parentBridge === null) {\n return null;\n }\n\n parentApplication = new ParentApplicationImpl(parentBridge);\n\n return parentApplication;\n}\n","/**\n * @license\n * child_helpers.ts\n * launcher-kit\n *\n * Created by Josep Rodriguez <josep.rodriguez@monterosa.co.uk> on 2022-07-13\n * Copyright © 2022 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, throttle } from '@monterosa/sdk-util';\n\nimport { RESIZE_THROTTLE_TIMEOUT } from './constants';\n\nimport { QueryParam, Experience } from './types';\n\nimport { getParentApplication } from './parent_application';\nimport { sendSdkMessage, onSdkMessage, Action } from './utils/bridge';\n\nfunction getUrlParam(param: string) {\n let queryString = {};\n\n if (typeof window !== 'undefined') {\n queryString = window.location.search;\n }\n\n const urlParams = new URLSearchParams(queryString);\n\n return urlParams.get(param);\n}\n\n/**\n * The SDK on the parent application will by default request a child\n * Experience to hide its header and footer by setting a query parameter called\n * `micHideHeaderAndFooter` to `1`.\n *\n * This function will return true if that is the case, and false otherwise.\n *\n * When true, the developer of a child Experience is expected to hide it's headers\n * and footers as the parent application is actively providing them.\n *\n * You can test whether you are respecting this correctly by adding the following query\n * to your URL:\n *\n * \"?micHideHeaderAndFooter=1\"\n *\n * @returns Whether the header and footer views should be hidden.\n */\nexport function shouldHideHeaderAndFooter() {\n return getUrlParam(QueryParam.HideHeaderAndFooter) === '1';\n}\n\n/**\n * This function will returns true if experience is embedded in autoresize height mode.\n */\nexport function isAutoresizesHeight() {\n return getUrlParam(QueryParam.AutoresizesHeight) === '1';\n}\n\n/**\n * This function is used to notify the parent application that the Experience\n * is ready to be used. It's intended to be called by the Experience itself and\n * not by the parent application.\n *\n * @example\n * ```javascript\n * import { sendReady } from '@monterosa/sdk-launcher-kit';\n *\n * sendReady();\n * ```\n *\n * @returns void\n */\nexport function sendReady(): void {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n console.log(\n 'Unable to send finished loading UI message, as there is no parent application',\n );\n\n return;\n }\n\n sendSdkMessage(parentApp, Action.OnReady);\n}\n\n/**\n * Sends a message to the SDK of the parent application informing it that\n * the UI of this Experience has completed loading.\n *\n * You should call this method when your UI has completed loading and you are ready to\n * display data to the user. This can be when your network calls have successfully requested\n * data and you have updated the DOM for it, or when an error has occurred and you want\n * to take over the UI to provide details to the user.\n *\n * The SDK will use this message to dismiss the loading indicator, allowing a seamless\n * transition between a native loading UI, into a fully loaded, child Experience.\n *\n * If this call is not made, the parent SDK will add a grace period to ensure the web app\n * has sufficient time to load, and eventually dismiss the loading state, whether Experience\n * is ready or not, so as to avoid scenarios were a defect leaves an infinite loading state\n * presented to the user.\n */\nexport function sendFinishedLoadingUI() {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n console.log(\n 'Unable to send finished loading UI message, as there is no parent application',\n );\n\n return;\n }\n\n sendSdkMessage(parentApp, Action.OnUILoaded);\n}\n\n/**\n * Adds an observer for when more data is requested by the parent application\n *\n * @param callback - The callback that is triggered when a request for more data\n * is received\n * @returns The unsubscribe function. When it's called,\n * the observer will be removed and requests for data will no longer be received\n */\nexport function onMoreDataRequested(callback: () => void): Unsubscribe {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n console.log(\n 'Unable to subscribe to more data event, as there is no parent application',\n );\n\n return () => {};\n }\n\n return onSdkMessage(parentApp, ({ action }) => {\n if (action === Action.OnMoreDataRequested) {\n callback();\n }\n });\n}\n\n/**\n * Adds an observer for when experience is fully embedded and ready to accept\n * incoming messages\n *\n * @param experience - Experience instance\n * @param callback - The callback that is triggered when experience is embedded\n * @returns The unsubscribe function. When it's called, the observer will be\n * removed and ready event will not be received\n */\nexport function onReady(\n experience: Experience,\n callback: () => void,\n): Unsubscribe {\n return onSdkMessage(experience, ({ action }) => {\n if (action === Action.OnReady) {\n callback();\n }\n });\n}\n\n/**\n * @internal\n */\nexport const sendExperienceSizeThrottled: (\n width: number,\n height: number,\n) => void = throttle(\n (width: number, height: number) => {\n const parentApp = getParentApplication();\n\n if (parentApp === null) return;\n\n sendSdkMessage(parentApp, Action.OnResize, { width, height });\n },\n RESIZE_THROTTLE_TIMEOUT,\n {\n leading: true,\n trailing: true,\n },\n);\n\n/**\n * @internal\n */\nexport function sendExperienceSize(width: number, height: number) {\n return sendExperienceSizeThrottled(width, height);\n}\n\n/**\n * Sets up an observer to watch for the element dimensions change and\n * automatically reports their changes to the parent application.\n *\n * @param element - HTML element whose dimensions need to be watched\n * @returns The unsubscribe function. When it's called,\n * the observer will be removed and element dimensions are no longer tracked\n */\nexport function reportExperienceSizeChanges(element: HTMLElement): () => void {\n const observer = new ResizeObserver(() => {\n const width = Math.max(element.offsetWidth, element.scrollWidth);\n const height = Math.max(element.offsetHeight, element.scrollHeight);\n\n sendExperienceSize(width, height);\n });\n\n observer.observe(element);\n\n return () => observer.unobserve(element);\n}\n"],"names":["Logger","Action","Source","QueryParam","BridgeError","_a","createError","globals","getGlobal","getErrorMessage","Emitter","VERSION","uuidv4","subscribe","fetchListings","embed","unmount","delay","Sdk","getSdk","showLoader","hideLoader","LogLevel","throttle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAWO,IAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;AAGO,IAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C;;;;AAIO,IAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;;;;;;AAOO,IAAM,qBA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;;;;;;;;;;;;;;;;;;;;"}
@@ -477,24 +477,6 @@ function getBridge(id) {
477
477
  bridges.set(id, bridge);
478
478
  return bridge;
479
479
  }
480
- /**
481
- * Returns true if the page is inside an iframe.
482
- *
483
- * @internal
484
- */
485
- function isInsideIframe() {
486
- if (typeof window === 'undefined') {
487
- return false;
488
- }
489
- try {
490
- return window.self !== window.top;
491
- }
492
- catch (_a) {
493
- // SecurityError is thrown when accessing window.top in a cross-origin iframe.
494
- // If we can't access it, we're definitely in an iframe.
495
- return true;
496
- }
497
- }
498
480
  /**
499
481
  * @internal
500
482
  */
@@ -505,9 +487,6 @@ function getParentBridge() {
505
487
  if (parentBridge !== undefined) {
506
488
  return parentBridge;
507
489
  }
508
- if (!isInsideIframe()) {
509
- return null;
510
- }
511
490
  const url = new URL(window.location.href);
512
491
  const bridgeId = url.searchParams.get(QueryParam.BridgeId);
513
492
  if (bridgeId === null) {
@@ -978,7 +957,7 @@ function unstashStyles(element) {
978
957
  element.removeAttribute('data-stash');
979
958
  }
980
959
 
981
- var version = "0.18.8";
960
+ var version = "0.18.9";
982
961
 
983
962
  /**
984
963
  * @license
@@ -1468,5 +1447,5 @@ function reportExperienceSizeChanges(element) {
1468
1447
  return () => observer.unobserve(element);
1469
1448
  }
1470
1449
 
1471
- export { Action, VERSION$1 as BRIDGE_VERSION, BridgeError, BridgeImpl, ExperienceImpl, ParentApplicationImpl, QueryParam, Source, VERSION, embed, enableLogging, getBridge, getExperience, getParentApplication, getParentBridge, isAutoresizesHeight, isInsideIframe, onMessage, onMoreDataRequested, onReady, onSdkMessage, registerEmbedHook, reportExperienceSizeChanges, requestMoreData, respondToMessage, respondToSdkMessage, sendExperienceSize, sendExperienceSizeThrottled, sendFinishedLoadingUI, sendMessage, sendReady, sendRequest, sendSdkMessage, sendSdkRequest, setRequestTimeout, shouldHideHeaderAndFooter, unmount };
1450
+ export { Action, VERSION$1 as BRIDGE_VERSION, BridgeError, BridgeImpl, ExperienceImpl, ParentApplicationImpl, QueryParam, Source, VERSION, embed, enableLogging, getBridge, getExperience, getParentApplication, getParentBridge, isAutoresizesHeight, onMessage, onMoreDataRequested, onReady, onSdkMessage, registerEmbedHook, reportExperienceSizeChanges, requestMoreData, respondToMessage, respondToSdkMessage, sendExperienceSize, sendExperienceSizeThrottled, sendFinishedLoadingUI, sendMessage, sendReady, sendRequest, sendSdkMessage, sendSdkRequest, setRequestTimeout, shouldHideHeaderAndFooter, unmount };
1472
1451
  //# sourceMappingURL=index.esm2017.js.map