UNPKG

@prismatic-io/embedded

Version:

Embed Prismatic's integration marketplace and workflow designer within your existing application.

1 lines 74.2 kB
{"version":3,"file":"index.cjs","names":["merge","urlJoin","urlJoin","urlJoin","merge","prismatic"],"sources":["../src/state.ts","../src/utils/assertInit.ts","../src/types/options.ts","../src/types/postMessage.ts","../src/utils/popover.ts","../src/utils/postMessage.ts","../src/utils/iframe.ts","../src/lib/configureInstance.ts","../src/lib/graphqlRequest.ts","../src/lib/authenticate.ts","../src/lib/createWorkflow.ts","../src/styles.ts","../src/lib/init.ts","../src/lib/dispose.ts","../src/lib/editInstanceConfiguration.ts","../src/lib/queryWorkflows.ts","../src/lib/setConfigVars.ts","../src/lib/showComponent.ts","../src/lib/showComponents.ts","../src/lib/showConnections.ts","../src/lib/showDashboard.ts","../src/utils/assertEmbeddedDesigner.ts","../src/lib/showDesigner.ts","../src/lib/showIntegrations.ts","../src/lib/showLogs.ts","../src/lib/showMarketplace.ts","../src/lib/showWorkflow.ts","../src/lib/showWorkflows.ts","../src/types/conditionalLogic.ts","../src/exports.ts","../src/index.ts"],"sourcesContent":["import type { AgentConfiguration } from \"./types/agent\";\nimport type { Filters } from \"./types/filters\";\nimport type { FontConfiguration } from \"./types/fontConfiguration\";\nimport type { ScreenConfiguration } from \"./types/screenConfiguration\";\nimport type { Theme } from \"./types/theme\";\nimport type { Translation } from \"./types/translation\";\n\nexport interface State {\n  agent?: AgentConfiguration;\n  filters: Filters;\n  initComplete: boolean;\n  jwt: string;\n  embeddedDesignerEnabled: boolean;\n  prismaticUrl: string;\n  screenConfiguration?: ScreenConfiguration;\n  skipPreload?: boolean;\n  theme?: Theme;\n  fontConfiguration?: FontConfiguration;\n  translation?: Translation;\n}\n\nconst defaultState: State = {\n  agent: undefined,\n  filters: {},\n  initComplete: false,\n  jwt: \"\",\n  embeddedDesignerEnabled: false,\n  prismaticUrl: \"https://app.prismatic.io\",\n  screenConfiguration: undefined,\n  theme: undefined,\n  fontConfiguration: undefined,\n  translation: undefined,\n};\n\nexport const ValidKeys: ReadonlySet<keyof State> = new Set(\n  Object.keys(defaultState) as Array<keyof State>,\n);\n\nexport const isStateKey = (key: string): key is keyof State =>\n  (ValidKeys as ReadonlySet<string>).has(key);\n\n// Assigning `state[key] = value` where `key: keyof State` trips TS's\n// correlated-types limitation — the index evaluates to an intersection\n// (`never`) instead of the union. Wrapping the assignment in a generic\n// function bound to a single `K` lets TS treat `State[K]` as a single\n// concrete type, which matches the `value` parameter cleanly.\nexport const setStateKey = <K extends keyof State>(\n  state: State,\n  key: K,\n  value: State[K],\n): void => {\n  state[key] = value;\n};\n\nclass StateService {\n  private defaultState: State;\n  private state: State | null = null;\n\n  constructor(defaultState: State) {\n    this.defaultState = defaultState;\n  }\n\n  getInitialState(): State {\n    return JSON.parse(JSON.stringify(this.defaultState));\n  }\n\n  /**\n   * A function that returns a copy of the current state.  If a mutation is desired, you must call\n   * `stateService.setState` afterwards to persist the updated copy.\n   * @returns A deep copy of the state to prevent accidental mutations.\n   */\n  getStateCopy(): State {\n    if (this.state) {\n      return JSON.parse(JSON.stringify(this.state));\n    }\n\n    return this.getInitialState();\n  }\n\n  setState(state: State) {\n    this.state = state;\n  }\n}\n\nconst stateService = new StateService(defaultState);\n\nexport default stateService;\n","import stateService from \"../state\";\n\nexport const assertInit = (functionName: string) => {\n  if (!stateService.getStateCopy().initComplete) {\n    throw new Error(\n      `Expected init to be called before calling ${functionName}`,\n    );\n  }\n\n  if (!stateService.getStateCopy().jwt && functionName !== \"authenticate\") {\n    throw new Error(\n      `Expected authenticate to be called before calling ${functionName}`,\n    );\n  }\n};\n","import type { AgentConfiguration } from \"./agent\";\nimport type { Filters } from \"./filters\";\nimport type { ScreenConfiguration } from \"./screenConfiguration\";\nimport type { Theme } from \"./theme\";\nimport type { Translation } from \"./translation\";\n\ninterface OptionsBase {\n  agent?: AgentConfiguration;\n  autoFocusIframe?: boolean;\n  filters?: Filters;\n  screenConfiguration?: ScreenConfiguration;\n  theme?: Theme;\n  translation?: Translation;\n}\n\nexport interface SelectorOptions extends OptionsBase {\n  selector: string;\n  usePopover?: false;\n}\n\nexport interface PopoverOptions extends OptionsBase {\n  usePopover: true;\n}\n\nexport type Options = PopoverOptions | SelectorOptions;\n\nexport const isPopover = (options: Options): options is PopoverOptions =>\n  options.usePopover === true;\n","import type { ConfigVar } from \"./configVars\";\n\nexport interface WorkflowConfigurationData {\n  customerId: string;\n  customerName: string;\n  instanceId: string;\n  instanceName: string;\n  workflowVersionId: string | null;\n}\n\nexport interface InstanceConfigurationData {\n  customerId: string;\n  customerName: string;\n  instanceId: string;\n  instanceName: string;\n  integrationName: string;\n  integrationVersionNumber: number;\n  readOnly: boolean;\n}\n\nexport interface InstanceConfigurationLoadedData\n  extends InstanceConfigurationData {\n  configVars: Record<string, ConfigVar>;\n}\n\nexport interface InstanceConfigurationPageLoadedData\n  extends InstanceConfigurationLoadedData {\n  pageName: string;\n  pageContent: Record<string, unknown>;\n}\n\nexport interface UserConfigurationData extends InstanceConfigurationData {\n  userConfigId: string | undefined;\n  userEmail: string;\n  userId: string;\n  userLevelConfigVariables: Record<string, ConfigVar>;\n  userName: string;\n}\n\nexport interface UserConfigurationPageData extends UserConfigurationData {\n  pageName: string;\n  pageContent: Record<string, unknown>;\n}\n\nexport enum PrismaticMessageEvent {\n  INSTANCE_CONFIGURATION_CANCELED = \"INSTANCE_CONFIGURATION_CANCELED\",\n  INSTANCE_CONFIGURATION_CLOSED = \"INSTANCE_CONFIGURATION_CLOSED\",\n  INSTANCE_CONFIGURATION_LOADED = \"INSTANCE_CONFIGURATION_LOADED\",\n  INSTANCE_CONFIGURATION_PAGE_LOADED = \"INSTANCE_CONFIGURATION_PAGE_LOADED\",\n  INSTANCE_CONFIGURATION_OPENED = \"INSTANCE_CONFIGURATION_OPENED\",\n  INSTANCE_CREATED = \"INSTANCE_CREATED\",\n  INSTANCE_DELETED = \"INSTANCE_DELETED\",\n  INSTANCE_DEPLOYED = \"INSTANCE_DEPLOYED\",\n  MARKETPLACE_CLOSED = \"MARKETPLACE_CLOSED\",\n  POPOVER_CLOSE_REQUESTED = \"POPOVER_CLOSE_REQUESTED\",\n  POPOVER_CLOSED = \"POPOVER_CLOSED\",\n  SET_AGENT_CONTEXT = \"SET_AGENT_CONTEXT\",\n  SET_CONFIG_VAR = \"SET_CONFIG_VAR\",\n  SET_FILTERS = \"SET_FILTERS\",\n  SET_SCREEN_CONFIGURATION = \"SET_SCREEN_CONFIGURATION\",\n  SET_TOKEN = \"SET_TOKEN\",\n  SET_TRANSLATION = \"SET_TRANSLATION\",\n  SET_VERSION = \"SET_VERSION\",\n  USER_CONFIGURATION_CLOSED = \"USER_CONFIGURATION_CLOSED\",\n  USER_CONFIGURATION_DELETED = \"USER_CONFIGURATION_DELETED\",\n  USER_CONFIGURATION_DEPLOYED = \"USER_CONFIGURATION_DEPLOYED\",\n  USER_CONFIGURATION_LOADED = \"USER_CONFIGURATION_LOADED\",\n  USER_CONFIGURATION_PAGE_LOADED = \"USER_CONFIGURATION_PAGE_LOADED\",\n  USER_CONFIGURATION_OPENED = \"USER_CONFIGURATION_OPENED\",\n  WORKFLOW_ENABLED = \"WORKFLOW_ENABLED\",\n  WORKFLOW_DELETED = \"WORKFLOW_DELETED\",\n  WORKFLOW_DISABLED = \"WORKFLOW_DISABLED\",\n}\n\nexport type MessageData =\n  | {\n      data: InstanceConfigurationData;\n      event: PrismaticMessageEvent.INSTANCE_CONFIGURATION_CANCELED;\n    }\n  | {\n      data: InstanceConfigurationData;\n      event: PrismaticMessageEvent.INSTANCE_CONFIGURATION_OPENED;\n    }\n  | {\n      data: InstanceConfigurationLoadedData;\n      event: PrismaticMessageEvent.INSTANCE_CONFIGURATION_LOADED;\n    }\n  | {\n      data: InstanceConfigurationPageLoadedData;\n      event: PrismaticMessageEvent.INSTANCE_CONFIGURATION_PAGE_LOADED;\n    }\n  | {\n      data: InstanceConfigurationData;\n      event: PrismaticMessageEvent.INSTANCE_CONFIGURATION_CLOSED;\n    }\n  | {\n      data: InstanceConfigurationData;\n      event: PrismaticMessageEvent.INSTANCE_CREATED;\n    }\n  | {\n      data: InstanceConfigurationData;\n      event: PrismaticMessageEvent.INSTANCE_DELETED;\n    }\n  | {\n      data: InstanceConfigurationData;\n      event: PrismaticMessageEvent.INSTANCE_DEPLOYED;\n    }\n  | {\n      data: Record<string, never>;\n      event: PrismaticMessageEvent.POPOVER_CLOSE_REQUESTED;\n    }\n  | {\n      data: UserConfigurationData;\n      event: PrismaticMessageEvent.USER_CONFIGURATION_DELETED;\n    }\n  | {\n      data: UserConfigurationData;\n      event: PrismaticMessageEvent.USER_CONFIGURATION_DEPLOYED;\n    }\n  | {\n      data: UserConfigurationData;\n      event: PrismaticMessageEvent.USER_CONFIGURATION_CLOSED;\n    }\n  | {\n      data: UserConfigurationData;\n      event: PrismaticMessageEvent.USER_CONFIGURATION_LOADED;\n    }\n  | {\n      data: UserConfigurationPageData;\n      event: PrismaticMessageEvent.USER_CONFIGURATION_PAGE_LOADED;\n    }\n  | {\n      data: UserConfigurationData;\n      event: PrismaticMessageEvent.USER_CONFIGURATION_OPENED;\n    }\n  | {\n      data: WorkflowConfigurationData;\n      event: PrismaticMessageEvent.WORKFLOW_ENABLED;\n    }\n  | {\n      data: WorkflowConfigurationData;\n      event: PrismaticMessageEvent.WORKFLOW_DELETED;\n    }\n  | {\n      data: WorkflowConfigurationData;\n      event: PrismaticMessageEvent.WORKFLOW_DISABLED;\n    };\n","import { PrismaticMessageEvent } from \"../types/postMessage\";\nimport {\n  EMBEDDED_IFRAME_CONTAINER_SELECTOR,\n  EMBEDDED_OVERLAY_SELECTOR,\n  EMBEDDED_OVERLAY_VISIBLE_CLASS,\n  getIframeContainerElement,\n  isIframe,\n} from \"./iframe\";\n\nexport const getPopover = () =>\n  document.querySelector(EMBEDDED_OVERLAY_SELECTOR);\n\nexport const openPopover = () => {\n  getPopover()?.classList.add(EMBEDDED_OVERLAY_VISIBLE_CLASS);\n};\n\n/**\n * Programmatically closes the currently open Prismatic popover. This notifies\n * the embedded iframe that the marketplace was closed and dispatches a\n * `POPOVER_CLOSED` event on the window.\n *\n * The popover also closes automatically when the user clicks the close button,\n * clicks the overlay backdrop, or presses the Escape key.\n *\n * @example\n * // Close the popover from your own UI\n * document.getElementById(\"my-close-btn\")\n *   .addEventListener(\"click\", () => prismatic.closePopover());\n *\n * @example\n * // Listen for the popover closed event\n * window.addEventListener(\"message\", (event) => {\n *   if (event.data.event === \"POPOVER_CLOSED\") {\n *     console.log(\"Popover was closed\");\n *   }\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/marketplace/ | Embedding the Marketplace}\n */\nexport const closePopover = () => {\n  const iframeElement = getIframeContainerElement(\n    `${EMBEDDED_IFRAME_CONTAINER_SELECTOR} > iframe`,\n  );\n\n  if (!isIframe(iframeElement)) {\n    return;\n  }\n\n  iframeElement.contentWindow?.postMessage(\n    { event: PrismaticMessageEvent.MARKETPLACE_CLOSED },\n    \"*\",\n  );\n\n  window.postMessage({ event: PrismaticMessageEvent.POPOVER_CLOSED }, \"*\");\n\n  getPopover()?.classList.remove(EMBEDDED_OVERLAY_VISIBLE_CLASS);\n};\n","import { getIframeElement, isIframe } from \"./iframe\";\n\ninterface PostMessageBase {\n  event: unknown;\n}\n\nexport interface SelectorPostMessage extends PostMessageBase {\n  selector?: string;\n}\n\nexport interface ElementPostMessage extends PostMessageBase {\n  iframe: Element;\n}\n\ntype PostMessageProps = SelectorPostMessage | ElementPostMessage;\n\n/**\n * Returns the iframe element that sent a given `MessageEvent`. This is typically\n * used inside a `window.addEventListener(\"message\", ...)` handler to identify\n * which Prismatic iframe dispatched an event, so you can pass it to\n * {@link setConfigVars} or perform other targeted operations.\n *\n * @param event - The `MessageEvent` received from `window.addEventListener(\"message\", ...)`.\n * @returns The matching `HTMLIFrameElement`, or `undefined` if no iframe matches.\n *\n * @example\n * window.addEventListener(\"message\", (event) => {\n *   if (event.data.event === \"INSTANCE_CONFIGURATION_LOADED\") {\n *     const iframe = prismatic.getMessageIframe(event);\n *     if (iframe) {\n *       prismatic.setConfigVars({\n *         iframe,\n *         configVars: { \"My Config Var\": { value: \"preset-value\" } },\n *       });\n *     }\n *   }\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/marketplace/ | Embedding the Marketplace}\n */\nexport const getMessageIframe = (event: MessageEvent) =>\n  Array.from(document.getElementsByTagName(\"iframe\")).find(\n    (iframe) => iframe.contentWindow === event.source,\n  );\n\nconst isIframePostMessage = (\n  props: PostMessageProps,\n): props is ElementPostMessage => \"iframe\" in props;\n\nexport const postMessage = (props: PostMessageProps) => {\n  const iframeElement = isIframePostMessage(props)\n    ? props.iframe\n    : getIframeElement(props.selector);\n\n  if (!isIframe(iframeElement)) {\n    return;\n  }\n\n  iframeElement.contentWindow?.postMessage(props.event, \"*\");\n};\n","import merge from \"lodash.merge\";\nimport urlJoin from \"url-join\";\nimport stateService, { isStateKey, type State, setStateKey } from \"../state\";\nimport { isPopover, type Options } from \"../types/options\";\nimport { PrismaticMessageEvent } from \"../types/postMessage\";\nimport type { ScreenConfiguration } from \"../types/screenConfiguration\";\nimport { closePopover, openPopover } from \"./popover\";\nimport { postMessage } from \"./postMessage\";\n\nexport const EMBEDDED_ID = \"pio__embedded\";\nexport const EMBEDDED_IFRAME_ID = \"pio__iframe\";\nexport const EMBEDDED_IFRAME_PRELOAD_ID = \"pio__iframe-preload\";\nexport const EMBEDDED_STYLE_ID = \"pio__styles\";\nexport const EMBEDDED_IFRAME_CONTAINER_CLASS = \"pio__iframeContainer\";\nexport const EMBEDDED_IFRAME_CONTAINER_SELECTOR = `#${EMBEDDED_ID} .${EMBEDDED_IFRAME_CONTAINER_CLASS}`;\nexport const EMBEDDED_OVERLAY_CLASS = \"pio__overlay\";\nexport const EMBEDDED_OVERLAY_SELECTOR = `#${EMBEDDED_ID} > .${EMBEDDED_OVERLAY_CLASS}`;\nexport const EMBEDDED_OVERLAY_VISIBLE_CLASS = `${EMBEDDED_OVERLAY_CLASS}--is_visible`;\nexport const EMBEDDED_POPOVER_CLASS = \"pio__popover\";\nexport const EMBEDDED_POPOVER_CLOSE_CLASS = \"pio__closeBtn\";\n\nexport const getIframeContainerElement = (selector: string) =>\n  document.querySelector(selector);\n\nexport const getIframeElement = (selector: string | undefined) =>\n  document.querySelector(\n    `${selector || EMBEDDED_IFRAME_CONTAINER_SELECTOR} > iframe`,\n  );\n\nexport const isIframe = (\n  element?: Element | null,\n): element is HTMLIFrameElement =>\n  Boolean(element && element.tagName === \"IFRAME\");\n\nexport const setIframe = (\n  route: string,\n  options: Options,\n  params?: Record<string, string>,\n) => {\n  if (!isPopover(options) && !options.selector) {\n    console.error(\"Could not find display selector.\");\n  }\n\n  const iframeContainerElement = getIframeContainerElement(\n    isPopover(options) ? EMBEDDED_IFRAME_CONTAINER_SELECTOR : options.selector,\n  );\n\n  if (!iframeContainerElement) {\n    return;\n  }\n\n  // we use a copy of state so that changes to this only impact this iframe and do not update the shared state\n  const state = stateService.getStateCopy();\n\n  if (options) {\n    Object.entries(options).forEach(([key, value]) => {\n      if (isStateKey(key)) {\n        const existing = state[key];\n        const next =\n          existing instanceof Object ? merge(existing, value) : value;\n        setStateKey(state, key, next as State[typeof key]);\n      }\n    });\n  }\n\n  const queryParams = new URLSearchParams({\n    ...params,\n    embed: \"true\",\n  });\n\n  if (state.theme) {\n    queryParams.set(\"theme\", state.theme);\n  }\n\n  if (state.screenConfiguration?.initializing) {\n    queryParams.set(\n      \"initializing\",\n      JSON.stringify(state.screenConfiguration.initializing),\n    );\n  }\n\n  if (state.fontConfiguration) {\n    queryParams.set(\n      \"fontConfiguration\",\n      JSON.stringify(state.fontConfiguration),\n    );\n  }\n\n  const iframeSrc = `${urlJoin(state.prismaticUrl, route)}?${queryParams}`;\n\n  iframeContainerElement.innerHTML = /* html */ `\n    <iframe\n      id=\"${EMBEDDED_IFRAME_ID}\"\n      src=\"${iframeSrc}\"\n      height=\"100%\"\n      width=\"100%\"\n      frameBorder=\"0\"\n      allow=\"clipboard-read; clipboard-write\"\n    ></iframe>\n  `;\n\n  const iframeElement = iframeContainerElement.querySelector(\"iframe\");\n\n  if (iframeElement) {\n    const abortController = new AbortController();\n    observeForIframeRemoval(abortController);\n    window.addEventListener(\n      \"message\",\n      (event: MessageEvent<{ event: string }>) => {\n        if (event.data?.event === \"PRISMATIC_INITIALIZED\") {\n          postMessage({\n            iframe: iframeElement,\n            event: {\n              event: PrismaticMessageEvent.SET_TOKEN,\n              data: state.jwt,\n            },\n          });\n\n          postMessage({\n            iframe: iframeElement,\n            event: {\n              event: PrismaticMessageEvent.SET_VERSION,\n              data: EMBEDDED_VERSION,\n            },\n          });\n\n          postMessage({\n            iframe: iframeElement,\n            event: {\n              event: PrismaticMessageEvent.SET_TRANSLATION,\n              data: state.translation,\n            },\n          });\n\n          const screenConfigurationToPost: ScreenConfiguration | undefined =\n            isPopover(options)\n              ? {\n                  ...(state.screenConfiguration ?? {}),\n                  isInPopover: true,\n                }\n              : state.screenConfiguration;\n          postMessage({\n            iframe: iframeElement,\n            event: {\n              event: PrismaticMessageEvent.SET_SCREEN_CONFIGURATION,\n              data: screenConfigurationToPost,\n            },\n          });\n\n          postMessage({\n            iframe: iframeElement,\n            event: {\n              event: PrismaticMessageEvent.SET_FILTERS,\n              data: state.filters,\n            },\n          });\n\n          postMessage({\n            iframe: iframeElement,\n            event: {\n              event: PrismaticMessageEvent.SET_AGENT_CONTEXT,\n              data: state.agent?.context,\n            },\n          });\n        } else if (\n          event.data?.event === PrismaticMessageEvent.POPOVER_CLOSE_REQUESTED\n        ) {\n          closePopover();\n        }\n      },\n      {\n        signal: abortController.signal,\n      },\n    );\n\n    if (options?.autoFocusIframe !== false) {\n      iframeElement.addEventListener(\n        \"mouseenter\",\n        () => {\n          iframeElement.focus();\n        },\n        {\n          signal: abortController.signal,\n        },\n      );\n    }\n  }\n\n  if (isPopover(options)) {\n    openPopover();\n  }\n};\n\nconst observeForIframeRemoval = (signal: AbortController) => {\n  const config = { attributes: false, childList: true, subtree: true };\n\n  // Create an observer instance that will self-terminate once the iframe that we care about has been removed\n  const observer = new MutationObserver((mutationList, observer) => {\n    for (const mutation of mutationList) {\n      if (mutation.type === \"childList\") {\n        const removedNodes = Array.from(mutation.removedNodes);\n        for (const removedNode of removedNodes) {\n          if (removedNode.nodeType === Node.ELEMENT_NODE) {\n            if (\n              (removedNode as HTMLElement).tagName === \"IFRAME\" &&\n              (removedNode as HTMLIFrameElement).id === EMBEDDED_IFRAME_ID\n            ) {\n              signal.abort();\n              observer.disconnect();\n            } else {\n              const iframe = (removedNode as HTMLElement).querySelector(\n                `iframe#${EMBEDDED_IFRAME_ID}`,\n              );\n              if (iframe !== null) {\n                signal.abort();\n                observer.disconnect();\n              }\n            }\n          }\n        }\n      }\n    }\n  });\n\n  // Start observing the target node for configured mutations\n  observer.observe(document.body, config);\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\ntype ConfigureInstancesBase = Options & {\n  skipRedirectOnRemove: boolean;\n};\n\nexport type ConfigureInstanceWithIntegrationName = ConfigureInstancesBase & {\n  integrationName: string;\n};\n\nexport type ConfigureInstanceWithIntegrationId = ConfigureInstancesBase & {\n  integrationId: string;\n};\n\nexport type ConfigureInstanceWithInstanceId = ConfigureInstancesBase & {\n  instanceId: string;\n};\n\nexport type ConfigureInstanceProps =\n  | ConfigureInstanceWithIntegrationName\n  | ConfigureInstanceWithIntegrationId\n  | ConfigureInstanceWithInstanceId;\n\n/**\n * Opens the configuration wizard for an integration, allowing a customer user\n * to activate and configure an instance. You can identify the target by\n * `integrationName`, `integrationId`, or `instanceId`.\n *\n * - Use `integrationName` to let a customer activate a new instance of a\n *   marketplace integration by its display name.\n * - Use `integrationId` to target a specific integration version.\n * - Use `instanceId` to reconfigure an already-deployed instance.\n *\n * @param props - Configuration options. Exactly one of `integrationName`, `integrationId`, or `instanceId` is required.\n * @param props.skipRedirectOnRemove - When `true`, prevents redirecting to the marketplace after the instance is removed.\n *\n * @example\n * // Configure by integration name (most common)\n * prismatic.configureInstance({\n *   integrationName: \"Salesforce\",\n *   usePopover: true,\n *   skipRedirectOnRemove: false,\n * });\n *\n * @example\n * // Reconfigure an existing instance inline\n * prismatic.configureInstance({\n *   instanceId: \"SW5zdGFuY2U6OGE2YjZi...\",\n *   selector: \"#config-container\",\n *   skipRedirectOnRemove: true,\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/marketplace/ | Embedding the Marketplace}\n */\nexport const configureInstance = ({ ...props }: ConfigureInstanceProps) => {\n  assertInit(\"configureInstance\");\n\n  if (isConfigureInstanceWithInstanceId(props)) {\n    const { instanceId, skipRedirectOnRemove, ...options } = props;\n\n    return setIframe(\"/find-integration-marketplace/\", options, {\n      instanceId,\n      ...(skipRedirectOnRemove ? { skipRedirectOnRemove: \"true\" } : {}),\n    });\n  }\n\n  if (isConfigureInstanceWithIntegrationId(props)) {\n    const { integrationId, skipRedirectOnRemove, ...options } = props;\n\n    return setIframe(\"/find-integration-marketplace/\", options, {\n      integrationId,\n      ...(skipRedirectOnRemove ? { skipRedirectOnRemove: \"true\" } : {}),\n    });\n  }\n\n  if (isConfigureInstanceWithIntegrationName(props)) {\n    const { integrationName, skipRedirectOnRemove, ...options } = props;\n\n    setIframe(\"/find-integration-marketplace/\", options, {\n      integrationName,\n      ...(skipRedirectOnRemove ? { skipRedirectOnRemove: \"true\" } : {}),\n    });\n  }\n};\n\n/** Type guard that checks whether the props identify a target instance by `instanceId`. */\nexport const isConfigureInstanceWithInstanceId = (\n  props: ConfigureInstanceProps,\n): props is ConfigureInstanceWithInstanceId => {\n  return Boolean(\"instanceId\" in props && props.instanceId);\n};\n\n/** Type guard that checks whether the props identify a target integration by `integrationId`. */\nexport const isConfigureInstanceWithIntegrationId = (\n  props: ConfigureInstanceProps,\n): props is ConfigureInstanceWithIntegrationId => {\n  return Boolean(\"integrationId\" in props && props.integrationId);\n};\n\n/** Type guard that checks whether the props identify a target integration by `integrationName`. */\nexport const isConfigureInstanceWithIntegrationName = (\n  props: ConfigureInstanceProps,\n): props is ConfigureInstanceWithIntegrationName => {\n  return Boolean(\"integrationName\" in props && props.integrationName);\n};\n","import urlJoin from \"url-join\";\n\nimport stateService from \"../state\";\nimport { assertInit } from \"../utils/assertInit\";\n\nexport interface GraphqlRequestProps<TVariables = Record<string, unknown>> {\n  query: string;\n  variables?: TVariables;\n}\n\nexport interface GraphqlRequestResponse<TData = unknown> {\n  data: TData;\n  errors?: { message: string }[];\n}\n\n/**\n * Executes an authenticated GraphQL request against the Prismatic API.\n * The request is automatically authorized using the JWT from the most\n * recent {@link authenticate} call.\n *\n * This is useful for building custom UIs — for example, querying\n * `marketplaceIntegrations` to render a custom marketplace.\n *\n * @param props - The GraphQL query and optional variables.\n * @param props.query - The GraphQL query string.\n * @param props.variables - Optional variables to pass to the query.\n * @returns The parsed JSON response from the Prismatic API.\n *\n * @example\n * // Query available marketplace integrations\n * const result = await prismatic.graphqlRequest({\n *   query: `{\n *     marketplaceIntegrations(\n *       filters: { category: \"ERP\" }\n *     ) {\n *       nodes {\n *         id\n *         name\n *         description\n *         category\n *       }\n *     }\n *   }`,\n * });\n * console.log(result.data.marketplaceIntegrations.nodes);\n *\n * @example\n * // Query with variables\n * const result = await prismatic.graphqlRequest({\n *   query: `query ($integrationId: ID!) {\n *     integration(id: $integrationId) {\n *       name\n *       instances { nodes { id name } }\n *     }\n *   }`,\n *   variables: { integrationId: \"SW50ZWdyYXRpb246...\" },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/embedded-api-requests/ | Embedded API Requests}\n */\nexport const graphqlRequest = async <\n  TData = unknown,\n  TVariables = Record<string, unknown>,\n>({\n  query,\n  variables,\n}: GraphqlRequestProps<TVariables>): Promise<GraphqlRequestResponse<TData>> => {\n  assertInit(\"authenticate\");\n\n  const { jwt, prismaticUrl } = stateService.getStateCopy();\n\n  const response = await fetch(urlJoin(prismaticUrl, \"api\"), {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n      Accept: \"application/json\",\n      Authorization: `Bearer ${jwt}`,\n    },\n    body: JSON.stringify({ query, variables }),\n  });\n\n  return await response.json();\n};\n","import urlJoin from \"url-join\";\nimport stateService from \"../state\";\nimport { PrismaticMessageEvent } from \"../types/postMessage\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { EMBEDDED_IFRAME_ID } from \"../utils/iframe\";\nimport { postMessage } from \"../utils/postMessage\";\nimport { graphqlRequest } from \"./graphqlRequest\";\n\nconst ERROR_MESSAGE =\n  \"The authenticate method expects an object containing a token and additional optional configuration.\";\nconst EXPECTED_KEYS = [\"token\"];\n\nexport interface AuthenticateProps {\n  prismaticUrl?: string;\n  token: string;\n}\n\n/**\n * Authenticates an embedded user with a signed JWT token. This must be called after\n * {@link init} and before rendering any embedded screens. The token should be a\n * short-lived RS256-signed JWT generated on your backend.\n *\n * After the initial call, call `authenticate` again before the token expires\n * (typically ~60 seconds before expiry) to keep the session alive. All active\n * iframes update automatically when a new token is provided.\n *\n * @param options - Authentication options.\n * @param options.token - A signed JWT containing `sub`, `organization`, `customer`, `iat`, and `exp` claims.\n * @param options.prismaticUrl - Override the Prismatic app URL for this authentication request.\n * @throws {Error} If the token is missing or the server rejects it.\n *\n * @example\n * // Authenticate with a token fetched from your backend\n * const response = await fetch(\"/api/prismatic-token\");\n * const { token } = await response.json();\n * await prismatic.authenticate({ token });\n *\n * @example\n * // Re-authenticate before token expiry\n * const TOKEN_LIFETIME_MS = 10 * 60 * 1000; // 10 minutes\n * const refreshToken = async () => {\n *   const { token } = await fetchToken();\n *   await prismatic.authenticate({ token });\n *   setTimeout(refreshToken, TOKEN_LIFETIME_MS - 60_000);\n * };\n * refreshToken();\n *\n * @see {@link https://prismatic.io/docs/embed/authenticate-users/ | Authenticating Embedded Users}\n */\nexport const authenticate = async (options: AuthenticateProps) => {\n  assertInit(\"authenticate\");\n\n  if (!options) {\n    throw new Error(ERROR_MESSAGE);\n  }\n\n  const givenProps = new Set(Object.keys(options));\n\n  if (!EXPECTED_KEYS.every((key) => givenProps.has(key))) {\n    throw new Error(ERROR_MESSAGE);\n  }\n\n  const { token } = options;\n\n  const iframeElement = document.getElementById(\n    EMBEDDED_IFRAME_ID,\n  ) as HTMLIFrameElement;\n\n  const state = stateService.getStateCopy();\n\n  if (state.jwt !== token && iframeElement) {\n    postMessage({\n      iframe: iframeElement,\n      event: {\n        event: PrismaticMessageEvent.SET_TOKEN,\n        data: token,\n      },\n    });\n  }\n\n  const prismaticUrl = options.prismaticUrl ?? state.prismaticUrl;\n\n  const authResponse = await fetch(\n    urlJoin(prismaticUrl, \"embedded\", \"authenticate\"),\n    {\n      headers: {\n        Authorization: `Bearer ${token}`,\n      },\n      method: \"post\",\n    },\n  );\n\n  if (!authResponse.ok) {\n    const responseText = await authResponse.text();\n\n    if (responseText) {\n      throw new Error(\n        `Authentication failed. Server sent back: ${responseText}`,\n      );\n    } else {\n      throw new Error(\n        `Authentication failed. Please check that your customer and organization information are correct, and that the token you provided is not expired.`,\n      );\n    }\n  }\n\n  state.jwt = token;\n\n  stateService.setState(state);\n\n  const result = await graphqlRequest<{\n    authenticatedUser: {\n      customer: { allowEmbeddedDesigner: boolean };\n    };\n  }>({\n    query: `{\n      authenticatedUser {\n        customer {\n          allowEmbeddedDesigner\n        }\n      }\n    }`,\n  });\n\n  state.embeddedDesignerEnabled =\n    result.data.authenticatedUser.customer.allowEmbeddedDesigner;\n\n  stateService.setState(state);\n};\n","import { assertInit } from \"../utils/assertInit\";\nimport { graphqlRequest } from \"./graphqlRequest\";\n\n// biome-ignore lint/suspicious/noEmptyInterface: Empty interface is intentional - consumers augment it via declaration merging.\nexport interface WorkflowContexts {}\n\nexport interface CreateWorkflowArgs<TContextData = unknown> {\n  name: string;\n  contextData: TContextData;\n  externalId?: string;\n}\n\nexport interface CreateWorkflowData {\n  importWorkflow: {\n    workflow: {\n      id: string;\n    };\n    errors: {\n      field: string;\n      messages: string[];\n    }[];\n  };\n}\n\ninterface CreateWorkflowVariables {\n  name: string;\n  contextStableKey: string;\n  contextData: string;\n  externalId?: string;\n}\n\nconst mutation = `\n  mutation createWorkflow($name: String!, $contextStableKey: String, $contextData: String, $externalId: String) {\n    importWorkflow(input: {\n      name: $name\n      contextStableKey: $contextStableKey\n      contextData: $contextData\n      externalId: $externalId\n    }) {\n      workflow {\n        id\n      }\n      errors {\n        field\n        messages\n      }\n    }\n  }\n`;\n\nexport async function createWorkflow<\n  TKey extends keyof WorkflowContexts | (string & {}),\n>(\n  contextStableKey: TKey,\n  args: CreateWorkflowArgs<\n    TKey extends keyof WorkflowContexts\n      ? WorkflowContexts[TKey]\n      : Record<string, unknown>\n  >,\n) {\n  assertInit(\"createWorkflow\");\n\n  return graphqlRequest<CreateWorkflowData, CreateWorkflowVariables>({\n    query: mutation,\n    variables: {\n      name: args.name,\n      contextStableKey,\n      contextData: JSON.stringify(args.contextData),\n      externalId: args.externalId,\n    },\n  });\n}\n","import {\n  EMBEDDED_IFRAME_CONTAINER_CLASS,\n  EMBEDDED_OVERLAY_CLASS,\n  EMBEDDED_OVERLAY_VISIBLE_CLASS,\n  EMBEDDED_POPOVER_CLASS,\n  EMBEDDED_POPOVER_CLOSE_CLASS,\n  EMBEDDED_STYLE_ID,\n} from \"./utils/iframe\";\n\nexport const styles = /* html */ `<style id=\"${EMBEDDED_STYLE_ID}\">\n  .${EMBEDDED_OVERLAY_CLASS} {\n    backdrop-filter: blur(10px);\n    background: rgb(119 119 119 / 29%);\n    bottom: 0;\n    display: block;\n    left: 0;\n    opacity: 0;\n    position: fixed;\n    right: 0;\n    top: 0;\n    transition: all 0.3s ease-in;\n    visibility: hidden;\n    z-index: 9999;\n  }\n  .${EMBEDDED_OVERLAY_CLASS}.${EMBEDDED_OVERLAY_VISIBLE_CLASS} {\n    opacity: 1;\n    visibility: visible;\n  }\n  .${EMBEDDED_POPOVER_CLASS} {\n    background: #fff;\n    border-radius: 4px;\n    bottom: 0;\n    height: 80vh;\n    left: 0;\n    margin: auto;\n    overflow: hidden;\n    position: absolute;\n    right: 0;\n    top: 0;\n    width: 80vw;\n  }\n  .${EMBEDDED_POPOVER_CLOSE_CLASS} {\n    all: unset;\n    cursor: pointer;\n    position: absolute;\n    right: 1.5em;\n    top: 1.3em;\n  }\n  .${EMBEDDED_IFRAME_CONTAINER_CLASS} {\n    height: 100%\n  }\n</style>`;\n","import merge from \"lodash.merge\";\nimport stateService, { isStateKey, type State, setStateKey } from \"../state\";\nimport { styles } from \"../styles\";\nimport {\n  EMBEDDED_ID,\n  EMBEDDED_IFRAME_CONTAINER_CLASS,\n  EMBEDDED_IFRAME_PRELOAD_ID,\n  EMBEDDED_OVERLAY_CLASS,\n  EMBEDDED_OVERLAY_SELECTOR,\n  EMBEDDED_OVERLAY_VISIBLE_CLASS,\n  EMBEDDED_POPOVER_CLASS,\n  EMBEDDED_POPOVER_CLOSE_CLASS,\n} from \"../utils/iframe\";\nimport { closePopover } from \"../utils/popover\";\n\nlet listenerController: AbortController | undefined;\n\nexport const releaseListeners = () => {\n  listenerController?.abort();\n  listenerController = undefined;\n};\n\nexport interface InitProps\n  extends Pick<\n      State,\n      \"screenConfiguration\" | \"theme\" | \"fontConfiguration\" | \"translation\"\n    >,\n    Partial<\n      Pick<State, \"filters\" | \"prismaticUrl\" | \"skipPreload\" | \"agent\">\n    > {}\n\nexport const EMBEDDED_DEFAULTS = {\n  filters: {\n    marketplace: {\n      includeActiveIntegrations: true,\n    },\n    integrations: {},\n    components: {},\n  },\n  screenConfiguration: {\n    configurationWizard: {},\n    instance: {},\n    marketplace: {},\n    initializing: {},\n  },\n  skipPreload: false,\n  theme: \"LIGHT\",\n  fontConfiguration: undefined,\n  translation: {},\n};\n\n/**\n * Initializes the Prismatic embedded SDK. This must be called once before any other\n * SDK methods. It sets up the popover overlay, preloads Prismatic assets into the\n * browser cache, and applies global configuration (theme, filters, translations, etc.).\n *\n * Calling `init` again resets the in-memory SDK state with the new options,\n * but the popover DOM and document-level listeners are reused. Call\n * {@link dispose} first if you need a fully fresh teardown.\n *\n * @param optionsBase - Optional global configuration for the embedded SDK.\n * @param optionsBase.theme - The color theme to use (`\"LIGHT\"` or `\"DARK\"`). Defaults to `\"LIGHT\"`.\n * @param optionsBase.fontConfiguration - Google Font families to load for the embedded UI.\n * @param optionsBase.screenConfiguration - Per-screen display options (marketplace, config wizard, dashboard, etc.).\n * @param optionsBase.filters - Default filters for the marketplace, integrations, and components screens.\n * @param optionsBase.translation - Custom phrase overrides and debug mode for i18n.\n * @param optionsBase.prismaticUrl - Override the Prismatic app URL. Defaults to `\"https://app.prismatic.io\"`.\n * @param optionsBase.skipPreload - Skip preloading Prismatic assets. Defaults to `false`.\n * @param optionsBase.agent - Configuration for the workflow copilot.\n * @param optionsBase.agent.context - Additional context for the copilot, keyed by topic. The agent consults these entries to learn your application's domain language, the components you expect it to use, or details about the signed-in user.\n *\n * @example\n * // Basic initialization with defaults\n * prismatic.init();\n *\n * @example\n * // Give the workflow copilot application-specific context\n * prismatic.init({\n *   agent: {\n *     context: {\n *       glossary: \"A 'deal' is an opportunity record.\",\n *       components: \"Prefer the acmeLeads component for lead creation.\",\n *     },\n *   },\n * });\n *\n * @example\n * // Initialize with dark theme and custom screen configuration\n * prismatic.init({\n *   theme: \"DARK\",\n *   screenConfiguration: {\n *     marketplace: { configuration: \"allow-details\" },\n *     configurationWizard: { mode: \"streamlined\" },\n *   },\n *   filters: {\n *     marketplace: { category: \"ERP\" },\n *   },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/get-started/install-embedded-sdk/ | Installing the Embedded SDK}\n * @see {@link https://prismatic.io/docs/embed/theming/ | Theming}\n * @see {@link https://prismatic.io/docs/embed/translations-and-internationalization/ | Translations & i18n}\n */\nexport const init = (optionsBase?: InitProps) => {\n  const options: InitProps = merge({}, EMBEDDED_DEFAULTS, optionsBase);\n\n  // when we initialize, start from the fresh default state\n  const state = stateService.getInitialState();\n\n  if (options) {\n    Object.entries(options).forEach(([key, value]) => {\n      if (isStateKey(key)) {\n        setStateKey(state, key, value as State[typeof key]);\n      }\n    });\n  }\n\n  state.initComplete = true;\n\n  stateService.setState(state);\n\n  const existingElement = document.getElementById(EMBEDDED_ID);\n\n  if (existingElement) {\n    return;\n  }\n\n  /**\n   * This establishes a connection to the prismatic url and preloads\n   * assets (css, js, fonts, etc.) into browser cache. Subsequent\n   * calls, use existing connections and cached assets.\n   */\n  const existingIframePreload = document.getElementById(\n    EMBEDDED_IFRAME_PRELOAD_ID,\n  );\n\n  if (!existingIframePreload && !options.skipPreload) {\n    document.body.insertAdjacentHTML(\n      \"beforeend\",\n      `<iframe\n        id=\"${EMBEDDED_IFRAME_PRELOAD_ID}\"\n        src=\"${state.prismaticUrl}/embedded\"\n        style=\"visibility: hidden; display: none;\"\n        height=\"0\"\n        width=\"0\"\n      />`,\n    );\n  }\n\n  document.head.insertAdjacentHTML(\"beforeend\", styles);\n\n  const embeddedElement = document.createElement(\"div\");\n\n  embeddedElement.id = EMBEDDED_ID;\n\n  embeddedElement.innerHTML = /* html */ `\n    <div class=\"${EMBEDDED_OVERLAY_CLASS}\">\n      <div class=\"${EMBEDDED_POPOVER_CLASS}\">\n        <button class=\"${EMBEDDED_POPOVER_CLOSE_CLASS}\" aria-label=\"close popover\" data-close>✕</button>\n        <div class=\"${EMBEDDED_IFRAME_CONTAINER_CLASS}\"></div>\n      </div>\n    </div>\n  `;\n\n  document.body.appendChild(embeddedElement);\n\n  const closeButtonElement = document.querySelector(\n    `#${EMBEDDED_ID} .${EMBEDDED_POPOVER_CLOSE_CLASS}`,\n  );\n\n  const overlayElement = document.querySelector(EMBEDDED_OVERLAY_SELECTOR);\n\n  listenerController = new AbortController();\n  const { signal } = listenerController;\n\n  overlayElement?.addEventListener(\n    \"click\",\n    (event) => {\n      if (event.target !== event.currentTarget) {\n        return;\n      }\n\n      closePopover();\n    },\n    { signal },\n  );\n\n  closeButtonElement?.addEventListener(\"click\", () => closePopover(), {\n    signal,\n  });\n\n  document.addEventListener(\n    \"keyup\",\n    (e) => {\n      if (\n        e.key === \"Escape\" &&\n        document.querySelector(`.${EMBEDDED_OVERLAY_VISIBLE_CLASS}`)\n      ) {\n        closePopover();\n      }\n    },\n    { signal },\n  );\n};\n","import stateService from \"../state\";\nimport {\n  EMBEDDED_ID,\n  EMBEDDED_IFRAME_PRELOAD_ID,\n  EMBEDDED_STYLE_ID,\n} from \"../utils/iframe\";\nimport { releaseListeners } from \"./init\";\n\n/**\n * Removes every DOM node, listener, and piece of in-memory state created by\n * {@link init}. Use this when the embedded experience is being unmounted\n * (SPA route change, logout, conditional render) or to fully reset between\n * tests.\n *\n * After `dispose`, the next call to {@link init} starts from a clean slate:\n * the popover DOM, preload iframe, and stylesheet are recreated, and a fresh\n * Escape-key listener is attached.\n *\n * Calling `dispose` before `init`, or twice in a row, is a safe no-op.\n *\n * @example\n * // Fully reset the SDK\n * prismatic.dispose();\n *\n * @example\n * // Re-initialize with new options\n * prismatic.dispose();\n * prismatic.init({ theme: \"DARK\" });\n */\nexport const dispose = () => {\n  document.getElementById(EMBEDDED_ID)?.remove();\n  document.getElementById(EMBEDDED_IFRAME_PRELOAD_ID)?.remove();\n  document.getElementById(EMBEDDED_STYLE_ID)?.remove();\n\n  releaseListeners();\n\n  stateService.setState(stateService.getInitialState());\n};\n","import { PrismaticMessageEvent } from \"../types/postMessage\";\nimport type { ConfigurationWizardConfiguration } from \"../types/screenConfiguration\";\nimport type { Theme } from \"../types/theme\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type EditInstanceConfigurationProps = {\n  instanceId: string;\n  selector: string;\n  theme?: Theme;\n  screenConfiguration?: {\n    configurationWizard?: Omit<ConfigurationWizardConfiguration, \"isInModal\">;\n  };\n  onCancel?: () => void;\n  onSuccess?: () => void;\n  onDelete?: () => void;\n};\n\n/**\n * Renders the configuration wizard for an existing instance directly into a\n * DOM element (no popover). This is useful when you want to embed instance\n * configuration inline within your own application's UI.\n *\n * Unlike {@link configureInstance}, this function opens the config wizard directly,\n * supports lifecycle callbacks (`onSuccess`, `onCancel`, `onDelete`), and returns a\n * cleanup function to remove event listeners.\n *\n * @param props - Configuration and display options.\n * @param props.instanceId - The ID of the instance to configure.\n * @param props.selector - A CSS selector for the DOM element to render into.\n * @param props.theme - Optional theme override (`\"LIGHT\"` or `\"DARK\"`).\n * @param props.screenConfiguration - Optional screen configuration for the configuration wizard.\n * @param props.onSuccess - Called when the instance is successfully deployed.\n * @param props.onCancel - Called when the user cancels the configuration.\n * @param props.onDelete - Called when the user deletes the instance.\n * @returns A cleanup function that removes the event listeners, or `undefined` if no callbacks were provided.\n *\n * @example\n * // Edit an instance's configuration with lifecycle callbacks\n * const cleanup = prismatic.editInstanceConfiguration({\n *   instanceId: \"SW5zdGFuY2U6OGE2YjZi...\",\n *   selector: \"#config-panel\",\n *   onSuccess: () => console.log(\"Configuration saved!\"),\n *   onCancel: () => console.log(\"Configuration canceled.\"),\n *   onDelete: () => console.log(\"Instance deleted.\"),\n * });\n *\n * // Call cleanup() when you're done to remove event listeners\n * cleanup?.();\n *\n * @see {@link https://prismatic.io/docs/embed/marketplace/ | Embedding the Marketplace}\n */\nexport const editInstanceConfiguration = ({\n  instanceId,\n  selector,\n  theme,\n  screenConfiguration,\n  onCancel,\n  onSuccess,\n  onDelete,\n}: EditInstanceConfigurationProps) => {\n  assertInit(\"editInstanceConfiguration\");\n\n  setIframe(\n    `/configure-instance/${instanceId}/`,\n    {\n      selector,\n      ...(theme ? { theme } : {}),\n      screenConfiguration: {\n        ...screenConfiguration,\n        configurationWizard: {\n          ...screenConfiguration?.configurationWizard,\n          isInModal: true,\n        },\n      },\n    },\n    { reconfigure: \"true\" },\n  );\n\n  if (!onCancel && !onSuccess && !onDelete) {\n    return;\n  }\n\n  const abortController = new AbortController();\n\n  window.addEventListener(\n    \"message\",\n    (event: MessageEvent<{ event: string }>) => {\n      switch (event.data?.event) {\n        case PrismaticMessageEvent.INSTANCE_DEPLOYED:\n          onSuccess?.();\n          abortController.abort();\n          break;\n        case PrismaticMessageEvent.INSTANCE_DELETED:\n          onDelete?.();\n          abortController.abort();\n          break;\n        case PrismaticMessageEvent.INSTANCE_CONFIGURATION_CANCELED:\n          onCancel?.();\n          abortController.abort();\n          break;\n      }\n    },\n    { signal: abortController.signal },\n  );\n\n  return () => abortController.abort();\n};\n","import { assertInit } from \"../utils/assertInit\";\nimport { graphqlRequest } from \"./graphqlRequest\";\n\nexport interface Workflow {\n  id: string;\n  name: string;\n  versionNumber: number;\n  description: string;\n  externalId: string | null;\n  updatedAt: string;\n  lastExecutedAt: string | null;\n  createdAt: string;\n  category: string | null;\n  labels: string[];\n  customer: {\n    id: string;\n    name: string;\n  };\n  instance: {\n    enabled: boolean;\n  } | null;\n  deployedVersion: {\n    id: string;\n  } | null;\n}\n\nexport interface QueryWorkflowsData {\n  workflows: {\n    nodes: Workflow[];\n    pageInfo: {\n      hasNextPage: boolean;\n      endCursor: string | null;\n    };\n    totalCount: number;\n  };\n}\n\nexport interface QueryWorkflowsProps extends Record<string, unknown> {\n  searchTerm?: string;\n  descriptionSearch?: string;\n  categorySearch?: string;\n  labelSearch?: string;\n  contextStableKey?: string;\n  externalId?: string;\n  sortBy?: string[];\n  first?: number;\n  cursor?: string;\n}\n\nconst query = `\n  query queryWorkflows(\n    $cursor: String\n    $searchTerm: String\n    $descriptionSearch: String\n    $categorySearch: String\n    $labelSearch: String\n    $contextStableKey: String\n    $externalId: String\n    $first: Int\n    $sortBy: [IntegrationVariantOrder]\n  ) {\n    workflows: integrationVariants(\n      after: $cursor\n      name_Icontains: $searchTerm\n      description_Icontains: $descriptionSearch\n      category: $categorySearch\n      labels_Icontains: $labelSearch\n      contextStableKey: $contextStableKey\n      externalId: $externalId\n      exclude: [INTEGRATION]\n      first: $first\n      sortBy: $sortBy\n    ) {\n      nodes {\n        ... on Workflow {\n          id\n          name\n          versionNumber\n          description\n          externalId\n          updatedAt\n          lastExecutedAt\n          createdAt\n          category\n          labels\n          customer {\n            id\n            name\n          }\n          instance {\n            enabled\n          }\n          deployedVersion {\n            id\n          }\n        }\n      }\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n      totalCount\n    }\n  }\n`;\n\nexport const queryWorkflows = async (variables?: QueryWorkflowsProps) => {\n  assertInit(\"queryWorkflows\");\n\n  return graphqlRequest<QueryWorkflowsData, QueryWorkflowsProps>({\n    query,\n    variables,\n  });\n};\n","import type { ConfigVars } from \"../types/configVars\";\nimport { PrismaticMessageEvent } from \"../types/postMessage\";\nimport { postMessage } from \"../utils/postMessage\";\n\ninterface SetConfigVarsPropsBase {\n  configVars: ConfigVars;\n}\n\ninterface SelectorSetConfigVarProps extends SetConfigVarsPropsBase {\n  selector?: string;\n}\n\ninterface IFrameSetConfigVarProps extends SetConfigVarsPropsBase {\n  iframe: Element;\n}\n\nexport type SetConfigVarsProps =\n  | IFrameSetConfigVarProps\n  | SelectorSetConfigVarProps;\n\n/**\n * Programmatically sets configuration variable values on an active configuration\n * wizard. This is useful for pre-filling config values based on context from\n * your application (e.g., setting an API endpoint or customer-specific settings).\n *\n * You can target the iframe either by passing the iframe element directly\n * (obtained from {@link getMessageIframe}) or by passing a `selector` string.\n *\n * @param props - The config vars and target iframe.\n * @param props.configVars - A map of config variable keys to their values.\n * @param props.iframe - The iframe element to send config vars to (use with `getMessageIframe`).\n * @param props.selector - A CSS selector for the iframe to send config vars to.\n *\n * @example\n * // Set config vars using an iframe reference from a message event\n * window.addEventListener(\"message\", (event) => {\n *   if (event.data.event === \"INSTANCE_CONFIGURATION_LOADED\") {\n *     const iframe = prismatic.getMessageIframe(event);\n *     prismatic.setConfigVars({\n *       iframe,\n *       configVars: {\n *         \"API Endpoint\": { value: \"https://api.example.com\" },\n *         \"Sync Frequency\": { value: \"daily\" },\n *       },\n *     });\n *   }\n * });\n *\n * @example\n * // Set config vars using a CSS selector\n * prismatic.setConfigVars({\n *   selector: \"#config-container\",\n *   configVars: {\n *     \"API Key\": { value: \"my-api-key\" },\n *   },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/marketplace/ | Embedding the Marketplace}\n */\nexport const setConfigVars = ({\n  configVars,\n  ...options\n}: SetConfigVarsProps) => {\n  postMessage({\n    ...options,\n    event: { event: PrismaticMessageEvent.SET_CONFIG_VAR, data: configVars },\n  });\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowComponentProps = Options & {\n  componentId: string;\n};\n\n/**\n * Renders the detail page for a specific component, showing its available\n * actions, triggers, and data sources.\n *\n * @param props - Display options including the component to show.\n * @param props.componentId - The ID of the component to display.\n *\n * @example\n * // Show a specific component in a popover\n * prismatic.showComponent({\n *   componentId: \"Q29tcG9uZW50OmFiY2Rl...\",\n *   usePopover: true,\n * });\n *\n * @example\n * // Show a specific component inline\n * prismatic.showComponent({\n *   componentId: \"Q29tcG9uZW50OmFiY2Rl...\",\n *   selector: \"#component-detail\",\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/additional-screens/show-components/ | Embedding Components}\n */\nexport const showComponent = ({\n  componentId,\n  ...options\n}: ShowComponentProps) => {\n  assertInit(\"showComponent\");\n\n  setIframe(`/components/${componentId}/`, options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowComponentsProps = Options & {};\n\n/**\n * Renders the component browser, where your customer's users can browse\n * available components and their actions.\n *\n * Components can be filtered by category or label via the `filters` option.\n *\n * @param options - Display options for the components screen.\n *\n * @example\n * // Show components in a popover\n * prismatic.showComponents({ usePopover: true });\n *\n * @example\n * // Show components inline, filtered by category\n * prismatic.showComponents({\n *   selector: \"#components-container\",\n *   filters: { components: { category: \"Data Platforms\" } },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/additional-screens/show-components/ | Embedding Components}\n */\nexport const showComponents = (options: ShowComponentsProps) => {\n  assertInit(\"showComponents\");\n\n  setIframe(\"/components/\", options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowConnectionsProps = Options & {};\n\n/**\n * Renders the connections management screen, where your customer's users can\n * view and manage their reusable credential connections.\n *\n * @param options - Display options for the connections screen.\n *\n * @example\n * // Show connections in a popover\n * prismatic.showConnections({ usePopover: true });\n *\n * @example\n * // Show connections inline\n * prismatic.showConnections({ selector: \"#connections-container\" });\n *\n * @see {@link https://prismatic.io/docs/embed/additional-screens/show-connections/ | Embedding Connections}\n */\nexport const showConnections = (options: ShowConnectionsProps) => {\n  assertInit(\"showConnections\");\n\n  setIframe(\"/customer-connections/\", options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowDashboardProps = Options & {};\n\n/**\n * Renders the customer dashboard, which provides an overview of the customer's\n * deployed instances, logs, connections, and other resources.\n *\n * Specific tabs can be hidden via `screenConfiguration.dashboard.hideTabs`.\n *\n * @param options - Display options for the dashboard.\n *\n * @example\n * // Show dashboard in a popover\n * prismatic.showDashboard({ usePopover: true });\n *\n * @example\n * // Show dashboard inline, hiding certain tabs\n * prismatic.showDashboard({\n *   selector: \"#dashboard-container\",\n *   screenConfiguration: {\n *     dashboard: { hideTabs: [\"Logs\", \"Credentials\"] },\n *   },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/additional-screens/show-dashboard/ | Embedding the Dashboard}\n */\nexport const showDashboard = (\n  options: ShowDashboardProps = { usePopover: true },\n) => {\n  assertInit(\"showDashboard\");\n\n  setIframe(\"/dashboard/\", options, {});\n};\n","import stateService from \"../state\";\n\nexport const assertEmbeddedDesigner = (functionName: string) => {\n  const { embeddedDesignerEnabled } = stateService.getStateCopy();\n\n  if (!embeddedDesignerEnabled) {\n    throw new Error(\n      `Embedded designer must be enabled for this customer in order to call ${functionName}`,\n    );\n  }\n};\n","import type { Options } from \"../types/options\";\nimport { assertEmbeddedDesigner } from \"../utils/assertEmbeddedDesigner\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowDesignerProps = Options & {\n  integrationId: string;\n};\n\n/**\n * Renders the embedded integration designer for a specific integration, allowing\n * your customer's users to build and modify integration workflows.\n *\n * Requires the embedded designer feature to be enabled for the customer.\n *\n * @param props - Display options including the integration to open.\n * @param props.integrationId - The ID of the integration to open in the designer.\n *\n * @example\n * // Open the designer for a specific integration in a popover\n * prismatic.showDesigner({\n *   integrationId: \"SW50ZWdyYXRpb246YzNmOGU...\",\n *   usePopover: true,\n * });\n *\n * @example\n * // Open the designer inline\n * prismatic.showDesigner({\n *   integrationId: \"SW50ZWdyYXRpb246YzNmOGU...\",\n *   selector: \"#designer-container\",\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/workflow-builder/workflow-builder/ | Embedding the Workflow Builder}\n */\nexport const showDesigner = ({\n  integrationId,\n  ...options\n}: ShowDesignerProps) => {\n  assertInit(\"showDesigner\");\n  assertEmbeddedDesigner(\"showDesigner\");\n\n  setIframe(`/integrations/${integrationId}/`, options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { assertEmbeddedDesigner } from \"../utils/assertEmbeddedDesigner\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowIntegrationsProps = Options & {};\n\n/**\n * Renders the integrations list screen, where your customer's users can view\n * and manage integrations they have built with the embedded designer.\n *\n * Requires the embedded designer feature to be enabled for the customer.\n *\n * @param options - Display options for the integrations list.\n *\n * @example\n * // Show integrations list in a popover\n * prismatic.showIntegrations({ usePopover: true });\n *\n * @example\n * // Show integrations list inline\n * prismatic.showIntegrations({ selector: \"#integrations-container\" });\n */\nexport const showIntegrations = (options: ShowIntegrationsProps) => {\n  assertInit(\"showIntegrations\");\n  assertEmbeddedDesigner(\"showIntegrations\");\n\n  setIframe(\"/integrations/\", options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowLogsProps = Options & {};\n\n/**\n * Renders the logs screen, where your customer's users can view execution\n * logs for their deployed instances.\n *\n * @param options - Display options for the logs screen.\n *\n * @example\n * // Show logs in a popover\n * prismatic.showLogs({ usePopover: true });\n *\n * @example\n * // Show logs inline\n * prismatic.showLogs({ selector: \"#logs-container\" });\n *\n * @see {@link https://prismatic.io/docs/embed/additional-screens/show-logs/ | Embedding Logs}\n */\nexport const showLogs = (options: ShowLogsProps) => {\n  assertInit(\"showLogs\");\n\n  setIframe(\"/logs/\", options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowMarketplaceProps = Options & {};\n\n/**\n * Renders Prismatic's integration marketplace, where your customers can browse,\n * activate, and configure available integrations.\n *\n * The marketplace can be displayed in a popover (default) or rendered inline\n * within a specific DOM element using the `selector` option.\n *\n * @param options - Display options for the marketplace.\n *\n * @example\n * // Show marketplace in a popover\n * prismatic.showMarketplace({ usePopover: true });\n *\n * @example\n * // Show marketplace inline in a specific DOM element\n * prismatic.showMarketplace({\n *   selector: \"#marketplace-container\",\n *   theme: \"DARK\",\n *   filters: { marketplace: { category: \"ERP\" } },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/marketplace/ | Embedding the Marketplace}\n */\nexport const showMarketplace = (\n  options: ShowMarketplaceProps = { usePopover: true },\n) => {\n  assertInit(\"showMarketplace\");\n\n  setIframe(\"/integration-marketplace/\", options, {});\n};\n","import type { Options } from \"../types/options\";\nimport { PrismaticMessageEvent } from \"../types/postMessage\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowWorkflowBuilderProps = Options & {\n  workflowId: string;\n  onDelete?: () => void;\n};\n\n/**\n * Renders the workflow builder for a specific workflow, allowing your customer's\n * users to view and modify the workflow's steps, triggers, and configuration.\n *\n * @param props - Display options including the workflow to open.\n * @param props.workflowId - The ID of the workflow to open in the builder.\n * @param props.onDelete - Called when the workflow is deleted.\n * @returns A cleanup function that removes the event listeners, or `undefined` if onDelete was not provided.\n *\n * @example\n * // Open a specific workflow in a popover\n * const cleanup = prismatic.showWorkflow({\n *   workflowId: \"V29ya2Zsb3c6YTFiMmMz...\",\n *   onDelete: () => console.log(`Workflow deleted.`),\n *   usePopover: true,\n * });\n * // Call cleanup() when you're done to remove event listeners\n * cleanup?.();\n *\n * @example\n * // Open a specific workflow inline\n * prismatic.showWorkflow({\n *   workflowId: \"V29ya2Zsb3c6YTFiMmMz...\",\n *   selector: \"#workflow-container\",\n * });\n *\n * @example\n * // Open the workflow builder on the trigger selection screen\n * prismatic.showWorkflow({\n *   workflowId: \"V29ya2Zsb3c6YTFiMmMz...\",\n *   selector: \"#workflow-container\",\n *   screenConfiguration: {\n *     workflowBuilder: { showTriggerSelectionOnLoad: true },\n *   },\n * });\n *\n * @example\n * // Open the workflow builder with the copilot panel already expanded\n * prismatic.showWorkflow({\n *   workflowId: \"V29ya2Zsb3c6YTFiMmMz...\",\n *   selector: \"#workflow-container\",\n *   screenConfiguration: {\n *     workflowBuilder: { copilot: { initialChatVisibility: \"open\" } },\n *   },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/workflow-builder/workflow-builder/ | Embedding the Workflow Builder}\n */\nexport const showWorkflow = ({\n  workflowId,\n  onDelete,\n  ...options\n}: ShowWorkflowBuilderProps) => {\n  assertInit(\"showWorkflowBuilder\");\n\n  setIframe(`/builder/${workflowId}/`, options, {});\n\n  if (onDelete) {\n    const abortController = new AbortController();\n\n    window.addEventListener(\n      \"message\",\n      (event: MessageEvent<{ event: string }>) => {\n        if (event.data?.event === PrismaticMessageEvent.WORKFLOW_DELETED) {\n          onDelete();\n        }\n      },\n      { signal: abortController.signal },\n    );\n\n    return () => abortController.abort();\n  }\n};\n","import type { Options } from \"../types/options\";\nimport { assertInit } from \"../utils/assertInit\";\nimport { setIframe } from \"../utils/iframe\";\n\nexport type ShowWorkflowsProps = Options & {};\n\n/**\n * Renders the workflows list screen, where your customer's users can browse\n * and manage their workflows.\n *\n * Set `screenConfiguration.workflows.includeIntegrations` to also display\n * integrations alongside workflows.\n *\n * @param options - Display options for the workflows list.\n *\n * @example\n * // Show workflows list in a popover\n * prismatic.showWorkflows({ usePopover: true });\n *\n * @example\n * // Show workflows inline, including integrations\n * prismatic.showWorkflows({\n *   selector: \"#workflows-container\",\n *   screenConfiguration: {\n *     workflows: { includeIntegrations: true },\n *   },\n * });\n *\n * @see {@link https://prismatic.io/docs/embed/workflow-builder/workflow-builder/ | Embedding the Workflow Builder}\n */\nexport const showWorkflows = (options: ShowWorkflowsProps) => {\n  assertInit(\"showWorkflows\");\n\n  setIframe(\"/workflows/\", options, {});\n};\n","export enum BooleanOperator {\n  and = \"and\",\n  or = \"or\",\n}\n\nexport enum TermOperator {\n  equal = \"equal\",\n  notEqual = \"notEqual\",\n  in = \"in\",\n  notIn = \"notIn\",\n  startsWith = \"startsWith\",\n  doesNotStartWith = \"doesNotStartWith\",\n  endsWith = \"endsWith\",\n  doesNotEndWith = \"doesNotEndWith\",\n}\n\nexport const TermOperatorPhrase = {\n  [TermOperator.equal]: \"equals\",\n  [TermOperator.notEqual]: \"does not equal\",\n  [TermOperator.in]: \"contained in\",\n  [TermOperator.notIn]: \"not contained in\",\n  [TermOperator.startsWith]: \"starts the string\",\n  [TermOperator.doesNotStartWith]: \"does not start the string\",\n  [TermOperator.endsWith]: \"ends the string\",\n  [TermOperator.doesNotEndWith]: \"does not end the string\",\n};\n\nexport type TermExpression = [TermOperator, unknown, unknown?];\n\nexport type BooleanExpression = [\n  BooleanOperator.and | BooleanOperator.or,\n  ...ConditionalExpression[],\n];\n\nexport type ConditionalExpression = TermExpression | BooleanExpression;\n","export * from \"./lib\";\nexport * from \"./types\";\nexport { closePopover } from \"./utils/popover\";\nexport { getMessageIframe } from \"./utils/postMessage\";\n","import * as prismatic from \"./exports\";\n\nexport * from \"./exports\";\nexport default prismatic;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