/**
 * Mirrors {@see CertificateTemplateDefaults} (PHP): default Regalia + Vertex layouts
 * used for starter tiles in {@link CertificateVisualBuilder} and seeded template posts.
 */
import { __ } from '../../lib/i18n';
import { CERT_LAYOUT_VERSION, type CertLayoutFile } from './certificateLayout';

export function getRegaliaHeritageLayout(): CertLayoutFile {
  return {
    version: CERT_LAYOUT_VERSION,
    blocks: [
      {
        id: 'ht_h1',
        type: 'heading',
        props: {
          x: 8,
          y: 6,
          w: 84,
          h: 9,
          z: 5,
          text: __('Certificate of Achievement', 'sikshya'),
          tag: 'h1',
          align: 'center',
          fontSize: 30,
          color: '#713f12',
          fontWeight: '700',
          fontFamily: 'serif',
          lineHeight: 1.1,
          letterSpacing: 0.06,
        },
      },
      {
        id: 'ht_sub',
        type: 'text',
        props: {
          x: 18,
          y: 15,
          w: 64,
          h: 5,
          z: 4,
          text: __('Official credential awarded to', 'sikshya'),
          align: 'center',
          fontSize: 13,
          color: '#78716c',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.35,
          letterSpacing: 0.08,
        },
      },
      {
        id: 'ht_student',
        type: 'merge_field',
        props: {
          x: 12,
          y: 22,
          w: 76,
          h: 12,
          z: 6,
          field: 'student_name',
          align: 'center',
          fontSize: 38,
          color: '#422006',
          fontWeight: '600',
          fontFamily: 'serif',
          lineHeight: 1.05,
        },
      },
      {
        id: 'ht_rule',
        type: 'divider',
        props: { x: 28, y: 35, w: 44, h: 0.6, z: 3, color: '#d97706', thickness: 2 },
      },
      {
        id: 'ht_lbl',
        type: 'text',
        props: {
          x: 16,
          y: 38,
          w: 68,
          h: 5,
          z: 3,
          text: __('Program completed', 'sikshya'),
          align: 'center',
          fontSize: 12,
          color: '#a16207',
          fontWeight: '700',
          fontFamily: 'sans',
          lineHeight: 1.2,
          letterSpacing: 0.12,
        },
      },
      {
        id: 'ht_course',
        type: 'merge_field',
        props: {
          x: 14,
          y: 43.5,
          w: 72,
          h: 9,
          z: 5,
          field: 'course_name',
          align: 'center',
          fontSize: 24,
          color: '#1c1917',
          fontWeight: '700',
          fontFamily: 'serif',
          lineHeight: 1.18,
          letterSpacing: -0.01,
        },
      },
      {
        id: 'ht_dt',
        type: 'merge_field',
        props: {
          x: 12,
          y: 54,
          w: 35,
          h: 5,
          z: 2,
          field: 'completion_date',
          align: 'left',
          fontSize: 14,
          color: '#44403c',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.2,
        },
      },
      {
        id: 'ht_ins',
        type: 'merge_field',
        props: {
          x: 53,
          y: 54,
          w: 35,
          h: 5,
          z: 2,
          field: 'instructor_name',
          align: 'right',
          fontSize: 14,
          color: '#44403c',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.2,
        },
      },
      {
        id: 'ht_code',
        type: 'merge_field',
        props: {
          x: 12,
          y: 70,
          w: 42,
          h: 6,
          z: 2,
          field: 'verification_code',
          align: 'left',
          fontSize: 11,
          color: '#57534e',
          fontWeight: '500',
          fontFamily: 'mono',
          lineHeight: 1.3,
        },
      },
      {
        id: 'ht_serial',
        type: 'merge_field',
        props: {
          x: 29,
          y: 70,
          w: 42,
          h: 6,
          z: 2,
          field: 'certificate_number',
          align: 'center',
          fontSize: 11,
          color: '#57534e',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.3,
          letterSpacing: 0.04,
        },
      },
      {
        id: 'ht_org',
        type: 'merge_field',
        props: {
          x: 12,
          y: 80,
          w: 76,
          h: 4,
          z: 1,
          field: 'site_name',
          align: 'center',
          fontSize: 12,
          color: '#92400e',
          fontWeight: '700',
          fontFamily: 'sans',
          lineHeight: 1.2,
          letterSpacing: 0.04,
        },
      },
    ],
  };
}

