/**
 * Copyright Super iPaaS Integration LLC, an IBM Company 2024
 */
import { AssetModelKindConstants, POLICY_KINDS } from "./base-asset.model.js";
import { EditorTab } from "./editor-tab.model.js";

export interface EditorTabsInfo {
  editorId: number;
  tabs: EditorTab[];
  activeTab: EditorTab | -1;
  hm: HashMap;
}

export interface EditorTabItem {
  activeEditor: boolean;
  editorTab: EditorTab;
  position: { line: number, column: number };
  tabsHeight: number;
  width: number;
  setUnSavedTabs: React.Dispatch<React.SetStateAction<number[]>>;
  fileName: string;
}

interface HashMap {
  [key: string]: NestedHashMap;
}
interface NestedHashMap {
  [key: string]: string;
}

export const FormViewSupportedKinds = [
  AssetModelKindConstants.API,
  AssetModelKindConstants.Test,
  AssetModelKindConstants.Assertion,
  AssetModelKindConstants.Environment,
  AssetModelKindConstants.PolicySequence,
  AssetModelKindConstants.GlobalPolicy,
  'OPENAPI',
  'POLICY',
  'SWAGGER'
];

export const FormViewUnsupportedKinds: Record<string, string> = {
  'swagger': 'swagger',
  [AssetModelKindConstants.Plan.toLowerCase()]: 'plan',
  [AssetModelKindConstants.Package.toLowerCase()]: 'package',
  [AssetModelKindConstants.SetContextVariable.toLowerCase()]: 'set context varaible',
  [AssetModelKindConstants.WebMethodsISService.toLowerCase()]: 'invoke WebMethods IS Service',
  [AssetModelKindConstants.InvokeAWSLambdaFunction.toLowerCase()]: 'invoke AWS Lambda function',
  [AssetModelKindConstants.MessageConfig.toLowerCase()]: 'message config',
  [AssetModelKindConstants.InvokeMessagingExtension.toLowerCase()]: 'invoke messaging extension',
  [AssetModelKindConstants.TransformRequest.toLowerCase()]: 'transform request',
  [AssetModelKindConstants.ValidateAPISpecification.toLowerCase()]: 'validate API specification',
  [AssetModelKindConstants.WebMethodsISService.toLowerCase()]: 'WebMethods IS service',
  [AssetModelKindConstants.Route.toLowerCase()]: 'routing',
  [AssetModelKindConstants.OutboundAlias.toLowerCase()]: 'outbound alias',
  [AssetModelKindConstants.OutboundAnonymous.toLowerCase()]: 'outbound anonymous',
  [AssetModelKindConstants.OutboundBasicAuth.toLowerCase()]: 'outbound basic auth',
  [AssetModelKindConstants.OutboundIncomingJWT.toLowerCase()]: 'outbound incoming JWT',
  [AssetModelKindConstants.OutboundKerberosAuth.toLowerCase()]: 'outbound kerberos auth',
};

export const API_FORM_VIEW_VALID_KINDS = [AssetModelKindConstants.API.toLowerCase(), 'openapi'];
export const POLICY_FORM_VIEW_VALID_KINDS = [AssetModelKindConstants.PolicySequence.toLowerCase(), ...POLICY_KINDS.map(kind => kind.toLowerCase()), AssetModelKindConstants.GlobalPolicy.toLowerCase()];
export const TEST_FORM_VIEW_VALID_KINDS = [AssetModelKindConstants.Assertion.toLowerCase(), AssetModelKindConstants.Environment.toLowerCase(), AssetModelKindConstants.Test.toLowerCase()];