import React from "react";

export type ConfigFieldType =
  | "text"
  | "number"
  | "switch"
  | "select"
  | "textarea"
  | "color"
  | "slider"
  | "multi-select"
  | "key-value"
  | "column-picker"
  | "checkbox"
  | "combobox";

export interface ConfigOption {
  label: string;
  value: string;
  description?: string;
}

export interface ConfigFieldDefinition<T = any> {
  key: string;
  label: string;
  type: ConfigFieldType;
  description?: string;
  placeholder?: string;
  options?: ConfigOption[];
  min?: number;
  max?: number;
  step?: number;
  condition?: (config: T) => boolean;
  disabled?: (config: T) => boolean;
}

export interface ConfigSectionDefinition<T = any> {
  id: string;
  title: string;
  description?: string;
  collapsible?: boolean;
  defaultOpen?: boolean;
  fields: ConfigFieldDefinition<T>[];
  condition?: (config: T) => boolean;
  group?: string;
}

export interface ConfigPanelBuilderProps<T = any> {
  config: T;
  onChange: (key: string, value: any) => void;
  onConfigChange?: (config: Record<string, any>) => void;
  sections: ConfigSectionDefinition<T>[];
  presets?: Array<{
    label: string;
    description?: string;
    values: Partial<T>;
  }>;
  tableColumns?: ConfigOption[];
  children?: React.ReactNode;
  mode?: "flat" | "tabs";
  context?: ConfigPanelContext;
}

/**
 * 설정 패널에 전달되는 화면/컴포넌트 컨텍스트 정보
 */
export interface ConfigPanelContext {
  tables?: any[];
  tableColumns?: any[];
  screenTableName?: string;
  menuObjid?: number;
  allComponents?: any[];
  currentComponent?: any;
  allTables?: any[];
  screenComponents?: any[];
  currentScreenCompanyCode?: string;
}

/**
 * 모든 ConfigPanel이 공통으로 받는 표준 Props
 */
export interface StandardConfigPanelProps {
  config: Record<string, any>;
  onChange: (config: Record<string, any>) => void;
  context?: ConfigPanelContext;
}
