'use client';

import Link from 'next/link';
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
import { CrmIcon } from '@/components/crm/CrmIcon';
import { listTeamOptions } from '@/features/members/api.client';
import { useOwners } from '@/features/owners/useOwners';
import { listPicklistOptions } from '@/features/picklists/api.client';
import { useUserPrefs } from '@/features/settings/UserPrefs';
import { errorText } from '@/lib/api/errors';
import { cn } from '@/lib/utils/cn';
import { CallReportSavePanel } from './CallReportSavePanel';
import {
  CA_PRESETS,
  CA_UNASSIGNED,
  CHART,
  NO_CA_FILTERS,
  changePct,
  dayLabel,
  filtersChip,
  fmtN,
  filtersFromSearch,
  getCallAnalytics,
  gridLines,
  monthLabel,
  outcomeColour,
  presetLabel,
  type CallAnalytics,
  type CallAnalyticsFilters,
} from '../analytics';

type Option = { value: string; label: string };
type ListKey = 'ownerIds' | 'outcomes' | 'teamIds' | 'directions';
type Bar = { key: string; label: string; value: number };

const Tri = () => (
  <svg className="ca-tri" viewBox="0 0 10 6" aria-hidden="true">
    <path d="M0 0h10L5 6z" fill="currentColor" />
  </svg>
);
const Icon = ({ d }: { d: ReactNode }) => (
  <svg
    className="ca-i"
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth="2"
    strokeLinecap="round"
    strokeLinejoin="round"
    aria-hidden="true"
  >
    {d}
  </svg>
);

/** The design's empty state of a card. */
function Empty() {
  return (
    <div className="ca-empty">
      <svg className="ca-empty__img" viewBox="0 0 160 130" aria-hidden="true">
        <path d="M80 70 140 98 80 126 20 98z" fill="var(--ca-ill-1)" />
        <ellipse
          cx="80"
          cy="98"
          rx="26"
          ry="10"
          fill="none"
          stroke="var(--ca-ill-2)"
          strokeDasharray="4 4"
        />
        <path d="M62 52 54 98M98 52l8 46" stroke="var(--ca-ill-2)" strokeDasharray="4 4" />
        <circle
          cx="80"
          cy="40"
          r="22"
          fill="var(--surface)"
          stroke="var(--ca-ill-2)"
          strokeWidth="5"
        />
        <path d="m96 56 18 16" stroke="var(--ca-ill-2)" strokeWidth="10" strokeLinecap="round" />
      </svg>
      <p>There is no data to show in this time frame. Try changing the date range.</p>
    </div>
  );
}

function Chips({ items }: { items: Array<string | false | undefined> }) {
  return (
    <div className="ca-chips">
      {items.filter(Boolean).map((c) => (
        <span key={c as string} className="ca-chip">
          {c}
        </span>
      ))}
    </div>
  );
}

/** Horizontal bars (the design's `hbar`). */
function HBar({ rows, axis, fmt }: { rows: Bar[]; axis: string; fmt?: (v: number) => string }) {
  const shown = rows.filter((r) => r.value > 0);
  if (!shown.length) return <Empty />;
  const max = Math.max(...shown.map((r) => r.value));
  const f = fmt ?? ((v: number) => String(Math.round(v * 10) / 10));
  return (
    <div className="ca-hbar" role="table" aria-label={axis}>
      {shown.map((r) => (
        <div key={r.key} className="ca-hbar__row" role="row">
          <span className="ca-hbar__lbl" role="rowheader">
            {r.label}
          </span>
          <span className="ca-hbar__track" role="cell">
            <span
              className="ca-hbar__bar"
              style={{ width: `${Math.max(1.5, (r.value / max) * 100)}%` }}
            />
            <b>{f(r.value)}</b>
          </span>
        </div>
      ))}
      <p className="ca-axis">{axis}</p>
    </div>
  );
}

