{"version":3,"file":"dialog.mjs","sourceRoot":"","sources":["../../../src/types/methods/dialog.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,2CAA6B,CAAA;IAC7B,+BAAiB,CAAA;AACnB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB","sourcesContent":["import type { Json } from '@metamask/utils';\n\nimport type { ComponentOrElement } from '..';\nimport type { EnumToUnion } from '../../internals';\n\n/**\n * The type of dialog to display.\n *\n * - `alert` - A dialog with a single button.\n * - `confirmation` - A dialog with two buttons, one to confirm and one to\n * cancel.\n * - `prompt` - A dialog with two buttons and a text input.\n */\nexport enum DialogType {\n  Alert = 'alert',\n  Confirmation = 'confirmation',\n  Prompt = 'prompt',\n}\n\nexport type DefaultDialog =\n  | {\n      id: string;\n    }\n  | { content: ComponentOrElement };\n\n/**\n * An alert dialog.\n */\nexport type AlertDialog =\n  | {\n      /**\n       * The literal string \"alert\" to indicate that this is an alert dialog.\n       */\n      type: EnumToUnion<DialogType.Alert>;\n\n      /**\n       * The content to display in the alert dialog.\n       */\n      content: ComponentOrElement;\n    }\n  | {\n      /**\n       * The literal string \"alert\" to indicate that this is an alert dialog.\n       */\n      type: EnumToUnion<DialogType.Alert>;\n\n      /**\n       * The Snap interface ID, which can be used to display a previously\n       * created interface. See [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n       */\n      id: string;\n    };\n\n/**\n * A confirmation dialog.\n */\nexport type ConfirmationDialog =\n  | {\n      /**\n       * The literal string \"confirmation\" to indicate that this is a\n       * confirmation dialog.\n       */\n      type: EnumToUnion<DialogType.Confirmation>;\n\n      /**\n       * The content to display in the confirmation dialog.\n       */\n      content: ComponentOrElement;\n    }\n  | {\n      /**\n       * The literal string \"confirmation\" to indicate that this is a\n       * confirmation dialog.\n       */\n      type: EnumToUnion<DialogType.Confirmation>;\n\n      /**\n       * The Snap interface ID, which can be used to display a previously\n       * created interface. See [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n       */\n      id: string;\n    };\n\n/**\n * A prompt dialog.\n */\nexport type PromptDialog =\n  | {\n      /**\n       * The literal string \"prompt\" to indicate that this is a prompt dialog.\n       */\n      type: EnumToUnion<DialogType.Prompt>;\n\n      /**\n       * The content to display in the prompt dialog.\n       */\n      content: ComponentOrElement;\n\n      /**\n       * An optional placeholder text to display in the text input.\n       */\n      placeholder?: string;\n    }\n  | {\n      /**\n       * The literal string \"prompt\" to indicate that this is a prompt dialog.\n       */\n      type: EnumToUnion<DialogType.Prompt>;\n\n      /**\n       * The Snap interface ID, which can be used to display a previously\n       * created interface. See [`snap_createInterface`](https://docs.metamask.io/snaps/reference/snaps-api/snap_createinterface).\n       */\n      id: string;\n\n      /**\n       * An optional placeholder text to display in the text input.\n       */\n      placeholder?: string;\n    };\n\n/**\n * An object containing the contents of the dialog.\n *\n * @property type - The type of dialog to display.\n * @property content - The content to display in the dialog.\n * @property id - The Snap interface ID.\n * @property placeholder - The placeholder text to display in the dialog. Only\n * applicable for the `prompt` dialog.\n */\nexport type DialogParams =\n  | AlertDialog\n  | ConfirmationDialog\n  | PromptDialog\n  | DefaultDialog;\n\n/**\n * - If the dialog is an `alert`, the result is `null`.\n * - If the dialog is a `confirmation`, the result is a boolean indicating\n * whether the user confirmed the dialog.\n * - If the dialog is a `prompt`, the result is the value entered by\n * the user.\n */\nexport type DialogResult = Json;\n"]}