// Portfolio Terminal demo data for the read-only presentation account.
// Fictional holdings only -- clearly labelled as an example in name/notes so
// nobody mistakes it for a real position. Manually entered transactions
// (type buy/sell/deposit/withdrawal/income), the same shape the app itself
// writes when a user fills the terminal in by hand -- no import-specific
// fields (externalProvider, dedupeKey, ...) are needed here.

interface DemoTransaction {
  id: string;
  type: 'buy' | 'sell' | 'deposit' | 'withdrawal' | 'income';
  date: string;
  asset?: string;
  qty?: number;
  price?: number;
  currency?: string;
  quoteAmount?: number;
  totalAmount?: number;
  feeQty?: number;
  feeAsset?: string;
  cashAmount?: number;
  cashCurrency?: string;
  note?: string;
}

const tx: DemoTransaction[] = [
  { id: 'demo-pf-01', type: 'deposit', date: '2025-01-10', cashAmount: 60000, cashCurrency: 'EUR', note: 'Beispiel-Kapitaleinlage' },
  { id: 'demo-pf-02', type: 'buy', date: '2025-01-15', asset: 'BTC', qty: 0.5, price: 42000, currency: 'EUR', quoteAmount: 21000, totalAmount: 21015, feeQty: 15, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-03', type: 'buy', date: '2025-02-10', asset: 'ETH', qty: 6, price: 2600, currency: 'EUR', quoteAmount: 15600, totalAmount: 15612, feeQty: 12, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-04', type: 'buy', date: '2025-03-05', asset: 'SOL', qty: 80, price: 145, currency: 'EUR', quoteAmount: 11600, totalAmount: 11609, feeQty: 9, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-05', type: 'deposit', date: '2025-04-20', cashAmount: 20000, cashCurrency: 'EUR', note: 'Beispiel-Kapitaleinlage' },
  { id: 'demo-pf-06', type: 'buy', date: '2025-05-10', asset: 'DOT', qty: 900, price: 6.2, currency: 'EUR', quoteAmount: 5580, totalAmount: 5585, feeQty: 5, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-07', type: 'buy', date: '2025-06-15', asset: 'ONDO', qty: 4000, price: 0.85, currency: 'EUR', quoteAmount: 3400, totalAmount: 3403, feeQty: 3, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-08', type: 'buy', date: '2025-08-01', asset: 'BTC', qty: 0.15, price: 58000, currency: 'EUR', quoteAmount: 8700, totalAmount: 8707, feeQty: 7, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-09', type: 'sell', date: '2025-10-05', asset: 'SOL', qty: 30, price: 165, currency: 'EUR', quoteAmount: 4950, totalAmount: 4946, feeQty: 4, feeAsset: 'EUR', note: 'Beispiel-Teilverkauf' },
  { id: 'demo-pf-10', type: 'buy', date: '2025-11-20', asset: 'ETH', qty: 2, price: 3100, currency: 'EUR', quoteAmount: 6200, totalAmount: 6205, feeQty: 5, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-11', type: 'withdrawal', date: '2026-01-15', cashAmount: 8000, cashCurrency: 'EUR', note: 'Beispiel-Entnahme' },
  { id: 'demo-pf-12', type: 'buy', date: '2026-02-10', asset: 'SOL', qty: 25, price: 190, currency: 'EUR', quoteAmount: 4750, totalAmount: 4754, feeQty: 4, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-13', type: 'buy', date: '2026-03-05', asset: 'BTC', qty: 0.1, price: 68000, currency: 'EUR', quoteAmount: 6800, totalAmount: 6805, feeQty: 5, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-14', type: 'sell', date: '2026-04-18', asset: 'DOT', qty: 200, price: 7.1, currency: 'EUR', quoteAmount: 1420, totalAmount: 1419, feeQty: 1, feeAsset: 'EUR', note: 'Beispiel-Teilverkauf' },
  { id: 'demo-pf-15', type: 'income', date: '2026-07-01', asset: 'SOL', qty: 2.5, price: 0, currency: 'EUR', quoteAmount: 0, note: 'Beispiel-Staking-Ertrag' },
  { id: 'demo-pf-16', type: 'buy', date: '2026-06-25', asset: 'BTC', qty: 0.05, price: 58400, currency: 'EUR', quoteAmount: 2920, totalAmount: 2922, feeQty: 2, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-17', type: 'buy', date: '2026-08-10', asset: 'ONDO', qty: 1500, price: 0.65, currency: 'EUR', quoteAmount: 975, totalAmount: 976, feeQty: 1, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
  { id: 'demo-pf-18', type: 'buy', date: '2026-09-01', asset: 'ETH', qty: 1, price: 2300, currency: 'EUR', quoteAmount: 2300, totalAmount: 2302, feeQty: 2, feeAsset: 'EUR', note: 'Beispiel-Kauf' },
];

/** Full `ck_portfolio_terminal_v6` app state, ready to JSON.stringify. */
export function buildPortfolioDemoState() {
  return {
    activePid: 'demo-portfolio',
    portfolios: [
      {
        id: 'demo-portfolio',
        name: 'CK Musterportfolio',
        platform: '',
        accountLabel: 'Beispielkonto',
        owner: '',
        accountType: 'private',
        ckMandate: '',
        note: 'Beispielportfolio zur Vorstellung des CK Portfolio Terminals — keine echten Bestände.',
        tx,
      },
    ],
  };
}