export function getVertexModernLayout(): CertLayoutFile {
  return {
    version: CERT_LAYOUT_VERSION,
    blocks: [
      {
        id: 'vx_top',
        type: 'divider',
        props: { x: 0, y: 0, w: 100, h: 3.2, z: 6, color: '#0d9488', thickness: 12 },
      },
      {
        id: 'vx_small',
        type: 'heading',
        props: {
          x: 5,
          y: 8,
          w: 40,
          h: 6,
          z: 8,
          text: __('Certificate', 'sikshya'),
          tag: 'h1',
          align: 'left',
          fontSize: 11,
          color: '#94a3b8',
          fontWeight: '800',
          fontFamily: 'sans',
          lineHeight: 1.0,
          letterSpacing: 0.42,
        },
      },
      {
        id: 'vx_big',
        type: 'heading',
        props: {
          x: 5,
          y: 13,
          w: 40,
          h: 5,
          z: 8,
          text: __('Of completion', 'sikshya'),
          tag: 'h2',
          align: 'left',
          fontSize: 22,
          color: '#0f172a',
          fontWeight: '800',
          fontFamily: 'sans',
          lineHeight: 1.05,
          letterSpacing: -0.02,
        },
      },
      {
        id: 'vx_issuer',
        type: 'text',
        props: {
          x: 62,
          y: 9,
          w: 32,
          h: 5,
          z: 5,
          text: `${__('Issuer', 'sikshya')}\n{{site_name}}`,
          align: 'right',
          fontSize: 12,
          color: '#64748b',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.35,
          letterSpacing: 0.02,
        },
      },
      {
        id: 'vx_grant',
        type: 'merge_field',
        props: {
          x: 58,
          y: 15,
          w: 38,
          h: 4,
          z: 4,
          field: 'completion_date',
          align: 'right',
          fontSize: 11,
          color: '#94a3b8',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.3,
          letterSpacing: 0.03,
        },
      },
      {
        id: 'vx_pres',
        type: 'text',
        props: {
          x: 22,
          y: 32,
          w: 70,
          h: 5,
          z: 4,
          text: __('This certifies that', 'sikshya'),
          align: 'left',
          fontSize: 13,
          color: '#64748b',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.4,
          letterSpacing: 0.05,
        },
      },
      {
        id: 'vx_student',
        type: 'merge_field',
        props: {
          x: 22,
          y: 38.5,
          w: 70,
          h: 12,
          z: 6,
          field: 'student_name',
          align: 'left',
          fontSize: 44,
          color: '#0f172a',
          fontWeight: '700',
          fontFamily: 'sans',
          lineHeight: 1.0,
          letterSpacing: -0.03,
        },
      },
      {
        id: 'vx_rule',
        type: 'divider',
        props: { x: 22, y: 52.5, w: 70, h: 0.55, z: 3, color: '#e2e8f0', thickness: 3 },
      },
      {
        id: 'vx_ok',
        type: 'text',
        props: {
          x: 22,
          y: 55,
          w: 65,
          h: 5,
          z: 4,
          text: __('Successfully completed', 'sikshya'),
          align: 'left',
          fontSize: 12,
          color: '#64748b',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.35,
          letterSpacing: 0.04,
        },
      },
      {
        id: 'vx_course',
        type: 'merge_field',
        props: {
          x: 22,
          y: 60.5,
          w: 72,
          h: 9,
          z: 5,
          field: 'course_name',
          align: 'left',
          fontSize: 26,
          color: '#0d9488',
          fontWeight: '700',
          fontFamily: 'sans',
          lineHeight: 1.12,
          letterSpacing: -0.02,
        },
      },
      {
        id: 'vx_ins',
        type: 'merge_field',
        props: {
          x: 22,
          y: 74,
          w: 30,
          h: 4,
          z: 2,
          field: 'instructor_name',
          align: 'left',
          fontSize: 12,
          color: '#475569',
          fontWeight: '600',
          fontFamily: 'sans',
          lineHeight: 1.25,
        },
      },
      {
        id: 'vx_cod',
        type: 'merge_field',
        props: {
          x: 44,
          y: 74,
          w: 30,
          h: 4,
          z: 2,
          field: 'verification_code',
          align: 'center',
          fontSize: 11,
          color: '#64748b',
          fontWeight: '500',
          fontFamily: 'mono',
          lineHeight: 1.25,
        },
      },
    ],
  };
}

export function cloneRegaliaSeed(): CertLayoutFile {
  return JSON.parse(JSON.stringify(getRegaliaHeritageLayout())) as CertLayoutFile;
}

export function cloneVertexSeed(): CertLayoutFile {
  return JSON.parse(JSON.stringify(getVertexModernLayout())) as CertLayoutFile;
}
