// DBIS International Arbitration Statutes (DIAS) - Type Definitions

export enum ArbitrationCaseType {
  SETTLEMENT_DISCREPANCY = 'SETTLEMENT_DISCREPANCY',
  FX_CONVERSION_DISPUTE = 'FX_CONVERSION_DISPUTE',
  CBDC_CONTRACT_VIOLATION = 'CBDC_CONTRACT_VIOLATION',
  COMMODITY_TOKEN_DISPUTE = 'COMMODITY_TOKEN_DISPUTE',
  SMART_CONTRACT_DISPUTE = 'SMART_CONTRACT_DISPUTE',
  CROSS_BORDER_DISPUTE = 'CROSS_BORDER_DISPUTE',
}

export enum ArbitrationPhase {
  SUBMISSION = 'SUBMISSION',
  VERIFICATION = 'VERIFICATION',
  HEARING = 'HEARING',
  DECISION = 'DECISION',
  EXECUTION = 'EXECUTION',
  CLOSED = 'CLOSED',
}

export enum ArbitrationDecision {
  FAVOR_CLAIMANT = 'FAVOR_CLAIMANT',
  FAVOR_RESPONDENT = 'FAVOR_RESPONDENT',
  PARTIAL = 'PARTIAL',
  DISMISSED = 'DISMISSED',
}

export enum EnforcementAction {
  ACCOUNT_FREEZE = 'ACCOUNT_FREEZE',
  SETTLEMENT_REVERSAL = 'SETTLEMENT_REVERSAL',
  LIQUIDITY_PENALTY = 'LIQUIDITY_PENALTY',
  SUSPENSION_OF_PRIVILEGES = 'SUSPENSION_OF_PRIVILEGES',
  NO_ACTION = 'NO_ACTION',
}

export interface ArbitrationPanel {
  id: string;
  caseId: string;
  scbRepresentative: {
    identityId: string;
    sovereignBankId: string;
    name: string;
  };
  dbisLegalAuthority: {
    identityId: string;
    name: string;
    title: string;
  };
  independentArbitrator: {
    identityId: string;
    name: string;
    credentials: string[];
  };
  assignedAt: Date;
}

export interface ArbitrationCase {
  id: string;
  caseType: ArbitrationCaseType;
  phase: ArbitrationPhase;
  claimant: {
    entityId: string;
    entityType: 'SCB' | 'PRIVATE_BANK' | 'INSTITUTION' | 'OTHER';
    name: string;
  };
  respondent: {
    entityId: string;
    entityType: 'SCB' | 'PRIVATE_BANK' | 'INSTITUTION' | 'OTHER';
    name: string;
  };
  claim: {
    description: string;
    amount?: string; // If monetary
    currencyCode?: string;
    evidence: Array<{
      type: string;
      data: Record<string, unknown>;
      timestamp: Date;
    }>;
  };
  panel?: ArbitrationPanel;
  ledgerEntries?: Array<{
    entryId: string;
    ledgerId: string;
    verified: boolean;
  }>;
  signatures?: Array<{
    identityId: string;
    signature: string;
    timestamp: Date;
  }>;
  decision?: {
    decision: ArbitrationDecision;
    reasoning: string;
    awardedAmount?: string;
    currencyCode?: string;
    decidedAt: Date;
    decidedBy: string; // Panel ID
  };
  enforcement?: {
    actions: EnforcementAction[];
    executed: boolean;
    executedAt?: Date;
  };
  submittedAt: Date;
  closedAt?: Date;
  metadata?: Record<string, unknown>;
}

export interface ArbitrationSubmission {
  caseType: ArbitrationCaseType;
  claimant: {
    entityId: string;
    entityType: 'SCB' | 'PRIVATE_BANK' | 'INSTITUTION' | 'OTHER';
    name: string;
  };
  respondent: {
    entityId: string;
    entityType: 'SCB' | 'PRIVATE_BANK' | 'INSTITUTION' | 'OTHER';
    name: string;
  };
  claim: {
    description: string;
    amount?: string;
    currencyCode?: string;
    evidence: Array<{
      type: string;
      data: Record<string, unknown>;
    }>;
  };
  metadata?: Record<string, unknown>;
}

export interface LedgerVerificationResult {
  entryId: string;
  ledgerId: string;
  verified: boolean;
  signatureValid: boolean;
  timestampValid: boolean;
  amountMatches: boolean;
  issues?: string[];
}

export interface ArbitrationDecisionRequest {
  caseId: string;
  decision: ArbitrationDecision;
  reasoning: string;
  awardedAmount?: string;
  currencyCode?: string;
}

