import { Component, OnInit } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton, IonIcon, ModalController, IonProgressBar } from '@ionic/angular/standalone';
import { AgentTaskStep } from 'src/app/agent/agent.task';
import { addIcons } from 'ionicons';
import { radioButtonOffOutline, reloadOutline, checkmarkCircleOutline, closeCircleOutline } from 'ionicons/icons';
import { FmodeChatCompletion, ImagineWork, DalleOptions } from "fmode-ng";
import { DecimalPipe } from '@angular/common';
import { startTask } from '../agent/agent.start';
import { TaskPoemPictureDesc } from '../agent/tasks/poem/poem-desc';
import { TaskPoemPictureCreate } from '../agent/tasks/poem/poem-picture';
import { TaskInqueryUserStory } from '../agent/tasks/poem/inquiry/1.inquiry-user-story';
import { TaskInqueryDoctorQuestion } from '../agent/tasks/poem/inquiry/2.inquiry-doctor-question';
import { TaskInqueryUserAnswer } from '../agent/tasks/poem/inquiry/3.inquiry-user-answer';
addIcons({ radioButtonOffOutline, reloadOutline, checkmarkCircleOutline, closeCircleOutline })
@Component({
  selector: 'app-tab2',
  templateUrl: 'tab2.page.html',
  styleUrls: ['tab2.page.scss'],
  standalone: true,
  imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton,
    IonProgressBar, IonIcon, DecimalPipe]
})
export class Tab2Page {
  //使用model弹出框就需要一个构造器先声明
  constructor(private modalCtrl: ModalController) {


  }

  taskList: AgentTaskStep[] = []
  //一个等待一秒的函数  每经过一秒
  wait(duration: number = 1000) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve(true)
      }, duration);
    })
  }

  shareData: any = {}

  // 任务：完成故事意境描述及图像绘制
  doPoemTask() {
    let task1 = TaskPoemPictureDesc({ shareData: this.shareData, modalCtrl: this.modalCtrl });
    let task2 = TaskPoemPictureCreate({ shareData: this.shareData, modalCtrl: this.modalCtrl });
    let PoemTaskList = [task1, task2]
    this.taskList = PoemTaskList
    startTask(PoemTaskList)
  }

  doInqueryTask() {
    let task1 = TaskInqueryUserStory({ shareData: this.shareData, modalCtrl: this.modalCtrl });
    let task2 = TaskInqueryDoctorQuestion({ shareData: this.shareData, modalCtrl: this.modalCtrl });
    let task3 = TaskInqueryUserAnswer({ shareData: this.shareData, modalCtrl: this.modalCtrl });

    // 定义任务集
    let InquireServiceTaskList = [
      task1, task2, task3
    ]
    // 传递给显示组件
    this.taskList = InquireServiceTaskList
    // 开始执行任务
    startTask(InquireServiceTaskList)
  }


}
