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A;AACZ,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,cAAc,KAAkB,EAAA;AAC9B,IAAK,IAAA,CAAA,OAAA,CAAQ,IAAK,CAAA,GAAG,KAAK,CAAA;AAC1B,IAAO,OAAA,IAAA;AAAA;AAEX;AAoBO,MAAM,MAA0B,CAAA;AAAA;AAAA;AAAA;AAAA,EAIrC,KAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA,EAEA,WAAA,CAAY,OAAe,KAAe,EAAA;AACxC,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AAAA;AAEjB;AA2BO,MAAM,eAA4C,CAAA;AAAA;AAAA;AAAA;AAAA,EAIvD,OAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA,EAEA,YAAY,OAAiB,EAAA;AAC3B,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA;AAAA;AACjB,EAEA,YAAY,KAA+B,EAAA;AACzC,IAAO,MAAA,CAAA,MAAA,CAAO,MAAM,KAAK,CAAA;AACzB,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,UAAU,KAAe,EAAA;AACvB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,SAAS,KAAe,EAAA;AACtB,IAAA,IAAA,CAAK,IAAO,GAAA,KAAA;AACZ,IAAO,OAAA,IAAA;AAAA;AAEX","file":"choice-set.mjs","sourcesContent":["import { IInputElement, InputElement } from './base';\n\nexport type ChoiceInputStyle = 'compact' | 'expanded' | 'filtered';\n\n/**\n * Allows a user to input a Choice.\n */\nexport interface IChoiceSetInput extends IInputElement {\n  type: 'Input.ChoiceSet';\n\n  /**\n   * Choice options.\n   */\n  choices?: IChoice[];\n\n  /**\n   * Allows dynamic fetching of choices from the bot to be displayed as suggestions in the dropdown when the user types in the input field.\n   */\n  'choices.data'?: IChoiceDataQuery;\n\n  /**\n   * Allow multiple choices to be selected.\n   */\n  isMultiSelect?: boolean;\n\n  /**\n   * the style of the choice input\n   */\n  style?: ChoiceInputStyle;\n\n  /**\n   * The initial choice (or set of choices) that should be selected. For multi-select, specify a comma-separated string of values.\n   */\n  value?: string;\n\n  /**\n   * Description of the input desired. Only visible when no selection has been made, the `style` is `compact` and `isMultiSelect` is `false`\n   */\n  placeholder?: string;\n\n  /**\n   * If `true`, allow text to wrap. Otherwise, text is clipped.\n   */\n  wrap?: boolean;\n}\n\nexport type ChoiceSetInputOptions = Omit<IChoiceSetInput, 'type' | 'choices'>;\n\n/**\n * Allows a user to input a Choice.\n */\nexport class ChoiceSetInput extends InputElement implements IChoiceSetInput {\n  type: 'Input.ChoiceSet';\n\n  /**\n   * Choice options.\n   */\n  choices: IChoice[];\n\n  /**\n   * Allows dynamic fetching of choices from the bot to be displayed as suggestions in the dropdown when the user types in the input field.\n   */\n  'choices.data'?: IChoiceDataQuery;\n\n  /**\n   * Allow multiple choices to be selected.\n   */\n  isMultiSelect?: boolean;\n\n  /**\n   * the style of the choice input\n   */\n  style?: ChoiceInputStyle;\n\n  /**\n   * The initial choice (or set of choices) that should be selected. For multi-select, specify a comma-separated string of values.\n   */\n  value?: string;\n\n  /**\n   * Description of the input desired. Only visible when no selection has been made, the `style` is `compact` and `isMultiSelect` is `false`\n   */\n  placeholder?: string;\n\n  /**\n   * If `true`, allow text to wrap. Otherwise, text is clipped.\n   */\n  wrap?: boolean;\n\n  constructor(...choices: IChoice[]) {\n    super();\n    this.type = 'Input.ChoiceSet';\n    this.choices = choices;\n  }\n\n  withOptions(value: ChoiceSetInputOptions) {\n    Object.assign(this, value);\n    return this;\n  }\n\n  withData(value: IChoiceDataQuery) {\n    this['choices.data'] = value;\n    return this;\n  }\n\n  withMultiSelect(value = true) {\n    this.isMultiSelect = value;\n    return this;\n  }\n\n  withStyle(value: ChoiceInputStyle) {\n    this.style = value;\n    return this;\n  }\n\n  withValue(value: string) {\n    this.value = value;\n    return this;\n  }\n\n  withPlaceholder(value: string) {\n    this.placeholder = value;\n    return this;\n  }\n\n  withWrap(value = true) {\n    this.wrap = value;\n    return this;\n  }\n\n  addChoices(...value: IChoice[]) {\n    this.choices.push(...value);\n    return this;\n  }\n}\n\n/**\n * Describes a choice for use in a ChoiceSet.\n */\nexport interface IChoice {\n  /**\n   * Text to display.\n   */\n  title: string;\n\n  /**\n   * The raw value for the choice. NOTE: do not use a `,` in the value, since a `ChoiceSet` with `isMultiSelect` set to `true` returns a comma-delimited string of choice values.\n   */\n  value: string;\n}\n\n/**\n * Describes a choice for use in a ChoiceSet.\n */\nexport class Choice implements IChoice {\n  /**\n   * Text to display.\n   */\n  title: string;\n\n  /**\n   * The raw value for the choice. NOTE: do not use a `,` in the value, since a `ChoiceSet` with `isMultiSelect` set to `true` returns a comma-delimited string of choice values.\n   */\n  value: string;\n\n  constructor(title: string, value: string) {\n    this.title = title;\n    this.value = value;\n  }\n}\n\n/**\n * The data populated in the event payload for fetching dynamic choices, sent to the card-author to help identify the dataset from which choices might be fetched to be displayed in the dropdown. It might contain auxillary data to limit the maximum number of choices that can be sent and to support pagination.\n */\nexport interface IChoiceDataQuery {\n  /**\n   * The dataset to be queried to get the choices.\n   */\n  dataset: string;\n\n  /**\n   * The maximum number of choices that should be returned by the query. It can be ignored if the card-author wants to send a different number.\n   */\n  count?: number;\n\n  /**\n   * The number of choices to be skipped in the list of choices returned by the query. It can be ignored if the card-author does not want pagination.\n   */\n  skip?: number;\n}\n\nexport type ChoiceDataQueryOptions = Omit<IChoiceDataQuery, 'dataset'>;\n\n/**\n * The data populated in the event payload for fetching dynamic choices, sent to the card-author to help identify the dataset from which choices might be fetched to be displayed in the dropdown. It might contain auxillary data to limit the maximum number of choices that can be sent and to support pagination.\n */\nexport class ChoiceDataQuery implements IChoiceDataQuery {\n  /**\n   * The dataset to be queried to get the choices.\n   */\n  dataset: string;\n\n  /**\n   * The maximum number of choices that should be returned by the query. It can be ignored if the card-author wants to send a different number.\n   */\n  count?: number;\n\n  /**\n   * The number of choices to be skipped in the list of choices returned by the query. It can be ignored if the card-author does not want pagination.\n   */\n  skip?: number;\n\n  constructor(dataset: string) {\n    this.dataset = dataset;\n  }\n\n  withOptions(value: ChoiceDataQueryOptions) {\n    Object.assign(this, value);\n    return this;\n  }\n\n  withCount(value: number) {\n    this.count = value;\n    return this;\n  }\n\n  withSkip(value: number) {\n    this.skip = value;\n    return this;\n  }\n}\n"]}