/** Columns (the design's `columns`). */
function Columns({
  rows,
  yLabel,
  zero,
  values,
}: {
  rows: Array<{ l: string; v: number }>;
  yLabel: string;
  zero?: boolean;
  values?: boolean;
}) {
  if (!rows.some((r) => r.v > 0) && !zero) return <Empty />;
  const { W, H, L, B, T } = CHART;
  const lines = gridLines(Math.max(1, ...rows.map((r) => r.v)));
  const top = lines[0]?.top ?? 1;
  const iw = W - L - 8;
  const ih = H - B - T;
  const bw = iw / Math.max(1, rows.length);
  const every = Math.ceil(rows.length / 10);
  return (
    <svg className="ca-svg" viewBox={`0 0 ${W} ${H}`} role="img" aria-label={yLabel}>
      {lines.map((g) => (
        <g key={g.v}>
          <line x1={L} x2={W - 8} y1={g.y} y2={g.y} className="ca-grid-l" />
          <text x={L - 8} y={g.y + 4} className="ca-tick" textAnchor="end">
            {fmtN(g.v)}
          </text>
        </g>
      ))}
      {rows.map((r, i) => {
        const h = (r.v / top) * ih;
        const x = L + i * bw + bw * 0.18;
        const w = bw * 0.64;
        return (
          <g key={`${r.l}-${i}`}>
            <rect x={x} y={T + ih - h} width={w} height={Math.max(0, h)} rx={2} className="ca-col">
              <title>{`${r.l}: ${r.v}`}</title>
            </rect>
            {values ? (
              <text x={x + w / 2} y={T + ih - h - 6} className="ca-val" textAnchor="middle">
                {fmtN(r.v)}
              </text>
            ) : null}
            {i % every === 0 ? (
              <text x={x + w / 2} y={H - B + 18} className="ca-tick" textAnchor="middle">
                {r.l}
              </text>
            ) : null}
          </g>
        );
      })}
      <text
        x={12}
        y={T + ih / 2}
        className="ca-ylab"
        transform={`rotate(-90 12 ${T + ih / 2})`}
        textAnchor="middle"
      >
        {yLabel}
      </text>
    </svg>
  );
}

/** Calls made against the goal (the design's `lines`). */
function Lines({ rows }: { rows: CallAnalytics['goal'] }) {
  if (rows.length < 2 || !rows.some((r) => r.made > 0)) return <Empty />;
  const { W, H, L, B, T } = CHART;
  const last = rows[rows.length - 1]!;
  const lines = gridLines(Math.max(last.goal, last.made, 1));
  const top = lines[0]?.top ?? 1;
  const iw = W - L - 8;
  const ih = H - B - T;
  const X = (i: number) => L + (i / (rows.length - 1)) * iw;
  const Y = (v: number) => T + ih - (v / top) * ih;
  return (
    <>
      <ul className="ca-legend">
        <li>
          <i className="ca-c0" />
          Calls made
        </li>
        <li>
          <i className="ca-goal-key" />
          Goal
        </li>
      </ul>
      <svg
        className="ca-svg"
        viewBox={`0 0 ${W} ${H}`}
        role="img"
        aria-label="Calls made versus goal"
      >
        {lines.map((g) => (
          <g key={g.v}>
            <line x1={L} x2={W - 8} y1={Y(g.v)} y2={Y(g.v)} className="ca-grid-l" />
            <text x={L - 8} y={Y(g.v) + 4} className="ca-tick" textAnchor="end">
              {fmtN(g.v)}
            </text>
          </g>
        ))}
        <polyline
          className="ca-goal"
          points={rows.map((r, i) => `${X(i)},${Y(r.goal)}`).join(' ')}
        />
        <polyline
          className="ca-line"
          points={rows.map((r, i) => `${X(i)},${Y(r.made)}`).join(' ')}
        />
        {rows.map((r, i) =>
          i % 5 === 0 ? (
            <text key={r.day} x={X(i)} y={H - B + 18} className="ca-tick" textAnchor="middle">
              {dayLabel(r.day)}
            </text>
          ) : null,
        )}
      </svg>
    </>
  );
}

/**
 * CL8a (Calls parity): Calls ⋮ › Call Analytics, as the live design (call-analytics.php,
 * assets/js/call-analytics.js, css/call-analytics.css): Back to calls, the filter bar (Create date,
 * Activity assigned to, Call outcome, CRM team, Call direction; each with search and Unassigned)
 * and the report cards, drawn from GET /call-analytics. A card's ⋮ › Save report is CL8b.
 */
