import type { ReactNode } from 'react'
import type { MsgProps } from './CTX'
import type INPUTPROPS from './INPUTPROPS'
import { CustomOption } from './UI'

export type ActionItem = {
  key: string
  icon?: any
  src?: string
  alt?: string
  click(ev: any, opt: MsgProps): void
}

export type ToolBarType = 'copy' | 'broad' | 'likes' | 'dislikes' | 'cite' | ActionItem

export type CautionItem = {
  ItemIcon?: ReactNode
  ItemName?: string
  ItemDesc?: string
  key: string
  [k: string]: any
}

export type InputOrderCaution = {
  currentKey?: string // 建议将 item 改成 key
  // selectedItem?: CautionItem
  title?: string
  list?: Array<CautionItem>
  ContentRender?: (opt: CautionItem) => ReactNode
  ListRender?: (opt: CautionItem) => ReactNode
}

// type HttpUrl = string extends `http${infer P}` ? P : never;// ?不能将类型“string”分配给类型“never”
// const ABC: HttpUrl = 'http://picx.zhimg.com/v2-3947c985edf0444511b20cd1dfdd467e_r.jpg?source=2c26e567'

// 全局配置，会传递给Chat组件及内部
export interface AppConfig {
  /** 语言 默认为zh */
  language?: 'en' | 'zh'

  /** 对话区域的顶部中心内容 */
  title?: string | ReactNode

  robot?: {
    /** 助手Logo: ReactNode | 图片地址
     *  ReactNode.className 图标主题颜色:text-theme-shal-7 图标前缀:iconfont-assistant 
     *  string 网络图片地址
     */
    avatar?: ReactNode | string
    /** 助手名称 */
    name?: string
  }

  user?: {
    /** 用户头像: ReactNode | 图片地址
    *  ReactNode.className 图标主题颜色 text-theme-shal-7 图标前缀:iconfont-assistant
    *  string 网络图片地址
    */
    avatar?: ReactNode | string
    /** name:用户名称 */
    name?: string
  }

  /** 流式返回停止前的闪烁效果 animate-content=卡片闪烁，animate-cursor=结尾光标闪烁 */
  fetchPendClass?: 'DS-GA-animate-content' | 'DS-GA-animate-cursor'

  /** 输入框 */
  inputProps?: INPUTPROPS

  /** 初始时展示的消息 */
  defaultMessages?: Array<MsgProps>

  /** 指令 @ */
  inputOrderCaution?: InputOrderCaution

  /** 自动重置消息 */
  autoResetMessages?: boolean

  /** 消息工具栏支持列表 */
  toolbarlist?: Array<ToolBarType>

  /** 是否在需要的时候显示引导语 */
  showGuideIfNeed?: boolean
}
