import { Component,OnInit } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonIcon, ModalController } from '@ionic/angular/standalone';
import { AgentTaskStep } from 'src/agent/agent.task';
import { addIcons } from 'ionicons';
import { radioButtonOffOutline, reloadOutline, checkmarkCircleOutline, closeCircleOutline } from 'ionicons/icons';
import { TaskExecutor } from 'src/agent/agent.start';
import { AgentUserInputComponent } from 'src/agent/agent-user-input/agent-user-input.component';
import { getUserInput } from 'src/agent/agent.input';
import { FmodeChatCompletion, ImagineWork, DalleOptions } from "fmode-ng";
import { TaskPoemPictureDesc } from 'src/agent/tasks/poem/poem-desc';
import { TaskPoemPictureCreate } from 'src/agent/tasks/poem/poem-picture';
import { DecimalPipe } from '@angular/common';
import { TaskInqueryUserStory } from 'src/agent/tasks/inquiry/1.inquiry-user-story';
import { extactAndParseJsonFromString } from 'src/agent/agent.json';
import { TaskInqueryDoctorQuestion } from 'src/agent/tasks/inquiry/2.inquiry-doctor-question';
import { TaskInqueryUserAnswer } from 'src/agent/tasks/inquiry/3.inquiry-user-answer';
addIcons({radioButtonOffOutline,reloadOutline,checkmarkCircleOutline,closeCircleOutline})
@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss'],
  standalone: true,
  imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton,
    IonIcon,DecimalPipe
  ],
})
export class Tab1Page  {


  constructor(private modalCtrl:ModalController) {


  }

  taskList:AgentTaskStep[] = []

  wait(duration:number=1000){
    return new Promise(resolve=>{
      setTimeout(() => {
          resolve(true)
      }, duration);
    })
  }

  shareData:any = {}

  // 任务：完成故事意境描述及图像绘制
  doPoemTask(){
    // 产生： shareData.PictureDescResult 生成后描述
    let task1 = TaskPoemPictureDesc({shareData:this.shareData,modalCtrl:this.modalCtrl});
    // 产生： shareData.images 渲染后图片
    let task2 = TaskPoemPictureCreate({shareData:this.shareData,modalCtrl:this.modalCtrl});
    
    // 定义任务集
    let PoemTaskList = [task1,task2]
    // 传递给显示组件
    this.taskList = PoemTaskList
    // 开始执行任务
    TaskExecutor(PoemTaskList)
  }


  testJSON(){
    let string = `
          ''''json
              {
                  "keshi": "神经内科",
                  "sympList": [
                      {
                          "title": "偏头痛",
                          "desc": "持续了2天的偏头疼",
                          "duration": "2天"
                      },
                      {
                          "title": "发冷",
                          "desc": "感觉发冷，已经有一天",
                          "duration": "1天"
                      }
                  ]
              }
              ''''
      `
      console.log(extactAndParseJsonFromString(string))
  }
  // 任务集：医疗问诊任务集 完成一次完整的门诊服务
  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
    // 开始执行任务
    TaskExecutor(InquireServiceTaskList)
  }




}