export function CallAnalyticsView() {
  const prefs = useUserPrefs();
  const { owners } = useOwners(true);
  const [teams, setTeams] = useState<Option[]>([]);
  const [outcomes, setOutcomes] = useState<Option[]>([]);
  // CL8b: a saved card opens with its filters (`?card=…&date=…`, from the reports library).
  const [filters, setFilters] = useState<CallAnalyticsFilters>(() =>
    typeof window === 'undefined'
      ? NO_CA_FILTERS
      : filtersFromSearch(new URLSearchParams(window.location.search)),
  );
  const [saving, setSaving] = useState<{ id: string; title: string } | null>(null);
  const [data, setData] = useState<CallAnalytics | null>(null);
  const [error, setError] = useState<string | null>(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    listTeamOptions().then(
      (r) => setTeams(r.data.map((t) => ({ value: t.id, label: t.name }))),
      () => {},
    );
    listPicklistOptions({ objectType: 'activity', field: 'callOutcome' }).then(
      (rows) =>
        setOutcomes(
          rows.filter((o) => !o.archived).map((o) => ({ value: o.value, label: o.label })),
        ),
      () => {},
    );
  }, []);

  useEffect(() => {
    const ctrl = new AbortController();
    setLoading(true);
    getCallAnalytics(filters, prefs.timeZone, ctrl.signal).then(
      (res) => {
        setData(res);
        setError(null);
        setLoading(false);
      },
      (err) => {
        if (ctrl.signal.aborted) return;
        setError(errorText(err));
        setLoading(false);
      },
    );
    return () => ctrl.abort();
  }, [filters, prefs.timeZone]);

  const ownerOptions = useMemo(
    () => owners.filter((o) => o.active).map((o) => ({ value: o.userId, label: o.name })),
    [owners],
  );
  const lists: Array<{ key: ListKey; label: string; options: Option[] }> = [
    { key: 'ownerIds', label: 'Activity assigned to', options: ownerOptions },
    { key: 'outcomes', label: 'Call outcome', options: outcomes },
    { key: 'teamIds', label: 'CRM team', options: teams },
    {
      key: 'directions',
      label: 'Call direction',
      options: [
        { value: 'inbound', label: 'Inbound' },
        { value: 'outbound', label: 'Outbound' },
      ],
    },
  ];

  // ---- the filter popover (the design's ca-pop under its button)
  const [pop, setPop] = useState<{ key: 'date' | ListKey; left: number; top: number } | null>(null);
  const [q, setQ] = useState('');
  const popRef = useRef<HTMLDivElement>(null);
  useEffect(() => {
    if (!pop) return;
    const down = (e: MouseEvent) => {
      const t = e.target as HTMLElement;
      if (!popRef.current?.contains(t) && !t.closest('[data-ca-f]')) setPop(null);
    };
    const key = (e: KeyboardEvent) => {
      if (e.key === 'Escape') setPop(null);
    };
    document.addEventListener('mousedown', down);
    document.addEventListener('keydown', key);
    return () => {
      document.removeEventListener('mousedown', down);
      document.removeEventListener('keydown', key);
    };
  }, [pop]);
  const openPop = (key: 'date' | ListKey, btn: HTMLElement) => {
    if (pop?.key === key) {
      setPop(null);
      return;
    }
    const r = btn.getBoundingClientRect();
    setQ('');
    setPop({
      key,
      left: Math.max(
        8,
        Math.min(
          r.left + window.scrollX,
          window.scrollX + document.documentElement.clientWidth - 308,
        ),
      ),
      top: r.bottom + window.scrollY + 8,
    });
  };
  const toggle = (key: ListKey, value: string) =>
    setFilters((f) => ({
      ...f,
      [key]: f[key].includes(value) ? f[key].filter((v) => v !== value) : [...f[key], value],
    }));
  const anyFilter = Boolean(filters.date) || lists.some((l) => filters[l.key].length > 0);

  // ---- a card's ⋮ menu
  const [menu, setMenu] = useState<string | null>(null);
  useEffect(() => {
    if (!menu) return;
    const down = (e: MouseEvent) => {
      if (!(e.target as HTMLElement).closest('.ca-menu-wrap')) setMenu(null);
    };
    const key = (e: KeyboardEvent) => {
      if (e.key === 'Escape') setMenu(null);
    };
    document.addEventListener('mousedown', down);
    document.addEventListener('keydown', key);
    return () => {
      document.removeEventListener('mousedown', down);
      document.removeEventListener('keydown', key);
    };
  }, [menu]);

  // CL8b: a saved card's link scrolls to it once the cards are drawn.
  const scrolled = useRef(false);
  useEffect(() => {
    if (!data || scrolled.current) return;
    scrolled.current = true;
    const card = new URLSearchParams(window.location.search).get('card');
    if (card) document.getElementById(`ca-${card}`)?.scrollIntoView({ block: 'center' });
  }, [data]);

  const rangeChip = filters.date ? presetLabel(filters.date) : 'In the last 30 days';
  const minutesChip = `${filters.date ? presetLabel(filters.date) : 'In the last 180 days'} | Monthly`;
  const days = data?.team.days ?? 30;
  const outcomeLabel = (v: string) =>
    v ? (outcomes.find((o) => o.value === v)?.label ?? v) : '(No value)';
  const outcomeOrder = outcomes.map((o) => o.value);

  const cards: Array<{ id: string; title: string; body: (d: CallAnalytics) => ReactNode }> = [
    {
      id: 'placed',
      title: 'Calls placed totals by rep',
      body: (d) => (
        <>
          <Chips items={[rangeChip, filtersChip(filters, 1)]} />
          <HBar rows={d.placed} axis="(Count) Calls" />
        </>
      ),
    },
    {
      id: 'minutes',
      title: 'Calling minutes usage (all sources)',
      body: (d) => (
        <>
          <p className="ca-sub">This report is not intended to match CRM calling minutes billed.</p>
          <Chips items={[minutesChip]} />
          <ul className="ca-legend">
            <li>
              <i className="ca-c0" />
              Calling minute usage
            </li>
          </ul>
          <Columns
            rows={d.minutes.map((m) => ({ l: monthLabel(m.month), v: m.minutes }))}
            yLabel="Minutes"
            zero
            values
          />
        </>
      ),
    },
    {
      id: 'byday',
      title: 'Call created totals by day',
      body: (d) => (
        <>
          <Chips items={[`${rangeChip} | Daily`, filtersChip(filters, 1)]} />
          <Columns
            rows={d.byDay.map((r) => ({ l: dayLabel(r.day), v: r.count }))}
            yLabel="(Count) Calls"
          />
        </>
      ),
    },
    {
      id: 'outcomes',
      title: 'Calls outcome totals by rep',
      body: (d) => {
        const rows = d.outcomes.filter((r) => r.total > 0);
        if (!rows.length) {
          return (
            <>
              <Chips items={[rangeChip, filtersChip(filters, 1)]} />
              <Empty />
            </>
          );
        }
        const max = Math.max(...rows.map((r) => r.total));
        return (
          <>
            <Chips items={[rangeChip, filtersChip(filters, 1)]} />
            <ul className="ca-legend">
              {d.outcomeKeys.map((k) => (
                <li key={k || 'none'}>
                  <i className={`ca-c${outcomeColour(k, outcomeOrder)}`} />
                  {outcomeLabel(k)}
                </li>
              ))}
            </ul>
            <div className="ca-hbar">
              {rows.map((r) => (
                <div key={r.key} className="ca-hbar__row">
                  <span className="ca-hbar__lbl">{r.label}</span>
                  <span className="ca-hbar__track">
                    <span className="ca-stack" style={{ width: `${(r.total / max) * 100}%` }}>
                      {d.outcomeKeys.map((k) =>
                        r.parts[k] ? (
                          <span
                            key={k || 'none'}
                            className={`ca-c${outcomeColour(k, outcomeOrder)}`}
                            style={{ flex: r.parts[k] }}
                            title={`${outcomeLabel(k)}: ${r.parts[k]}`}
                          />
                        ) : null,
                      )}
                    </span>
                    <b>{r.total}</b>
                  </span>
                </div>
              ))}
              <p className="ca-axis">(Count) Calls</p>
            </div>
          </>
        );
      },
    },
    {
      id: 'team',
      title: 'Team activity totals',
      body: (d) => {
        const tiles: Array<[string, number, number]> = [
          ['Email sent to contact', d.team.now.emails, d.team.previous.emails],
          ['Meeting', d.team.now.meetings, d.team.previous.meetings],
          ['Note', d.team.now.notes, d.team.previous.notes],
          ['Task', d.team.now.tasks, d.team.previous.tasks],
        ];
        return (
          <>
            <Chips
              items={[rangeChip, `Compared To | Previous ${days} days`, filtersChip(filters)]}
            />
            <div className="ca-kpis">
              {tiles.map(([name, now, before]) => {
                const ch = changePct(now, before);
                return (
                  <div key={name} className="ca-kpi">
                    <span>{name}</span>
                    <strong>{now.toLocaleString('en-US')}</strong>
                    <small className={ch >= 0 ? 'is-up' : 'is-down'}>
                      <Icon d={<path d={ch >= 0 ? 'm6 14 6-6 6 6' : 'm6 10 6 6 6-6'} />} />
                      {Math.abs(ch).toFixed(2)}%
                    </small>
                  </div>
                );
              })}
            </div>
          </>
        );
      },
    },
    {
      id: 'types',
      title: 'Call and meeting totals by type',
      body: (d) => (
        <>
          <Chips items={[rangeChip, filtersChip(filters)]} />
          <ul className="ca-legend">
            <li>
              <i className="ca-c0" />
              (Count) Activities
            </li>
          </ul>
          <Columns
            rows={d.types.map((r) => ({ l: r.label, v: r.value }))}
            yLabel="(Count) Activities"
            values
          />
        </>
      ),
    },
    {
      id: 'duration',
      title: 'Call duration average by rep',
      body: (d) => (
        <>
          <Chips items={[rangeChip, filtersChip(filters)]} />
          <HBar
            rows={d.duration}
            axis="Average call duration (minutes)"
            fmt={(v) => `${Math.round(v * 10) / 10} min`}
          />
        </>
      ),
    },
    {
      id: 'reps',
      title: 'Call and meeting totals by rep',
      body: (d) => (
        <>
          <Chips items={[rangeChip, filtersChip(filters)]} />
          <HBar rows={d.reps} axis="(Count) Activities" />
        </>
      ),
    },
    {
      id: 'goal',
      title: 'Calls made vs. goal',
      body: (d) => (
        <>
          <Chips items={[`${rangeChip} | Daily`, filtersChip(filters, 1)]} />
          <Lines rows={d.goal} />
        </>
      ),
    },
    {
      id: 'workspace-answer',
      title: 'Call Answer Status (by Workspace)',
      body: (d) => (
        <>
          <Chips items={[rangeChip, filtersChip(filters, 1)]} />
          <div className="ca-workspace-chart">
            <HBar rows={d.inboundByTeam} axis="(Count) Inbound calls" />
          </div>
        </>
      ),
    },
  ];

  const popList = pop && pop.key !== 'date' ? lists.find((l) => l.key === pop.key) : undefined;
  const qq = q.trim().toLowerCase();

  return (
    <div className="ca" data-ca>
      <header className="ca-head">
        <Link className="ca-back" href="/calls">
          <CrmIcon name="chevron-left" className="iconSize-14" />
          Back to calls
        </Link>
        <h1>Call Analytics</h1>
      </header>

      <div className="ca-body">
        <div className="ca-filters" role="toolbar" aria-label="Report filters">
          <button
            type="button"
            className={cn('ca-fbtn', filters.date && 'is-on', pop?.key === 'date' && 'is-open')}
            data-ca-f="date"
            aria-haspopup="listbox"
            aria-expanded={pop?.key === 'date'}
            onClick={(e) => openPop('date', e.currentTarget)}
          >
            {filters.date ? `Create date: ${presetLabel(filters.date)}` : 'Create date'}
            <Tri />
          </button>
          {lists.map((l) => {
            const n = filters[l.key].length;
            return (
              <button
                key={l.key}
                type="button"
                className={cn('ca-fbtn', n > 0 && 'is-on', pop?.key === l.key && 'is-open')}
                data-ca-f={l.key}
                aria-haspopup="listbox"
                aria-expanded={pop?.key === l.key}
                onClick={(e) => openPop(l.key, e.currentTarget)}
              >
                {l.label}
                {n ? ` (${n})` : ''}
                <Tri />
              </button>
            );
          })}
          {anyFilter ? (
            <button type="button" className="ca-clear" onClick={() => setFilters(NO_CA_FILTERS)}>
              Clear all
            </button>
          ) : null}
        </div>

        {error ? <p className="crm-text-danger crm-px-4">{error}</p> : null}
        <div className="ca-grid" aria-busy={loading}>
          {cards.map((c) => (
            <section key={c.id} className="ca-card" aria-labelledby={`ca-${c.id}`}>
              <header className="ca-card__head">
                <h2 id={`ca-${c.id}`}>{c.title}</h2>
                <div className="ca-menu-wrap">
                  <button
                    type="button"
                    className="ca-icon"
                    aria-haspopup="menu"
                    aria-expanded={menu === c.id}
                    aria-label={`${c.title} actions`}
                    onClick={() => setMenu((m) => (m === c.id ? null : c.id))}
                  >
                    <Icon
                      d={
                        <>
                          <circle cx="12" cy="5" r="1" />
                          <circle cx="12" cy="12" r="1" />
                          <circle cx="12" cy="19" r="1" />
                        </>
                      }
                    />
                  </button>
                  {menu === c.id ? (
                    <div className="ca-menu" role="menu">
                      <button
                        type="button"
                        role="menuitem"
                        onClick={() => {
                          setMenu(null);
                          setSaving({ id: c.id, title: c.title });
                        }}
                      >
                        Save report
                      </button>
                    </div>
                  ) : null}
                </div>
              </header>
              <div className="ca-card__body">{data ? c.body(data) : null}</div>
            </section>
          ))}
        </div>
      </div>

      <CallReportSavePanel
        card={saving}
        filters={filters}
        lists={lists}
        onClose={() => setSaving(null)}
      />

      {pop ? (
        <div
          ref={popRef}
          className="ca-pop"
          role="dialog"
          aria-label={pop.key === 'date' ? 'Create date' : popList?.label}
          style={{ left: pop.left, top: pop.top }}
        >
          {pop.key === 'date' || (popList && popList.options.length > 6) ? (
            <label className="ca-search">
              <input
                type="search"
                placeholder="Search"
                aria-label="Search"
                value={q}
                autoFocus
                onChange={(e) => setQ(e.target.value)}
              />
              <Icon
                d={
                  <>
                    <circle cx="11" cy="11" r="7" />
                    <path d="m21 21-4.3-4.3" />
                  </>
                }
              />
            </label>
          ) : null}
          <div
            className="ca-list"
            role="listbox"
            aria-multiselectable={pop.key === 'date' ? undefined : true}
          >
            {pop.key === 'date'
              ? CA_PRESETS.filter((p) => p.label.toLowerCase().includes(qq)).map((p) => (
                  <button
                    key={p.id}
                    type="button"
                    className="ca-opt ca-opt--2"
                    role="option"
                    aria-selected={filters.date === p.id}
                    onClick={() => {
                      setFilters((f) => ({ ...f, date: p.id }));
                      setPop(null);
                    }}
                  >
                    <span>{p.label}</span>
                    <small>{p.hint}</small>
                  </button>
                ))
              : popList
                ? [
                    ...popList.options,
                    { value: '—', label: '' },
                    { value: CA_UNASSIGNED, label: 'Unassigned' },
                  ]
                    .filter((o) => o.value === '—' || o.label.toLowerCase().includes(qq))
                    .map((o) => {
                      if (o.value === '—')
                        return <hr key="sep" className="ca-sep" role="separator" />;
                      const on = filters[popList.key].includes(o.value);
                      return (
                        <button
                          key={o.value}
                          type="button"
                          className="ca-opt"
                          role="option"
                          aria-selected={on}
                          onClick={() => toggle(popList.key, o.value)}
                        >
                          <span className={cn('ca-cb', on && 'is-on')} aria-hidden="true">
                            <Icon d={<path d="M20 6 9 17l-5-5" />} />
                          </span>
                          <span>{o.label}</span>
                        </button>
                      );
                    })
                : null}
          </div>
          {pop.key === 'date' && filters.date ? (
            <button
              type="button"
              className="ca-link ca-pop__reset"
              onClick={() => {
                setFilters((f) => ({ ...f, date: '' }));
                setPop(null);
              }}
            >
              Clear date range
            </button>
          ) : null}
        </div>
      ) : null}
    </div>
  );
}
