// ── Shared profile field definitions ─────────────────────────────────────────
// This module is the single source of truth for required profile fields,
// document fields, and portfolio sections per role.
// Used by both ProfilePage and MyDashboardPage to compute missing labels
// without any hardcoded role-specific branching.

export type BasicField = {
  key: string;
  label: string;
  type?: string;
  required?: boolean;
  options?: string[];
};

export type DocField = {
  key: string;
  label: string;
  required?: boolean;
  hint?: string;
};

// ── Basic (profile) fields per role ──────────────────────────────────────────

const BASIC_FIELDS: Record<string, BasicField[]> = {
  default: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'location', label: 'City', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
    { key: 'address', label: 'Address', type: 'textarea' },
  ],
  COMPANY: [
    { key: 'company_name', label: 'Company Name', required: true },
    { key: 'company_email', label: 'Company Email', type: 'email', required: true },
    { key: 'company_phone', label: 'Company Phone' },
    { key: 'website', label: 'Website URL', type: 'url' },
    { key: 'location', label: 'City', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
    { key: 'address', label: 'Registered Address', type: 'textarea' },
    { key: 'gst_number', label: 'GST Number (optional)' },
  ],
  PHOTOGRAPHER: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
  FITNESS_TRAINER: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    { key: 'location', label: 'City', required: true },
    { key: 'state', label: 'State', required: true },
    {
      key: 'training_type',
      label: 'Training Type',
      type: 'select',
      options: [
        'Personal Training',
        'Group Fitness',
        'Yoga',
        'CrossFit',
        'Zumba',
        'Pilates',
        'Other',
      ],
    },
    { key: 'experience_years', label: 'Years of Experience', type: 'number' },
    { key: 'bio', label: 'Short Bio', type: 'textarea' },
  ],
  TUTOR: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    { key: 'location', label: 'City', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'subjects', label: 'Subjects Taught (comma separated)' },
    { key: 'experience_years', label: 'Years of Experience', type: 'number' },
    { key: 'bio', label: 'Short Bio', type: 'textarea' },
  ],
  CATERING_SERVICES: [
    { key: 'business_name', label: 'Business Name', required: true },
    { key: 'owner_name', label: 'Owner Name', required: true },
    { key: 'phone', label: 'Contact Number', required: true },
    { key: 'location', label: 'City', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'cuisine_types', label: 'Cuisine Types (comma separated)' },
    { key: 'bio', label: 'About Your Service', type: 'textarea' },
  ],
  MAKEUP_ARTIST: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
  DEVELOPER: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
  VIDEO_EDITOR: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
  UGC_CONTENT_CREATOR: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
  GRAPHIC_DESIGNER: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
  SOCIAL_MEDIA_MANAGER: [
    { key: 'first_name', label: 'First Name', required: true },
    { key: 'last_name', label: 'Last Name', required: true },
    { key: 'email', label: 'Email Address', required: true },
    { key: 'phone', label: 'Mobile Number', required: true },
    {
      key: 'gender',
      label: 'Gender',
      type: 'select',
      options: ['Male', 'Female', 'Other', 'Prefer not to say'],
    },
    { key: 'address_line_1', label: 'Address Line 1', required: true },
    { key: 'address_line_2', label: 'Address Line 2 (Optional)' },
    { key: 'city', label: 'City', required: true },
    { key: 'area', label: 'Area', required: true },
    { key: 'state', label: 'State', required: true },
    { key: 'pin_code', label: 'PIN Code' },
  ],
};

// ── Document fields per role ──────────────────────────────────────────────────

const DOC_FIELDS: Record<string, DocField[]> = {
  default: [
    {
      key: 'aadhar_doc',
      label: 'Aadhar / Government ID',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  JOB_SEEKER: [
    {
      key: 'aadhar_doc',
      label: 'Aadhar / Government ID',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  COMPANY: [
    {
      key: 'registration_doc',
      label: 'Company Registration Certificate',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    { key: 'gst_doc', label: 'GST Certificate (optional)', hint: 'JPG, PNG or PDF · Max 10MB' },
  ],
  PHOTOGRAPHER: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'portfolio_ownership_proof',
      label: 'Portfolio Ownership Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  MAKEUP_ARTIST: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'professional_certifications',
      label: 'Professional Certifications',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  TUTOR: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'qualification_proof',
      label: 'Qualification Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  FITNESS_TRAINER: [
    {
      key: 'aadhar_doc',
      label: 'Aadhar / Government ID',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'certification_doc',
      label: 'Fitness Certification',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  CATERING_SERVICES: [
    {
      key: 'aadhar_doc',
      label: 'Aadhar / Government ID',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'fssai_license',
      label: 'FSSAI License',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  DEVELOPER: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'tax_document',
      label: 'Tax Document',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  VIDEO_EDITOR: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'tax_document',
      label: 'Tax Document',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  GRAPHIC_DESIGNER: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'tax_document',
      label: 'Tax Document',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  SOCIAL_MEDIA_MANAGER: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'tax_document',
      label: 'Tax Document',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
  UGC_CONTENT_CREATOR: [
    {
      key: 'aadhar_doc',
      label: 'Identity Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'address_proof',
      label: 'Address Proof',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
    {
      key: 'tax_document',
      label: 'Tax Document',
      required: true,
      hint: 'JPG, PNG or PDF · Max 10MB',
    },
  ],
};

// ── Portfolio sections per role ───────────────────────────────────────────────
// Only roles with a portfolio section are listed.
// COMPANY does NOT have a portfolio section.

const PORTFOLIO_SECTIONS: Record<string, string[]> = {
  default: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  JOB_SEEKER: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  PHOTOGRAPHER: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  MAKEUP_ARTIST: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  TUTOR: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  FITNESS_TRAINER: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  CATERING_SERVICES: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  DEVELOPER: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  VIDEO_EDITOR: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  UGC_CONTENT_CREATOR: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  GRAPHIC_DESIGNER: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
  SOCIAL_MEDIA_MANAGER: ['About', 'Services & pricing', 'Experience / tools', 'FAQs', 'Showcase items'],
};

// ── Accessor functions ────────────────────────────────────────────────────────

export function getBasicFields(roleKey: string): BasicField[] {
  return BASIC_FIELDS[roleKey] ?? BASIC_FIELDS.default;
}

export function getDocFields(roleKey: string): DocField[] {
  return DOC_FIELDS[roleKey] ?? DOC_FIELDS.default;
}

/**
 * Returns the list of portfolio section labels for the given role.
 * Returns an empty array if the role has no portfolio section (e.g., COMPANY).
 */
export function getPortfolioSections(roleKey: string): string[] {
  return PORTFOLIO_SECTIONS[roleKey] ?? [];
}

/**
 * Returns true if the given role has a portfolio section.
 */
export function roleHasPortfolio(roleKey: string): boolean {
  return getPortfolioSections(roleKey).length > 0;
}
