import { ComponentMetadata, Snippet } from '@alilc/lowcode-types';

/**
 * PisellFinancialSummary 组件 LowCode Meta
 * 资金汇总：Balance Due + Total + Paid + Refund 层级展示
 */
const PisellFinancialSummaryMeta: ComponentMetadata = {
  componentName: 'PisellFinancialSummary',
  title: '资金汇总',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/private-materials',
    version: '3.4.86',
    exportName: 'PisellFinancialSummary',
    main: 'src/index.ts',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: {
          label: { type: 'i18n', 'en-US': 'data', 'zh-CN': '数据' },
        },
        name: 'data',
        description: '资金汇总数据：balanceDue、total、paid、refund',
        setter: ['JsonSetter', 'VariableSetter'],
        isRequired: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'showTotal', 'zh-CN': '显示 Total' } },
        name: 'showTotal',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'showPaid', 'zh-CN': '显示 Paid' } },
        name: 'showPaid',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'showRefund', 'zh-CN': '显示 Refund' } },
        name: 'showRefund',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'showItemsCount', 'zh-CN': '显示 N items' } },
        name: 'showItemsCount',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'showInfoIcon', 'zh-CN': '显示提示图标' } },
        name: 'showInfoIcon',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'hideZeroAmountRows', 'zh-CN': '隐藏 0 金额行' } },
        name: 'hideZeroAmountRows',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: false,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'currencySymbol', 'zh-CN': '货币符号' } },
        name: 'currencySymbol',
        setter: ['StringSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'amountPrecision', 'zh-CN': '金额小数位' } },
        name: 'amountPrecision',
        setter: ['NumberSetter', 'VariableSetter'],
        defaultValue: 2,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'useThousandsSeparator', 'zh-CN': '千分位' } },
        name: 'useThousandsSeparator',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: false,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'hideDecimalForWholeNumbers', 'zh-CN': '整数隐藏 .00' } },
        name: 'hideDecimalForWholeNumbers',
        setter: ['BoolSetter', 'VariableSetter'],
        defaultValue: true,
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'titleBalanceDue', 'zh-CN': '标题：Balance due' } },
        name: 'titleBalanceDue',
        setter: ['PisellI18nSetter', 'StringSetter', 'SlotSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'titleTotal', 'zh-CN': '标题：Total' } },
        name: 'titleTotal',
        setter: ['PisellI18nSetter', 'StringSetter', 'SlotSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'titlePaid', 'zh-CN': '标题：Paid' } },
        name: 'titlePaid',
        setter: ['PisellI18nSetter', 'StringSetter', 'SlotSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'titleRefund', 'zh-CN': '标题：Refund' } },
        name: 'titleRefund',
        setter: ['PisellI18nSetter', 'StringSetter', 'SlotSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'missingValuePlaceholder', 'zh-CN': '缺失占位符' } },
        name: 'missingValuePlaceholder',
        setter: ['StringSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'className', 'zh-CN': '类名' } },
        name: 'className',
        setter: ['StringSetter', 'VariableSetter'],
      },
      {
        title: { label: { type: 'i18n', 'en-US': 'style', 'zh-CN': '样式' } },
        name: 'style',
        setter: ['StyleSetter', 'VariableSetter'],
      },
    ],
    supports: {
      style: true,
      className: true,
    },
    component: {
      isContainer: false,
    },
  },
};

const snippets: Snippet[] = [
  {
    title: '资金汇总',
    screenshot: '',
    schema: {
      componentName: 'PisellFinancialSummary',
      props: {
        data: {
          balanceDue: 54,
          total: {
            value: 54,
            children: [
              { label: 'Subtotal', value: 60.2, itemsCount: '3 items' },
              { label: 'GST/Tax', value: 1, infoTooltip: 'Tax' },
              { label: 'Discount', value: -5 },
            ],
          },
          paid: [
            { methodName: 'Card', amount: 54, time: '14:00' },
          ],
          refund: [],
        },
        currencySymbol: 'A$',
      },
    },
  },
];

export default {
  ...PisellFinancialSummaryMeta,
  snippets,
};
