export type CategoryId = 'hvac' | 'power' | 'building' | 'app';

const IMG = 'auto=format&fit=crop&w=960&q=80';

export type WizardStep = {
  imageSrc?: string;
  imageCaption?: string;
  title: string;
  intro: string;
  bullets: string[];
};

export const CATEGORY_ORDER: { id: CategoryId; label: string }[] = [
  { id: 'hvac', label: 'Air conditioning' },
  { id: 'power', label: 'Power & electrical' },
  { id: 'building', label: 'Building systems' },
  { id: 'app', label: 'Application & account' },
];

export const STEPS_BY_CATEGORY: Record<CategoryId, WizardStep[]> = {
  power: [
    {
      imageSrc: `https://images.unsplash.com/photo-1621905251918-48416bd8575a?${IMG}`,
      imageCaption: 'Panels, breakers, and protection devices',
      title: 'Breakers, RCDs, and panels',
      intro:
        'Read the steps below. When you have actually tried them, use the button below to continue.',
      bullets: [
        'Identify whether one circuit or a whole area is affected.',
        'Check the correct panel for that space; reset a tripped breaker only once if policy allows, and note which label matches the room or equipment.',
        'If an RCD/GFCI device has tripped, press reset after unplugging new or suspect equipment—if it trips again, leave it off and report.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1558494949-ef010cbdcc31?${IMG}`,
      imageCaption: 'UPS, server rooms, and facility power indicators',
      title: 'Power at the source',
      intro: 'Confirm whether the issue is local or upstream before opening a ticket.',
      bullets: [
        'Check if neighbouring rooms or equipment on the same feed still have power.',
        'Note any recent work, outages, or generator/UPS transfers communicated by facilities.',
        'Do not open energized panels beyond your training; photograph labels only if safe to do so.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?${IMG}`,
      imageCaption: 'Isolating equipment and electrical safety',
      title: 'Equipment and safety',
      intro: 'Reduce risk and capture details technicians will need.',
      bullets: [
        'Turn off or isolate affected equipment only if your procedure allows it.',
        'Unplug new or suspect devices from the affected circuit where policy permits.',
        'Record exact location, panel name, breaker label, and what changed just before the fault.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1504917595217-d4dc5ebe6122?${IMG}`,
      imageCaption: 'Notes, photos, and details for your ticket',
      title: 'Before you escalate',
      intro: 'If the problem is still there after the checks above, gather this for your ticket.',
      bullets: [
        'List what you tried and the outcome (including repeated trips or resets).',
        'Note any burning smell, heat, noise, or visible damage—stop and report immediately if unsafe.',
        'Use Support issues → New issue with photos and panel labels if your site allows attachments.',
      ],
    },
  ],
  hvac: [
    {
      imageSrc: `https://images.unsplash.com/photo-1770625467384-304e461ef1be?${IMG}`,
      imageCaption: 'Digital thermostat, mode, and setpoint',
      title: 'Quick HVAC checks',
      intro: 'Work through these before reporting poor cooling or airflow.',
      bullets: [
        'Confirm the thermostat mode (cool/heat/fan), setpoint, and that it is not in override or schedule lock.',
        'Check return air paths and vents—blocked grilles are a common cause of weak airflow.',
        'If there is a local isolator or shutoff for the unit, verify it is on per site policy only.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1585771724684-38269d6639fd?${IMG}`,
      imageCaption: 'Outdoor unit, lines, and coil area',
      title: 'Filters and coils',
      intro: 'Restricted airflow often traces to maintenance items.',
      bullets: [
        'Note the last filter change date; a clogged filter reduces airflow and can trip limits.',
        'Look for ice on lines or coils—if present, stop forcing the system and report.',
        'Do not remove safety covers unless you are authorized and trained.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1765850262030-1ae93e474473?${IMG}`,
      imageCaption: 'Ceiling units, alarms, and wet areas near equipment',
      title: 'Noise, water, and alarms',
      intro: 'Capture symptoms that help narrow the fault.',
      bullets: [
        'Record unusual sounds (grinding, squealing) and when they started.',
        'Check for water near the unit or drain pan overflow indicators.',
        'Copy any fault code or BMS alarm text shown on the panel or screen.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1497366216548-37526070297c?${IMG}`,
      imageCaption: 'Notes, readings, and what to send with your issue',
      title: 'Ready for a ticket',
      intro: 'Include this in your issue for faster routing.',
      bullets: [
        'Building, floor, room, and asset tag if available.',
        'Whether the space is occupied, sensitive (e.g. clinical), or time-critical.',
        'What you already tried and current thermostat readings if visible.',
      ],
    },
  ],
  building: [
    {
      imageSrc: `https://images.unsplash.com/photo-1502672260266-1c1ef2d93688?${IMG}`,
      imageCaption: 'Doors, circulation, and access points',
      title: 'Access, doors, and security',
      intro: 'Many building tickets start with access or environmental comfort.',
      bullets: [
        'Confirm whether the problem is one door/zone or a wider access failure.',
        'Check for obstructions, broken glass, or propped doors that affect sensors.',
        'Note if card readers or intercoms show an error code or LED pattern.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1600585154526-990dced4db0d?${IMG}`,
      imageCaption: 'Fixtures, pipes, and visible water',
      title: 'Water and leaks',
      intro: 'Treat active leaks as urgent; safety comes first.',
      bullets: [
        'If water is near electrics, keep clear and report immediately per your emergency process.',
        'Identify the source if safe (ceiling, fixture, pipe chase) and contain with approved materials only.',
        'Photograph the area from a safe distance if your policy allows.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1558618666-fcd25c85cd64?${IMG}`,
      imageCaption: 'Lighting, outlets, and local circuits',
      title: 'Lighting and small power',
      intro: 'Local checks before logging a facilities issue.',
      bullets: [
        'Try adjacent switches; confirm the circuit is not isolated for maintenance.',
        'For recurring trips, note which device or circuit label is involved.',
        'Report flickering that affects a whole zone—it may indicate a loose neutral upstream.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1497366754035-f200968a6e72?${IMG}`,
      imageCaption: 'Location, timing, and operational impact',
      title: 'Escalation details',
      intro: 'Help the team respond on first visit.',
      bullets: [
        'Exact location, time noticed, and whether it is getting worse.',
        'Impact on operations, safety, or compliance.',
        'Any recent construction, cleaning, or vendor work nearby.',
      ],
    },
  ],
  app: [
    {
      imageSrc: `https://images.unsplash.com/photo-1460925895917-afdab827c52f?${IMG}`,
      imageCaption: 'Browser, session, and refresh',
      title: 'Browser and session',
      intro: 'Most application issues are fixed with a few quick steps.',
      bullets: [
        'Hard refresh the page (Ctrl+Shift+R or Cmd+Shift+R) or try another browser.',
        'Sign out and sign back in; clear site data only if your IT policy allows it.',
        'Disable conflicting extensions temporarily to rule out ad blockers or script blockers.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1544197150-b99a580bb7a8?${IMG}`,
      imageCaption: 'Wi‑Fi, mobile data, and VPN connectivity',
      title: 'Network and VPN',
      intro: 'Confirm connectivity before reporting an app outage.',
      bullets: [
        'Check other internal sites or the corporate intranet load correctly.',
        'If you use VPN, reconnect or try the flow off VPN if permitted.',
        'Note exact error text, URL, and approximate time of failure.',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1563013544-824ae1b704d3?${IMG}`,
      imageCaption: 'Accounts, roles, and access control',
      title: 'Permissions and data',
      intro: 'Some errors are role or data related.',
      bullets: [
        'Confirm you are using the correct company/site profile if the app supports multiple.',
        'Try the same action on another device to see if it is account-specific.',
        'Screenshot the error banner or toast message (redact personal data).',
      ],
    },
    {
      imageSrc: `https://images.unsplash.com/photo-1555066931-4365d14bab8c?${IMG}`,
      imageCaption: 'Steps, screenshots, and environment details',
      title: 'Handover to support',
      intro: 'Open a ticket with enough context to reproduce.',
      bullets: [
        'Steps you took, expected result, and actual result.',
        'Browser name and version, device type, and whether others are affected.',
        'Attach screenshots only if allowed by your data policy.',
      ],
    },
  ],
};

export const TOTAL_STEPS = 4;

export type NewIssuePrecheckLocationState = {
  newIssuePrecheckDone?: boolean;
  precheckCantCompleteReason?: string;
};
