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AAAA;AAEnD","file":"dialog.mjs","sourcesContent":["import { WindowClient } from '../window-client';\n\nimport { DialogSize } from '../types/dialog';\nimport { dialog } from '../types';\n\n/**\n * Shared Dialog Properties\n */\ninterface BaseDialogParams {\n  /**\n   * Title of the dialog module.\n   */\n  title?: string;\n\n  /**\n   * The requested size of the dialog\n   */\n  size: DialogSize;\n}\n\n/**\n * Data structure to describe dialog information needed to open an Adaptive Card-based dialog.\n */\nexport interface AdaptiveCardDialogParams extends BaseDialogParams {\n  /**\n   * JSON defining an Adaptive Card.\n   */\n  card: string;\n}\n\n/**\n * Data structure to describe dialog information needed to open a bot-based Adaptive Card-based dialog.\n */\nexport interface BotAdaptiveCardDialogParams extends AdaptiveCardDialogParams {\n  /**\n   * Specifies a bot ID to send the result of the user's interaction with the dialog module.\n   * The bot will receive a task/complete invoke event with a JSON object\n   * in the event payload.\n   */\n  completionBotId: string;\n}\n\n/**\n * Data structure to describe dialog information needed to open a url-based dialog.\n */\nexport interface UrlDialogParams extends BaseDialogParams {\n  /**\n   * The url to be rendered in the webview/iframe.\n   *\n   * @remarks\n   * The domain of the url must match at least one of the\n   * valid domains specified in the [validDomains block](https://learn.microsoft.com/microsoftteams/platform/resources/schema/manifest-schema#validdomains) of the app manifest\n   */\n  url: string;\n\n  /**\n   * If client doesnt support the URL, the URL that needs to be opened in the browser.\n   */\n  fallbackUrl?: string;\n}\n\n/**\n * Data structure to describe dialog information needed to open a bot based dialog.\n */\nexport interface BotUrlDialogParams extends UrlDialogParams {\n  /**\n   * Specifies a bot ID to send the result of the user's interaction with the task module.\n   * The bot will receive a task/complete invoke event with a JSON object\n   * in the event payload.\n   */\n  completionBotId: string;\n}\n\nexport type DialogParams =\n  | AdaptiveCardDialogParams\n  | BotAdaptiveCardDialogParams\n  | UrlDialogParams\n  | BotUrlDialogParams;\n\nexport class DialogClient {\n  readonly window: WindowClient;\n\n  constructor(client: WindowClient) {\n    this.window = client;\n  }\n\n  async open(params: DialogParams) {\n    const [err, result] = await this.window.send<[string | undefined, string | object]>(\n      'tasks.startTask',\n      {\n        title: params.title,\n        height: params.size.height || 'small',\n        width: params.size.width || 'small',\n        url: 'url' in params ? params.url : undefined,\n        fallbackUrl: 'fallbackUrl' in params ? params.fallbackUrl : undefined,\n        card: 'card' in params ? params.card : undefined,\n        completionBotId: 'completionBotId' in params ? params.completionBotId : undefined,\n      } as dialog.DialogInfo\n    );\n\n    return { err, result };\n  }\n\n  async submit(result?: string | object, appIds?: string | string[]) {\n    await this.window.send(\n      'tasks.completeTask',\n      result,\n      appIds ? (Array.isArray(appIds) ? appIds : [appIds]) : []\n    );\n  }\n\n  async update(size: dialog.DialogSize) {\n    await this.window.send('tasks.updateTask', size);\n  }\n}\n"]}