/*
 * @Author: ZhaoYing 
 * @Date: 2026-02-03 16:34:15 
 * @Last Modified by: ZhaoYing
 * @Last Modified time: 2026-03-16 09:55:52
 */
/**
 * Type definitions for Application Management
 */
import type { WorkflowConfig } from '@/views/Workflow/types';
/**
 * Search query parameters
 */
export interface Query {
  /** Search keyword */
  search: string;
  type?: string;
  shared_only?: boolean;
}

/**
 * Application data structure
 */
export interface Application {
  /** Application ID */
  id: string;
  /** Workspace ID */
  workspace_id: string;
  /** Creator user ID */
  created_by: string;
  /** Application name */
  name: string;
  /** Application description */
  description?: string;
  /** Icon URL */
  icon?: string;
  /** Icon type */
  icon_type?: string;
  /** Application type: agent, multi_agent, or workflow */
  type: 'agent' | 'multi_agent' | 'workflow';
  /** Visibility setting */
  visibility: string;
  /** Application status */
  status: string;
  /** Application tags */
  tags: string[];
  /** Current release version ID */
  current_release_id?: string;
  /** Whether application is active */
  is_active: boolean;
  /** Whether application is shared */
  is_shared: boolean;
  /** Creation timestamp */
  created_at: number;
  /** Last update timestamp */
  updated_at: number;
  share_permission?: string;
  source_workspace_name?: string;
  source_workspace_icon?: string;
  source_app_version?: string;
  source_app_is_active?: boolean;
}

/**
 * Application creation/edit form data
 */
export interface ApplicationModalData {
  /** Application name */
  name: string;
  /** Application type */
  type: string;
  /** Application description */
  description?: string;
  /** Icon upload data */
  icon: {
    url: string;
    uid: string | number;
  }[];
}

/**
 * Application modal ref interface
 */
export interface ApplicationModalRef {
  /** Open modal with optional application data for editing */
  handleOpen: (application?: Application) => void;
}

/**
 * Model configuration modal ref interface
 */
export interface ModelConfigModalRef {
  /** Open modal with application data */
  handleOpen: (application?: Application) => void;
}

/**
 * Model configuration form data
 */
export interface ModelConfigModalData {
  /** Selected model */
  model: string;
  /** Additional configuration fields */
  [key: string]: string;
}

/**
 * AI prompt modal ref interface
 */
export interface AiPromptModalRef {
  /** Open modal with application data */
  handleOpen: (application?: Application) => void;
}

/**
 * Variable modal ref interface
 */
export interface VariableModalRef {
  /** Open modal with application data */
  handleOpen: (application?: Application) => void;
}

/**
 * Variable modal props
 */
export interface VariableModalProps {
  /** Callback to refresh variable list */
  refresh: () => void;
}

/**
 * Variable edit modal ref interface
 */
export interface VariableEditModalRef {
  /** Open modal with optional variable data */
  handleOpen: (values?: Variable) => void;
}

/**
 * Variable data structure
 */
export interface Variable {
  /** Variable index */
  index?: number;
  /** Variable type */
  type: string;
  /** Variable key */
  key: string;
  /** Variable name */
  name: string;
  /** Maximum length for string types */
  maxLength?: number;
  /** Default value */
  defaultValue?: string;
  /** Options for select type */
  options?: string[];
  /** Whether variable is required */
  required: boolean;
  /** Whether variable is hidden */
  hidden?: boolean;
}

/**
 * API extension configuration data
 */
export interface ApiExtensionModalData {
  /** Extension name */
  name: string;
  /** API endpoint URL */
  apiEndpoint: string;
  /** API authentication key */
  apiKey: string;
}

/**
 * API extension modal ref interface
 */
export interface ApiExtensionModalRef {
  /** Open API extension modal */
  handleOpen: () => void;
}

/**
 * Upload workflow modal form data
 */
export interface UploadWorkflowModalData {
  /** Platform type (e.g., 'dify') */
  platform: string;
  /** Array of uploaded files */
  file: any[];
  /** Optional workflow name */
  name?: string;
  /** Optional original file name */
  fileName?: string;
  /** Optional file size in bytes */
  fileSize?: number;
  /** Optional workflow description */
  description?: string;
}

/**
 * Complex item for errors and warnings
 */
interface ComplexItem {
  /** Error/warning type */
  type: string;
  /** Detailed error/warning message */
  detail: string;
  /** Node identifier where the error/warning occurred */
  node_id: string;
  /** Node name where the error/warning occurred */
  node_name: string;
  /** Optional scope of the error/warning */
  scope: string | null;
  /** Optional name associated with the error/warning */
  name: string | null;
}

/**
 * Upload data response
 * @extends WorkflowConfig
 */
export interface UploadData extends WorkflowConfig {
  /** Whether the upload was successful */
  success: boolean;
  /** Temporary identifier for the uploaded workflow */
  temp_id: string;
  /** Optional workflow identifier if already exists */
  workflow_id?: string;
  /** Array of error items */
  errors: ComplexItem[];
  /** Array of warning items */
  warnings: ComplexItem[];
}

/**
 * Upload workflow modal ref interface
 */
export interface UploadWorkflowModalRef {
  /** Open the upload workflow modal */
  handleOpen: () => void;
}

/**
 * Upload app modal ref interface
 */
export interface UploadModalRef {
  /** Open the upload workflow modal */
  handleOpen: () => void;
}
export interface MySharedOutItem {
  id: string;
  source_app_id: string;
  source_workspace_id: string;
  target_workspace_id: string;
  shared_by: string;
  permission: 'readonly' | 'editable';
  created_at: number;
  updated_at: number;
  source_app_name: string;
  source_app_type: string;
  source_app_version: string;
  source_app_is_active: boolean;
  target_workspace_name: string;
  target_workspace_icon: string;
}