import { useState, useEffect, useCallback } from 'react'; import { Plus, Pencil, Trash2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Modal, ModalHeader, ModalBody, ModalFooter, ConfirmModal } from '@/components/ui/modal'; import { apiFetch } from '@/lib/api'; import { toast } from '@/components/ui/toast-store'; import { SENCHO_LABELS_CHANGED } from '@/lib/events'; import { CapabilityGate } from '../CapabilityGate'; import { LabelDot } from '../LabelPill'; import { LABEL_COLORS, MAX_LABELS_PER_NODE, type Label, type LabelColor } from '../label-types'; import { SettingsCallout } from './SettingsCallout'; import { SettingsPrimaryButton } from './SettingsActions'; import { useMastheadStats } from './MastheadStatsContext'; interface LabelsSectionProps { onLabelsChanged?: () => void; } export function LabelsSection({ onLabelsChanged }: LabelsSectionProps = {}) { const [labels, setLabels] = useState([]); const [loading, setLoading] = useState(true); const [assignmentCounts, setAssignmentCounts] = useState>({}); // Dialog state const [dialogOpen, setDialogOpen] = useState(false); const [editingLabel, setEditingLabel] = useState