@viswa-test/test-citation 0.0.390 → 0.0.391
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/cjs/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/cjs/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/features/PdfViewer/rotationManager.js +1 -1
- package/dist/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +0 -2
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +1 -8
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -12
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts +2 -9
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts +3 -2
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +1 -2
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/rotationManager.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts +1 -2
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts +21 -0
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionAccordion.js","sources":["../../../../src/features/CognitiveCompare/components/SectionAccordion.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Box,\n Tooltip,\n Typography,\n} from \"@mui/material\";\nimport { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport { \n generateColorPalette, \n hasValue, \n safeStringify,\n DEVIATION_BADGE_SEPARATOR,\n isMissingStr,\n escapeRegExp,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n findTextMatchRange,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { findTextRangeWithFormatting } from \"../utils/normalizeInlineMarkdown\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\nimport { DeviationNavigationEntry } from \"../hooks/useDeviationNavigation\";\nimport { normalizeRedlineMarkdown } from \"../utils/normalizeRedlineMarkdown\";\n\nconst renderSimpleMarkdown = (text: string, isMultiTag = false) => {\n if (!text) return null;\n\n const normalizedText = safeStringify(text).replace(/\\\\n/g, \"\\n\");\n const parts = normalizedText.split(/(\\*\\*.*?\\*\\*)/g);\n\n return parts.map((part: string, i: number) => {\n if (part.startsWith(\"**\") && part.endsWith(\"**\")) {\n return <strong key={i}>{part.slice(2, -2)}</strong>;\n }\n\n return (\n <div\n key={i}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"8px\",\n width: \"100%\",\n }}\n >\n <span\n style={{\n minWidth: 0,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {part}\n </span>\n\n {isMultiTag && (\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"0px 6px\",\n borderRadius: \"9999px\",\n background: \"#F3F4F6\",\n border: \"1px solid #D1D5DB\",\n color: \"#6B7280\",\n fontSize: \"9px\",\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n lineHeight: 1.4,\n marginRight: \"4px\",\n }}\n >\n Multiple\n </span>\n )}\n </div>\n );\n });\n};\n\nconst findScrollParent = (element: HTMLElement | null): HTMLElement | null => {\n let current = element?.parentElement || null;\n while (current) {\n const style = window.getComputedStyle(current);\n const overflowY = style.overflowY;\n const canScroll =\n (overflowY === \"auto\" || overflowY === \"scroll\") &&\n current.scrollHeight > current.clientHeight;\n\n if (canScroll) return current;\n current = current.parentElement;\n }\n\n return null;\n};\n\nconst isElementVisibleInScrollParent = (element: HTMLElement) => {\n const scrollParent = findScrollParent(element);\n const rect = element.getBoundingClientRect();\n const parentRect = scrollParent?.getBoundingClientRect() || {\n top: 0,\n bottom: window.innerHeight,\n };\n\n return rect.top >= parentRect.top && rect.bottom <= parentRect.bottom;\n};\n\ntype SectionAccordionProps = {\n section: SectionBlock;\n idx: number;\n columnKey: \"left\" | \"right\";\n colRef: React.RefObject<HTMLDivElement>;\n mb?: number;\n parentNodeId?: string;\n isExpanded: boolean;\n onToggle: () => void;\n navigation: DeviationNavigationEntry | null;\n};\n\nconst SectionAccordion = ({\n section,\n idx,\n columnKey,\n colRef,\n mb = 1,\n isExpanded,\n onToggle,\n navigation,\n parentNodeId = \"\",\n}: SectionAccordionProps) => {\n const {\n showOpenNodeRef,\n resolvedMarkdownStyles,\n maintainRelativeOrder,\n showDeviationBadges = false,\n renderSubSectionAccordion,\n treeData,\n proposedSections,\n existingSections,\n deviationNumberRegistry,\n deviationParentRegistry,\n getBadgeRef,\n openSummaryPopup,\n getSectionCompareStyle,\n connectedSections,\n openMoreFunctionsPopup,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n isSideBySide,\n activeSideBySideSection,\n scrollSyncLocked,\n unifiedNumbering,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n } = useCompareContext();\n const collisionKey = `${isSideBySide ? \"1\" : \"0\"}-${String(activeSideBySideSection ?? \"\")}`;\n const hasTitle = (section.displayTitle ?? true) && hasValue(section.title);\n const isProposedFixTarget =\n !!isProposingFix &&\n !!proposingFixNodeId &&\n columnKey === \"left\" &&\n (section.id === proposingFixNodeId ||\n section.nodeId === proposingFixNodeId ||\n section.contentId === proposingFixNodeId);\n \n const hasRedlineTags = hasMeaningfulRedlineTags(section.content);\n const inferredRedlineFlow = hasRedlineTags;\n const resolvedRedlineFlow =\n typeof isRedlineFlow === \"boolean\" ? isRedlineFlow : inferredRedlineFlow;\n const suppressHighlightBg = hasRedlineTags;\n const changeHistoryContent = section.change_history;\n\n // Use all visible redline text as the base so changed-only highlights can match.\n const shouldOverlayContent = resolvedRedlineFlow && hasRedlineTags;\n const normalizedRedlineContent = React.useMemo(\n () => shouldOverlayContent\n ? normalizeRedlineMarkdown(safeStringify(section.content))\n : safeStringify(section.content),\n [section.content, shouldOverlayContent],\n );\n const baseContent = shouldOverlayContent\n ? stripRedlineTags(normalizedRedlineContent)\n : section.content;\n const overlayContent = shouldOverlayContent ? normalizedRedlineContent : undefined;\n const fallbackContent =\n hasRedlineTags && hasValue(changeHistoryContent)\n ? safeStringify(changeHistoryContent)\n : undefined;\n const hasContent = ((section.displayContent ?? true) || hasRedlineTags) && hasValue(section.content);\n const isEmpty = !hasTitle && !hasContent;\n\n \n\n let displayTitle = section.title;\n if (!hasTitle) {\n displayTitle = hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n }\n const isMultipleMapping =\n columnKey === \"left\" &&\n (section.isMultipleMapping || (section.refContentIds?.length ?? 1) > 1);\n const visibleTitle =\n columnKey === \"left\" && displayTitle.length > 29\n ? `${displayTitle.slice(0, 29).trimEnd()}...`\n : displayTitle;\n\n let targetEvalResult = section.evaluationResult;\n if (!targetEvalResult && columnKey === \"right\") {\n if (maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsSection = proposedSections.find((s: any) => s.selfIndex === lhsSelfIndex);\n targetEvalResult = lhsSection?.evaluationResult;\n } else {\n targetEvalResult = proposedSections[idx]?.evaluationResult;\n }\n }\n\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterPartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n const findNodeByIdDeep = (nodes: any[], id?: string): any => {\n if (!id || !nodes) return null;\n for (const n of nodes) {\n if (n.id === id || n.nodeId === id || n.contentId === id) return n;\n if (n.subsections?.length) {\n const found = findNodeByIdDeep(n.subsections, id);\n if (found) return found;\n }\n }\n return null;\n };\n\n let popupBaseSec: any = columnKey === \"left\" ? section : findNodeByIdDeep(proposedSections, section.id);\n let popupRefSec: any = columnKey === \"right\" ? section : findNodeByIdDeep(existingSections, section.id);\n\n const sectionOffset = React.useMemo(() => {\n if (!maintainRelativeOrder) return 0;\n let min = Infinity;\n\n const normalizeInlineContent = (value: unknown) => {\n const raw = safeStringify(value || \"\").replace(/\\\\n/g, \"\\n\");\n return hasMeaningfulRedlineTags(raw)\n ? stripRedlineTags(normalizeRedlineMarkdown(raw))\n : raw;\n };\n\n const canRenderInlineHighlight = (node: SectionBlock, highlight: unknown) => {\n if (typeof highlight !== \"string\" || isMissingStr(highlight)) return false;\n const content = normalizeInlineContent(node?.content);\n const normalizedHighlight = normalizeInlineContent(highlight);\n return !!normalizedHighlight && !!findTextMatchRange(content, normalizedHighlight);\n };\n\n const traverse = (node: any, bNode: any, rNode: any, isTopLevel: boolean) => {\n if (!node) return;\n\n let topNodeId = node.nodeId || node.id;\n if (isTopLevel && columnKey === \"right\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(node.selfIndex));\n if (mappedLhs.length > 0) topNodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n }\n\n let subNodeId = node.nodeId || node.id || bNode?.nodeId || bNode?.id || rNode?.nodeId || rNode?.id;\n\n const evalResult = node.evaluationResult || bNode?.evaluationResult || rNode?.evaluationResult;\n const devs = evalResult?.deviations || {};\n Object.keys(devs).forEach(devKey => {\n const highlight = devs[devKey]?.[parentNodeId];\n const renderNode = columnKey === \"left\" ? (bNode || node) : (rNode || node);\n if (!canRenderInlineHighlight(renderNode, highlight)) return;\n\n const refId1 = `${topNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx1 = deviationNumberRegistry?.[refId1];\n if (idx1 !== undefined && idx1 !== null && idx1 < min) min = idx1;\n\n const refId2 = `${subNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx2 = deviationNumberRegistry?.[refId2];\n if (idx2 !== undefined && idx2 !== null && idx2 < min) min = idx2;\n });\n\n const subs = node.subsections || [];\n const bSubs = bNode?.subsections || [];\n const rSubs = rNode?.subsections || [];\n const maxLen = Math.max(subs.length, bSubs.length, rSubs.length);\n\n for (let i = 0; i < maxLen; i++) {\n traverse(subs[i], bSubs[i], rSubs[i], false);\n }\n };\n\n const mappedLhsSections = columnKey === \"right\"\n ? proposedSections.filter((lhs: SectionBlock) => lhs.refIndexes?.includes(section.selfIndex as number))\n : [];\n\n if (mappedLhsSections.length === 1) {\n const mappedLhs = mappedLhsSections[0] as SectionBlock;\n const mappedRhsSections = (mappedLhs.refIndexes || [])\n .map((rhsSelfIndex: number) =>\n existingSections.find((rhs: SectionBlock) => rhs.selfIndex === rhsSelfIndex),\n )\n .filter(Boolean);\n\n mappedRhsSections.forEach((rhsSection: any) => {\n traverse(rhsSection, mappedLhs, rhsSection, true);\n });\n } else {\n traverse(section, popupBaseSec, popupRefSec, true);\n }\n\n return min !== Infinity ? min - 1 : 0;\n }, [section, popupBaseSec, popupRefSec, columnKey, parentNodeId, deviationNumberRegistry, maintainRelativeOrder, proposedSections, existingSections]);\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n popupRefSec = rhsArrayIdx !== -1\n ? existingSections[rhsArrayIdx]\n : findNodeByIdDeep(existingSections, section.id);\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n popupBaseSec = lhsArrayIdx !== -1\n ? proposedSections[lhsArrayIdx]\n : findNodeByIdDeep(proposedSections, section.id);\n }\n }\n\n const isSecOrphan = columnKey === \"left\" ? !popupRefSec : !popupBaseSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(section, proposedSections);\n\n const resolvedEvalResult = targetEvalResult || popupBaseSec?.evaluationResult || popupRefSec?.evaluationResult;\n const deviationColorData = resolvedEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n const deviations = resolvedEvalResult?.deviations || {};\n\n const lhsDeviationDisplayIndexes = React.useMemo(\n () =>\n maintainRelativeOrder && columnKey === \"right\"\n ? getLhsDeviationDisplayIndexes(\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n )\n : new Map<string, number>(),\n [\n maintainRelativeOrder,\n columnKey,\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n ],\n );\n\n let nodeId = section.nodeId || section.id;\n\n // For RHS mapped sections, nodeId must match what the registry used (LHS id)\n if (maintainRelativeOrder && columnKey !== \"left\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(section.selfIndex));\n if (mappedLhs.length > 0) {\n nodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n } else if (popupBaseSec?.id) {\n nodeId = popupBaseSec.nodeId || popupBaseSec.id;\n }\n }\n\n const rhsOrphanVisualIndexes = React.useMemo(() => {\n const indexes = new Map<string, number>();\n if (!maintainRelativeOrder || columnKey !== \"right\") return indexes;\n\n let nextIndex = 1;\n const mappedLhsSections = proposedSections.filter((lhs: SectionBlock) =>\n lhs.refIndexes?.includes(section.selfIndex as number),\n );\n const isOneToOneSection =\n mappedLhsSections.length === 1 &&\n mappedLhsSections[0].refIndexes?.length === 1;\n const normalizeContent = (value: unknown) =>\n safeStringify(value || \"\").replace(/\\\\n/g, \"\\n\");\n\n const resolveNode = (rhsNode: SectionBlock, isRoot: boolean) => {\n const lhsNode = isRoot\n ? mappedLhsSections[0]\n : findNodeByIdDeep(\n proposedSections,\n rhsNode.nodeId || rhsNode.id || rhsNode.contentId,\n );\n const evalResult =\n rhsNode.evaluationResult || lhsNode?.evaluationResult;\n const registryNodeId = lhsNode\n ? lhsNode.nodeId || lhsNode.id\n : rhsNode.nodeId || rhsNode.id;\n return { lhsNode, evalResult, registryNodeId };\n };\n\n if (isOneToOneSection) {\n const reserveMappedIndexes = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(evalResult?.deviations || {}).forEach(\n ([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const normalizedHighlight = normalizeContent(highlight);\n const isMapped =\n !!lhsNode &&\n !isMissingStr(deviationMap[counterPartNodeId as string]);\n if (\n !isMapped ||\n !normalizedHighlight ||\n !findTextMatchRange(normalizedContent, normalizedHighlight)\n ) return;\n\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const registryIndex = deviationNumberRegistry[refId];\n if (registryIndex === undefined || registryIndex === null) return;\n nextIndex = Math.max(\n nextIndex,\n Math.max(1, registryIndex - (sectionOffset || 0)) + 1,\n );\n },\n );\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) =>\n reserveMappedIndexes(child),\n );\n };\n\n reserveMappedIndexes(section, true);\n }\n\n const visit = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const nodeDeviations = evalResult?.deviations || {};\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(nodeDeviations)\n .map(([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const isOrphan =\n !lhsNode || isMissingStr(deviationMap[counterPartNodeId as string]);\n const normalizedHighlight = normalizeContent(highlight);\n let position = -1;\n if (normalizedHighlight) {\n position = findTextMatchRange(normalizedContent, normalizedHighlight)?.start ?? -1;\n if (position === -1) {\n position = findTextRangeWithFormatting(normalizedContent, normalizedHighlight)?.start ?? -1;\n }\n }\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n return {\n refId,\n isRenderable:\n isOrphan && !!normalizedHighlight && !isMissingStr(highlight),\n position,\n registryIndex: deviationNumberRegistry[refId] ?? Number.MAX_SAFE_INTEGER,\n };\n })\n .filter((entry) => entry.isRenderable)\n .sort((a, b) => {\n const aPosition =\n a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition =\n b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.registryIndex - b.registryIndex;\n })\n .forEach((entry) => {\n indexes.set(entry.refId, nextIndex++);\n });\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) => visit(child));\n };\n\n visit(section, true);\n return indexes;\n }, [\n maintainRelativeOrder,\n columnKey,\n section,\n proposedSections,\n parentNodeId,\n counterPartNodeId,\n deviationNumberRegistry,\n sectionOffset,\n ]);\n\n // Derive validatedParentNum from registry\n const firstDeviationKey = Object.keys(deviations)[0];\n const firstRefId = firstDeviationKey ? `${nodeId}${DEVIATION_BADGE_SEPARATOR}${firstDeviationKey}` : null;\n const registeredParentNum = firstRefId ? (deviationParentRegistry?.[firstRefId] as number) : null;\n\n let validatedParentNum: string | number = idx + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(section?.id as string) \n : unifiedNumbering.rightNums.get(section?.id as string);\n \n if (isSecOrphan && unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n } else if (unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n }\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n }\n // const deviationNodeIdRef = useRef<string | undefined>(deviationNodeIdToView);\n // const deviationNodeParentRef = useRef<string | null>(deviationTargetParentId || null);\n const highlights: string[] = [];\n // Mapp through deviations to pass to memoized markdown for highlighting, also prepare deviation badges \n let nextFallbackDeviationIndex = Math.max(\n 0,\n ...Object.keys(deviations).map(\n (deviationKey) =>\n deviationNumberRegistry[\n `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`\n ],\n ).filter(\n (value): value is number => typeof value === \"number\" && Number.isFinite(value),\n ),\n ) + 1;\n const rawDeviationEntries = Object.entries(deviations).map(([deviationKey, deviationMap]: [string, any]) => {\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n // Registry numbering is presentation metadata, not a render gate. A valid\n // highlight must still receive a badge if registry traversal missed it.\n const currentIndex = deviationNumberRegistry[refId] ?? nextFallbackDeviationIndex++;\n return { deviationKey, deviationMap, refId, currentIndex };\n });\n\n // Sort by global index BEFORE mapping to prevent negative/zero offsets\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const deviationEntries = rawDeviationEntries.map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) {\n highlight = \"\"; \n } else if (!highlight) {\n return null; \n }\n\n highlights.push(highlight);\n\n // MAPPING Stricter Left/Right Index mapping to prevent cross-wiring\n let leftIdx = idx;\n let rightIdx = idx;\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n rightIdx = rhsArrayIdx;\n } else {\n const rhsByIdIdx = existingSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n rightIdx = rhsByIdIdx !== -1 ? rhsByIdIdx : idx;\n }\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n leftIdx = lhsArrayIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n leftIdx = lhsByIdIdx !== -1 ? lhsByIdIdx : idx;\n }\n }\n }\n\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftIdx}${DEVIATION_BADGE_SEPARATOR}${rightIdx}`;\n \n // CONTENT Use the calculated mapped indices to grab correct counterpart text\n // const counterPartContentRaw = columnKey === \"left\" ? existingSections[rightIdx]?.content : proposedSections[leftIdx]?.content;\n const counterpartHighlight = deviationMap[counterPartNodeId as string];\n \n // Commented Out code for removing the highlight swallowing logic\n // let simulatedContent = safeStringify(counterPartContentRaw);\n\n // const counterPartHighlight = Object.keys(deviations)\n // .map(key => ({ key, text: deviations[key][counterPartNodeId as string] }))\n // .filter(item => !isMissingStr(item.text))\n // .sort((a, b) => b.text.length - a.text.length);\n\n // const survivingKeys = new Set();\n // counterPartHighlight.forEach(item => {\n // const clean = item.text.replace(/\\\\(['’])/g, \"$1\").replace(/\\\\n/g, \"\\n\");\n // if(!clean) return;\n\n // const regex = new RegExp(escapeRegExp(clean));\n // if(regex.test(simulatedContent)){\n // survivingKeys.add(item.key);\n // simulatedContent = simulatedContent.replace(regex, `__TOKEN_${item.key}__`);\n // }\n // });\n\n // const isCounterPartOverlapping = !isMissingStr(counterpartHighlight) && !survivingKeys.has(deviationKey);\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex = rhsOrphanVisualIndexes.get(refId);\n const mappedLhsIndex = lhsDeviationDisplayIndexes.get(refId);\n if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n orphanVisualIndex !== undefined\n ) {\n currentIndex = orphanVisualIndex;\n } else if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n !isDeviationOrphan &&\n mappedLhsIndex !== undefined\n ) {\n currentIndex = mappedLhsIndex;\n } else if (\n maintainRelativeOrder &&\n sectionOffset !== undefined &&\n (columnKey !== \"right\" || isDeviationOrphan || hasSingleMappedLhs)\n ) {\n currentIndex = currentIndex - sectionOffset;\n }\n currentIndex = Math.max(1, currentIndex);\n\n const badgeParentNum =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n unifiedNumbering\n ? getRhsMappedSectionNumber({\n section,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n\n let mappedIdx = idx;\n if (columnKey === \"right\" && maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const actualLhsIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (actualLhsIdx !== -1) {\n mappedIdx = actualLhsIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n if (lhsByIdIdx !== -1) mappedIdx = lhsByIdIdx;\n }\n }\n const baseStyle = getSectionCompareStyle ? getSectionCompareStyle(mappedIdx) : null;\n \n // let isUIOverlapping = false;\n // if (highlight) {\n // const allHighlights = Object.values(deviations).map((d: any) => d[parentNodeId as string]).filter(Boolean);\n // isUIOverlapping = allHighlights.some((otherHl: any) => otherHl.length > highlight.length && otherHl.includes(highlight));\n // }\n\n const deviationOutput = deviationMap?.evaluation_outputs || resolvedEvalResult?.evaluation_outputs;\n const deviationScore = deviationOutput?.output_value ?? null;\n const deviationColorForBadge = deviationOutput?.metadata?.label_color ?? deviationColorData;\n const deviationPaletteForBadge = generateColorPalette(deviationColorForBadge);\n let badgeStyle = baseStyle\n ? {\n ...baseStyle,\n badgeBg: deviationPaletteForBadge.badgeBg,\n badgeBorder: deviationPaletteForBadge.badgeBorder,\n badgeText: deviationPaletteForBadge.badgeText,\n }\n : { ...deviationPaletteForBadge };\n\n // if (isUIOverlapping) {\n // badgeStyle.badgeBg = \"#FFFBEB\";\n // badgeStyle.badgeBorder = \"#FCD34D\";\n // badgeStyle.badgeText = \"#B45309\";\n // badgeStyle.highlightBg = \"#FDE68A\";\n // }\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary,\n deviation_title: deviationMap?.deviation_title || resolvedEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || resolvedEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || resolvedEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || resolvedEvalResult?.cognitive_decisioning,\n }\n : null;\n\n // Logic for overlapping highlight badges\n let stackIndex = 0;\n const contentStr = baseContent || \"\";\n if (highlight && contentStr) {\n const paragraphs = contentStr.split(/\\n{2,}/);\n const paraIndex = paragraphs.findIndex(p => p.includes(highlight));\n if (paraIndex !== -1) {\n const devsInPara = Object.entries(deviations)\n .filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && paragraphs[paraIndex].includes(hl);\n })\n .sort((a: any, b: any) => paragraphs[paraIndex].indexOf(a[1][parentNodeId]) - paragraphs[paraIndex].indexOf(b[1][parentNodeId]));\n const overlappingDevs = devsInPara.filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && (hl.includes(highlight) || highlight.includes(hl));\n });\n if (overlappingDevs.length > 1) {\n stackIndex = Math.max(0, overlappingDevs.findIndex(([k]) => k === deviationKey));\n }\n }\n }\n const badgeRef = getBadgeRef(columnKey, refId);\n\n return {\n id: refId,\n actionId: actionId,\n label: badgeLabel,\n highlight,\n side: columnKey,\n style: badgeStyle,\n stackIndex,\n score: deviationScore,\n isConnected: connectedSections?.has(actionId),\n showScrollLockToggle:\n connectedSections?.has(actionId) ||\n (isSideBySide && activeSideBySideSection === actionId) ||\n (!!summaryPopupAnchorEl && summaryPopupAnchorEl === badgeRef.current),\n scrollSyncLocked,\n toggleScrollSyncLocked,\n isOrphan: isDeviationOrphan,\n isMissingClause,\n badgeRef,\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n\n if (openMoreFunctionsPopup) {\n openMoreFunctionsPopup(\n e as any, \n popupBaseSec || { id: \"orphan-left\", title: \"\", content: \"\" }, \n isDeviationOrphan, \n popupRefSec || { id: \"orphan-right\", title: \"\", content: \"\" }, \n actionId as any, \n badgeStyle as StyleVariant | null\n );\n }\n },\n\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n },\n };\n }).filter(Boolean);\n const baseShouldRenderBadges = showDeviationBadges || isProposedFixTarget;\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deviationEntries : [];\n\n // NEW: Sync highlights to prevent ghost highlights\n const highlightsToRender = deviationEntries.map((b: any) => b.highlight).filter(Boolean)\n\n const show =\n section.id && columnKey === navigation?.columnKey ? navigation : null;\n\n // Local ref added to prevent race conditions\n const hasScrolledRef = React.useRef(false);\n\n // Reset scroll flag when section closed\n useEffect(() => {\n if (!isExpanded) {\n hasScrolledRef.current = false;\n }\n }, [isExpanded]);\n // useEffect(()=>{\n // deviationNodeIdRef.current = deviationNodeIdToView;\n // deviationNodeParentRef.current = deviationTargetParentId || null;\n // }, [deviationNodeIdToView, deviationTargetParentId]);\n\n // Commented out the auto scroll functionality which was breaking the LSC -> RHS opening\n // useEffect(() => {\n // const isDeviationTargetSection =\n // !!deviationNodeIdRef.current &&\n // !!deviationNodeParentRef.current &&\n // nodeId === deviationNodeParentRef.current;\n // // NEW CONDITION: Check if the deviation target is one of the direct subsections\n // const isTargetInSubsections =\n // !!deviationNodeIdRef.current &&\n // (section.subsections || []).some(\n // (sub) => sub.id === deviationNodeIdRef.current\n // );\n\n // // Abort scroll if it's already scrolled, not expanded, is the target section, \n // // OR if the target is inside its subsections\n // if (\n // !isExpanded ||\n // hasScrolledRef.current ||\n // isDeviationTargetSection ||\n // isTargetInSubsections\n // ) {\n // return;\n // }\n\n // const timer = setTimeout(() => {\n // const firstDeviationEl = show?.firstDeviationRef?.current;\n // const firstDeviationPosition = show?.firstDeviationPosition;\n\n // if (!firstDeviationEl) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // if (\n // firstDeviationPosition === \"inside\" ||\n // isElementVisibleInScrollParent(firstDeviationEl)\n // ) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // hasScrolledRef.current = true;\n // firstDeviationEl.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }, 600);\n\n // return () => clearTimeout(timer);\n // }, [\n // isExpanded,\n // nodeId,\n // show?.firstDeviationPosition,\n // show?.firstDeviationRef,\n // ]);\n \n return (\n <Box\n key={`${columnKey}-sec-${idx}`}\n ref={colRef}\n sx={{\n mb,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n position: \"relative\",\n minWidth: 0,\n }}\n >\n {isExpanded && show?.showAbove && (\n <div\n style={{\n position: \"sticky\",\n top: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showAboveRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingTop: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronUp\n color={\n show?.showAboveRef?.current\n ? window.getComputedStyle(show.showAboveRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={() => {\n if (!isEmpty) {\n onToggle();\n showOpenNodeRef.current = section.id;\n }\n }}\n sx={{\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #E2E8F0\",\n bgcolor: isEmpty ? \"#FAFAFA\" : \"#FFFFFF\",\n borderRadius: \"6px\",\n flexGrow: 1,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n \"& .MuiAccordion-heading\": {\n position: \"sticky\",\n top: -12,\n zIndex: 10,\n background: \"#fff\",\n },\n }}\n >\n <AccordionSummary\n expandIcon={isEmpty ? null : <ChevronDown size={16} />}\n sx={{\n minHeight: \"36px\",\n flexShrink: 0,\n cursor: isEmpty ? \"default\" : \"pointer\",\n \"& .MuiAccordionSummary-content\": {\n my: 0.5,\n display: \"grid\",\n alignItems: \"center\",\n minWidth: 0,\n width: \"100%\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper\": {\n transition: \"transform 0.2s ease\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded\": {\n transform: \"rotate(180deg)\",\n },\n }}\n >\n {hasTitle && (\n <Tooltip title={displayTitle} placement=\"top\">\n <Typography\n component=\"div\"\n sx={{\n fontSize: \"12px\",\n color: isEmpty ? \"#94A3B8\" : \"#19213D\",\n fontWeight: isEmpty ? 400 : 700,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n width: \"100%\",\n minWidth: 0,\n }}\n >\n {renderSimpleMarkdown(visibleTitle, isMultipleMapping)}\n </Typography>\n </Tooltip>\n )}\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails\n sx={{\n pt: 0,\n pb: 1.25,\n bgcolor: \"#FFFFFF\",\n flex: 1,\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n }}\n >\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n fallbackContent={fallbackContent}\n sxStyles={resolvedMarkdownStyles}\n highlights={highlightsToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n deviationBadges={deviationBadgesToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) =>\n renderSubSectionAccordion({\n section: sub,\n keyPath: `${idx}-${subIdx}`,\n depth: 0,\n columnKey,\n parentNodeId,\n sectionOffset,\n rhsOrphanVisualIndexes,\n }),\n )}\n </AccordionDetails>\n )}\n </Accordion>\n {isExpanded && show?.showBelow && (\n <div\n style={{\n position: \"sticky\",\n bottom: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showBelowRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingBottom: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronDown\n color={\n show?.showBelowRef?.current\n ? window.getComputedStyle(show.showBelowRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n </Box>\n );\n};\n\nexport default SectionAccordion;\n"],"names":["renderSimpleMarkdown","text","isMultiTag","safeStringify","replace","split","map","part","i","startsWith","endsWith","children","slice","jsxs","style","display","alignItems","justifyContent","gap","width","jsx","minWidth","overflow","textOverflow","whiteSpace","padding","borderRadius","background","border","color","fontSize","fontWeight","flexShrink","lineHeight","marginRight","SectionAccordion","section","idx","columnKey","colRef","mb","isExpanded","onToggle","navigation","parentNodeId","showOpenNodeRef","resolvedMarkdownStyles","maintainRelativeOrder","showDeviationBadges","renderSubSectionAccordion","treeData","proposedSections","existingSections","deviationNumberRegistry","deviationParentRegistry","getBadgeRef","openSummaryPopup","getSectionCompareStyle","connectedSections","openMoreFunctionsPopup","isProposingFix","proposingFixNodeId","isRedlineFlow","isSideBySide","activeSideBySideSection","scrollSyncLocked","unifiedNumbering","toggleScrollSyncLocked","summaryPopupAnchorEl","useCompareContext","collisionKey","String","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","contentId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","changeHistoryContent","change_history","shouldOverlayContent","normalizedRedlineContent","React","useMemo","normalizeRedlineMarkdown","baseContent","stripRedlineTags","overlayContent","fallbackContent","hasContent","displayContent","isEmpty","isMultipleMapping","refContentIds","length","visibleTitle","trimEnd","targetEvalResult","evaluationResult","lhsSelfIndex","refIndexes","lhsSection","find","s","selfIndex","leftDocId","input_index_map","rightDocId","counterPartNodeId","findNodeByIdDeep","nodes","n","subsections","found","popupBaseSec","popupRefSec","sectionOffset","min","Infinity","normalizeInlineContent","value","raw","traverse","node","bNode","rNode","isTopLevel","topNodeId","mappedLhs","filter","l","includes","subNodeId","evalResult","devs","deviations","Object","keys","forEach","devKey","highlight","isMissingStr","normalizedHighlight","findTextMatchRange","canRenderInlineHighlight","refId1","DEVIATION_BADGE_SEPARATOR","idx1","refId2","idx2","subs","bSubs","rSubs","maxLen","Math","max","mappedLhsSections","lhs","rhsSelfIndex","rhs","Boolean","rhsSection","rhsArrayIdx","findIndex","lhsArrayIdx","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","resolvedEvalResult","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","lhsDeviationDisplayIndexes","getLhsDeviationDisplayIndexes","Map","rhsOrphanVisualIndexes","indexes","nextIndex","isOneToOneSection","normalizeContent","resolveNode","rhsNode","isRoot","lhsNode","registryNodeId","reserveMappedIndexes","normalizedContent","entries","deviationKey","deviationMap","registryIndex","child","visit","nodeDeviations","isOrphan","position","start","findTextRangeWithFormatting","refId","isRenderable","Number","MAX_SAFE_INTEGER","entry","sort","a","b","set","firstDeviationKey","firstRefId","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","nextFallbackDeviationIndex","isFinite","rawDeviationEntries","currentIndex","deviationEntries","item","isMissingClause","leftIdx","rightIdx","rhsByIdIdx","lhsByIdIdx","actionId","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","mappedIdx","actualLhsIdx","baseStyle","deviationOutput","deviationScore","output_value","deviationPaletteForBadge","badgeStyle","badgeBg","badgeBorder","badgeText","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","overlappingDevs","_","dMap","hl","indexOf","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","current","onClick","e","stopPropagation","onSummaryClick","deviationBadgesToRender","highlightsToRender","show","hasScrolledRef","useRef","useEffect","Box","ref","sx","flexDirection","showAbove","top","height","cursor","showAboveRef","scrollIntoView","behavior","block","transform","paddingTop","right","left","ChevronUp","window","getComputedStyle","Accordion","disableGutters","expanded","onChange","boxShadow","bgcolor","flexGrow","zIndex","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","transition","Tooltip","placement","Typography","component","AccordionDetails","pt","pb","flex","MemoizedMarkdown","sxStyles","highlights","deviationBadges","sub","subIdx","keyPath","depth","showBelow","bottom","showBelowRef","paddingBottom"],"mappings":"q7BAgCA,MAAMA,EAAuB,CAACC,EAAcC,GAAa,KACnD,IAACD,EAAa,OAAA,KAKlB,OAHuBE,EAAcF,GAAMG,QAAQ,OAAQ,MAC9BC,MAAM,kBAEtBC,IAAI,CAACC,EAAcC,IAC1BD,EAAKE,WAAW,OAASF,EAAKG,SAAS,QACjC,SAAgB,CAAAC,SAAAJ,EAAKK,MAAM,GAAG,IAAlBJ,GAIpBK,EAAC,MAAA,CAECC,MAAO,CACLC,QAAS,OACTC,WAAY,SACZC,eAAgB,gBAChBC,IAAK,MACLC,MAAO,QAGTR,SAAA,CAAAS,EAAC,OAAA,CACCN,MAAO,CACLO,SAAU,EACVC,SAAU,SACVC,aAAc,WACdC,WAAY,UAGbb,SAAAJ,IAGFL,GACCkB,EAAC,OAAA,CACCN,MAAO,CACLC,QAAS,cACTC,WAAY,SACZC,eAAgB,SAChBQ,QA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S,IACnBE,MAAO,EACPhT,YACAM,eACA+E,iBACAgE,mCAMTlJ,GAAcwP,IAAMsD,WACnBnU,EAAC,MAAA,CACCN,MAAO,CACLiM,SAAU,SACVyI,OAAQ,EACR7C,OAAQ,MACRC,OAAQ,WAEVjB,QAAS,IACPM,IAAMwD,cAAc/D,SAASoB,eAAe,CAC1CC,SAAU,SACVC,MAAO,WAIXrS,SAAAS,EAAC,MAAA,CACCN,MAAO,CACLmS,UAAW,yCACK,SAAd3Q,EAAuB,IAAM,cAE/ByK,SAAU,WACV2I,cAAe,UACG,SAAdpT,EAAuB,CAAC6Q,MAAO,SAAW,CAACC,KAAM,UAGvDzS,SAAAS,EAAC8S,EAAA,CACCrS,MACEoQ,IAAMwD,cAAc/D,QAChB4B,OAAOC,iBAAiBtB,GAAKwD,aAAa/D,SAAS7P,WACnD,UAxLT,GAAGS,SAAiBD"}
|
|
1
|
+
{"version":3,"file":"SectionAccordion.js","sources":["../../../../src/features/CognitiveCompare/components/SectionAccordion.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Box,\n Tooltip,\n Typography,\n} from \"@mui/material\";\nimport { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport { \n generateColorPalette, \n hasValue, \n safeStringify,\n DEVIATION_BADGE_SEPARATOR,\n isMissingStr,\n escapeRegExp,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\nimport { DeviationNavigationEntry } from \"../hooks/useDeviationNavigation\";\n\nconst renderSimpleMarkdown = (text: string, isMultiTag = false) => {\n if (!text) return null;\n\n const normalizedText = safeStringify(text).replace(/\\\\n/g, \"\\n\");\n const parts = normalizedText.split(/(\\*\\*.*?\\*\\*)/g);\n\n return parts.map((part: string, i: number) => {\n if (part.startsWith(\"**\") && part.endsWith(\"**\")) {\n return <strong key={i}>{part.slice(2, -2)}</strong>;\n }\n\n return (\n <div\n key={i}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"8px\",\n width: \"100%\",\n }}\n >\n <span\n style={{\n minWidth: 0,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {part}\n </span>\n\n {isMultiTag && (\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"0px 6px\",\n borderRadius: \"9999px\",\n background: \"#F3F4F6\",\n border: \"1px solid #D1D5DB\",\n color: \"#6B7280\",\n fontSize: \"9px\",\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n lineHeight: 1.4,\n marginRight: \"4px\",\n }}\n >\n Multiple\n </span>\n )}\n </div>\n );\n });\n};\n\nconst findScrollParent = (element: HTMLElement | null): HTMLElement | null => {\n let current = element?.parentElement || null;\n while (current) {\n const style = window.getComputedStyle(current);\n const overflowY = style.overflowY;\n const canScroll =\n (overflowY === \"auto\" || overflowY === \"scroll\") &&\n current.scrollHeight > current.clientHeight;\n\n if (canScroll) return current;\n current = current.parentElement;\n }\n\n return null;\n};\n\nconst isElementVisibleInScrollParent = (element: HTMLElement) => {\n const scrollParent = findScrollParent(element);\n const rect = element.getBoundingClientRect();\n const parentRect = scrollParent?.getBoundingClientRect() || {\n top: 0,\n bottom: window.innerHeight,\n };\n\n return rect.top >= parentRect.top && rect.bottom <= parentRect.bottom;\n};\n\ntype SectionAccordionProps = {\n section: SectionBlock;\n idx: number;\n columnKey: \"left\" | \"right\";\n colRef: React.RefObject<HTMLDivElement>;\n mb?: number;\n parentNodeId?: string;\n isExpanded: boolean;\n onToggle: () => void;\n navigation: DeviationNavigationEntry | null;\n};\n\nconst SectionAccordion = ({\n section,\n idx,\n columnKey,\n colRef,\n mb = 1,\n isExpanded,\n onToggle,\n navigation,\n parentNodeId = \"\",\n}: SectionAccordionProps) => {\n const {\n showOpenNodeRef,\n resolvedMarkdownStyles,\n maintainRelativeOrder,\n showDeviationBadges = false,\n renderSubSectionAccordion,\n treeData,\n proposedSections,\n existingSections,\n deviationNumberRegistry,\n deviationParentRegistry,\n getBadgeRef,\n openSummaryPopup,\n getSectionCompareStyle,\n connectedSections,\n openMoreFunctionsPopup,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n isSideBySide,\n activeSideBySideSection,\n scrollSyncLocked,\n unifiedNumbering,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n } = useCompareContext();\n const collisionKey = `${isSideBySide ? \"1\" : \"0\"}-${String(activeSideBySideSection ?? \"\")}`;\n const hasTitle = (section.displayTitle ?? true) && hasValue(section.title);\n const isProposedFixTarget =\n !!isProposingFix &&\n !!proposingFixNodeId &&\n columnKey === \"left\" &&\n (section.id === proposingFixNodeId || section.nodeId === proposingFixNodeId);\n \n const hasRedlineTags = hasMeaningfulRedlineTags(section.content);\n const inferredRedlineFlow = hasRedlineTags;\n const resolvedRedlineFlow =\n typeof isRedlineFlow === \"boolean\" ? isRedlineFlow : inferredRedlineFlow;\n const suppressHighlightBg = hasRedlineTags;\n\n // Use history as the base when redlines exist so badge matching still works.\n const shouldOverlayContent = resolvedRedlineFlow && hasRedlineTags;\n const baseContent = shouldOverlayContent\n ? stripRedlineTags(section.content)\n : section.content;\n const overlayContent = shouldOverlayContent ? section.content : undefined;\n const hasContent = ((section.displayContent ?? true) || hasRedlineTags) && hasValue(section.content);\n const isEmpty = !hasTitle && !hasContent;\n // const changeHistoryContent = section.change_history;\n // const isProposedFixTarget =\n // !!isProposingFix &&\n // !!proposingFixNodeId &&\n // columnKey === \"left\" &&\n // section.id === proposingFixNodeId;\n // const shouldOverlayContent = isProposedFixTarget && hasValue(changeHistoryContent);\n // const baseContent = shouldOverlayContent ? (changeHistoryContent || \"\") : section.content;\n // const overlayContent = shouldOverlayContent ? section.content : undefined;\n // const hasContent = (section.displayContent ?? true) && hasValue(baseContent);\n // const isEmpty = !hasTitle && !hasContent;\n\n \n\n let displayTitle = section.title;\n if (!hasTitle) {\n displayTitle = hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n }\n const isMultipleMapping =\n columnKey === \"left\" &&\n (section.isMultipleMapping || (section.refContentIds?.length ?? 1) > 1);\n const visibleTitle =\n columnKey === \"left\" && displayTitle.length > 29\n ? `${displayTitle.slice(0, 29).trimEnd()}...`\n : displayTitle;\n\n let targetEvalResult = section.evaluationResult;\n if (!targetEvalResult && columnKey === \"right\") {\n if (maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsSection = proposedSections.find((s: any) => s.selfIndex === lhsSelfIndex);\n targetEvalResult = lhsSection?.evaluationResult;\n } else {\n targetEvalResult = proposedSections[idx]?.evaluationResult;\n }\n }\n\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterPartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n const findNodeByIdDeep = (nodes: any[], id?: string): any => {\n if (!id || !nodes) return null;\n for (const n of nodes) {\n if (n.id === id || n.nodeId === id || n.contentId === id) return n;\n if (n.subsections?.length) {\n const found = findNodeByIdDeep(n.subsections, id);\n if (found) return found;\n }\n }\n return null;\n };\n\n let popupBaseSec: any = columnKey === \"left\" ? section : findNodeByIdDeep(proposedSections, section.id);\n let popupRefSec: any = columnKey === \"right\" ? section : findNodeByIdDeep(existingSections, section.id);\n\n const sectionOffset = React.useMemo(() => {\n if (!maintainRelativeOrder) return 0;\n let min = Infinity;\n\n const normalizeInlineContent = (value: unknown) => {\n const raw = hasMeaningfulRedlineTags(value) ? stripRedlineTags(value) : value;\n return safeStringify(raw || \"\").replace(/\\\\n/g, \"\\n\");\n };\n\n const canRenderInlineHighlight = (node: SectionBlock, highlight: unknown) => {\n if (typeof highlight !== \"string\" || isMissingStr(highlight)) return false;\n const content = normalizeInlineContent(node?.content);\n const normalizedHighlight = normalizeInlineContent(highlight);\n return !!normalizedHighlight && content.includes(normalizedHighlight);\n };\n\n const traverse = (node: any, bNode: any, rNode: any, isTopLevel: boolean) => {\n if (!node) return;\n\n let topNodeId = node.nodeId || node.id;\n if (isTopLevel && columnKey === \"right\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(node.selfIndex));\n if (mappedLhs.length > 0) topNodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n }\n\n let subNodeId = node.nodeId || node.id || bNode?.nodeId || bNode?.id || rNode?.nodeId || rNode?.id;\n\n const evalResult = node.evaluationResult || bNode?.evaluationResult || rNode?.evaluationResult;\n const devs = evalResult?.deviations || {};\n Object.keys(devs).forEach(devKey => {\n const highlight = devs[devKey]?.[parentNodeId];\n const renderNode = columnKey === \"left\" ? (bNode || node) : (rNode || node);\n if (!canRenderInlineHighlight(renderNode, highlight)) return;\n\n const refId1 = `${topNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx1 = deviationNumberRegistry?.[refId1];\n if (idx1 !== undefined && idx1 !== null && idx1 < min) min = idx1;\n\n const refId2 = `${subNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx2 = deviationNumberRegistry?.[refId2];\n if (idx2 !== undefined && idx2 !== null && idx2 < min) min = idx2;\n });\n\n const subs = node.subsections || [];\n const bSubs = bNode?.subsections || [];\n const rSubs = rNode?.subsections || [];\n const maxLen = Math.max(subs.length, bSubs.length, rSubs.length);\n\n for (let i = 0; i < maxLen; i++) {\n traverse(subs[i], bSubs[i], rSubs[i], false);\n }\n };\n\n const mappedLhsSections = columnKey === \"right\"\n ? proposedSections.filter((lhs: SectionBlock) => lhs.refIndexes?.includes(section.selfIndex as number))\n : [];\n\n if (mappedLhsSections.length === 1) {\n const mappedLhs = mappedLhsSections[0] as SectionBlock;\n const mappedRhsSections = (mappedLhs.refIndexes || [])\n .map((rhsSelfIndex: number) =>\n existingSections.find((rhs: SectionBlock) => rhs.selfIndex === rhsSelfIndex),\n )\n .filter(Boolean);\n\n mappedRhsSections.forEach((rhsSection: any) => {\n traverse(rhsSection, mappedLhs, rhsSection, true);\n });\n } else {\n traverse(section, popupBaseSec, popupRefSec, true);\n }\n\n return min !== Infinity ? min - 1 : 0;\n }, [section, popupBaseSec, popupRefSec, columnKey, parentNodeId, deviationNumberRegistry, maintainRelativeOrder, proposedSections, existingSections]);\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n popupRefSec = rhsArrayIdx !== -1\n ? existingSections[rhsArrayIdx]\n : findNodeByIdDeep(existingSections, section.id);\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n popupBaseSec = lhsArrayIdx !== -1\n ? proposedSections[lhsArrayIdx]\n : findNodeByIdDeep(proposedSections, section.id);\n }\n }\n\n const isSecOrphan = columnKey === \"left\" ? !popupRefSec : !popupBaseSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(section, proposedSections);\n\n const resolvedEvalResult = targetEvalResult || popupBaseSec?.evaluationResult || popupRefSec?.evaluationResult;\n const deviationColorData = resolvedEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n const deviations = resolvedEvalResult?.deviations || {};\n\n const lhsDeviationDisplayIndexes = React.useMemo(\n () =>\n maintainRelativeOrder && columnKey === \"right\"\n ? getLhsDeviationDisplayIndexes(\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n )\n : new Map<string, number>(),\n [\n maintainRelativeOrder,\n columnKey,\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n ],\n );\n\n let nodeId = section.nodeId || section.id;\n\n // For RHS mapped sections, nodeId must match what the registry used (LHS id)\n if (maintainRelativeOrder && columnKey !== \"left\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(section.selfIndex));\n if (mappedLhs.length > 0) {\n nodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n } else if (popupBaseSec?.id) {\n nodeId = popupBaseSec.nodeId || popupBaseSec.id;\n }\n }\n\n const rhsOrphanVisualIndexes = React.useMemo(() => {\n const indexes = new Map<string, number>();\n if (!maintainRelativeOrder || columnKey !== \"right\") return indexes;\n\n let nextIndex = 1;\n const mappedLhsSections = proposedSections.filter((lhs: SectionBlock) =>\n lhs.refIndexes?.includes(section.selfIndex as number),\n );\n const isOneToOneSection =\n mappedLhsSections.length === 1 &&\n mappedLhsSections[0].refIndexes?.length === 1;\n const normalizeContent = (value: unknown) =>\n safeStringify(value || \"\").replace(/\\\\n/g, \"\\n\");\n\n const resolveNode = (rhsNode: SectionBlock, isRoot: boolean) => {\n const lhsNode = isRoot\n ? mappedLhsSections[0]\n : findNodeByIdDeep(\n proposedSections,\n rhsNode.nodeId || rhsNode.id || rhsNode.contentId,\n );\n const evalResult =\n rhsNode.evaluationResult || lhsNode?.evaluationResult;\n const registryNodeId = lhsNode\n ? lhsNode.nodeId || lhsNode.id\n : rhsNode.nodeId || rhsNode.id;\n return { lhsNode, evalResult, registryNodeId };\n };\n\n if (isOneToOneSection) {\n const reserveMappedIndexes = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(evalResult?.deviations || {}).forEach(\n ([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const normalizedHighlight = normalizeContent(highlight);\n const isMapped =\n !!lhsNode &&\n !isMissingStr(deviationMap[counterPartNodeId as string]);\n if (\n !isMapped ||\n !normalizedHighlight ||\n !normalizedContent.includes(normalizedHighlight)\n ) return;\n\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const registryIndex = deviationNumberRegistry[refId];\n if (registryIndex === undefined || registryIndex === null) return;\n nextIndex = Math.max(\n nextIndex,\n Math.max(1, registryIndex - (sectionOffset || 0)) + 1,\n );\n },\n );\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) =>\n reserveMappedIndexes(child),\n );\n };\n\n reserveMappedIndexes(section, true);\n }\n\n const visit = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const nodeDeviations = evalResult?.deviations || {};\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(nodeDeviations)\n .map(([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const isOrphan =\n !lhsNode || isMissingStr(deviationMap[counterPartNodeId as string]);\n const normalizedHighlight = normalizeContent(highlight);\n const position = normalizedHighlight\n ? normalizedContent.indexOf(normalizedHighlight)\n : -1;\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n return {\n refId,\n isRenderable:\n isOrphan && !!normalizedHighlight && !isMissingStr(highlight),\n position,\n registryIndex: deviationNumberRegistry[refId] ?? Number.MAX_SAFE_INTEGER,\n };\n })\n .filter((entry) => entry.isRenderable)\n .sort((a, b) => {\n const aPosition =\n a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition =\n b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.registryIndex - b.registryIndex;\n })\n .forEach((entry) => {\n indexes.set(entry.refId, nextIndex++);\n });\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) => visit(child));\n };\n\n visit(section, true);\n return indexes;\n }, [\n maintainRelativeOrder,\n columnKey,\n section,\n proposedSections,\n parentNodeId,\n counterPartNodeId,\n deviationNumberRegistry,\n sectionOffset,\n ]);\n\n // Derive validatedParentNum from registry\n const firstDeviationKey = Object.keys(deviations)[0];\n const firstRefId = firstDeviationKey ? `${nodeId}${DEVIATION_BADGE_SEPARATOR}${firstDeviationKey}` : null;\n const registeredParentNum = firstRefId ? (deviationParentRegistry?.[firstRefId] as number) : null;\n\n let validatedParentNum: string | number = idx + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(section?.id as string) \n : unifiedNumbering.rightNums.get(section?.id as string);\n \n if (isSecOrphan && unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n } else if (unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n }\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n }\n // const deviationNodeIdRef = useRef<string | undefined>(deviationNodeIdToView);\n // const deviationNodeParentRef = useRef<string | null>(deviationTargetParentId || null);\n const highlights: string[] = [];\n // Mapp through deviations to pass to memoized markdown for highlighting, also prepare deviation badges \n const rawDeviationEntries = Object.entries(deviations).map(([deviationKey, deviationMap]: [string, any]) => {\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const currentIndex = deviationNumberRegistry[refId];\n return { deviationKey, deviationMap, refId, currentIndex };\n }).filter(item => item.currentIndex !== undefined && item.currentIndex !== null);\n\n // Sort by global index BEFORE mapping to prevent negative/zero offsets\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const deviationEntries = rawDeviationEntries.map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) {\n highlight = \"\"; \n } else if (!highlight) {\n return null; \n }\n\n highlights.push(highlight);\n\n // MAPPING Stricter Left/Right Index mapping to prevent cross-wiring\n let leftIdx = idx;\n let rightIdx = idx;\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n rightIdx = rhsArrayIdx;\n } else {\n const rhsByIdIdx = existingSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n rightIdx = rhsByIdIdx !== -1 ? rhsByIdIdx : idx;\n }\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n leftIdx = lhsArrayIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n leftIdx = lhsByIdIdx !== -1 ? lhsByIdIdx : idx;\n }\n }\n }\n\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftIdx}${DEVIATION_BADGE_SEPARATOR}${rightIdx}`;\n \n // CONTENT Use the calculated mapped indices to grab correct counterpart text\n // const counterPartContentRaw = columnKey === \"left\" ? existingSections[rightIdx]?.content : proposedSections[leftIdx]?.content;\n const counterpartHighlight = deviationMap[counterPartNodeId as string];\n \n // Commented Out code for removing the highlight swallowing logic\n // let simulatedContent = safeStringify(counterPartContentRaw);\n\n // const counterPartHighlight = Object.keys(deviations)\n // .map(key => ({ key, text: deviations[key][counterPartNodeId as string] }))\n // .filter(item => !isMissingStr(item.text))\n // .sort((a, b) => b.text.length - a.text.length);\n\n // const survivingKeys = new Set();\n // counterPartHighlight.forEach(item => {\n // const clean = item.text.replace(/\\\\(['’])/g, \"$1\").replace(/\\\\n/g, \"\\n\");\n // if(!clean) return;\n\n // const regex = new RegExp(escapeRegExp(clean));\n // if(regex.test(simulatedContent)){\n // survivingKeys.add(item.key);\n // simulatedContent = simulatedContent.replace(regex, `__TOKEN_${item.key}__`);\n // }\n // });\n\n // const isCounterPartOverlapping = !isMissingStr(counterpartHighlight) && !survivingKeys.has(deviationKey);\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex = rhsOrphanVisualIndexes.get(refId);\n const mappedLhsIndex = lhsDeviationDisplayIndexes.get(refId);\n if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n orphanVisualIndex !== undefined\n ) {\n currentIndex = orphanVisualIndex;\n } else if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n !isDeviationOrphan &&\n mappedLhsIndex !== undefined\n ) {\n currentIndex = mappedLhsIndex;\n } else if (\n maintainRelativeOrder &&\n sectionOffset !== undefined &&\n (columnKey !== \"right\" || isDeviationOrphan || hasSingleMappedLhs)\n ) {\n currentIndex = currentIndex - sectionOffset;\n }\n currentIndex = Math.max(1, currentIndex);\n\n const badgeParentNum =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n unifiedNumbering\n ? getRhsMappedSectionNumber({\n section,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n\n let mappedIdx = idx;\n if (columnKey === \"right\" && maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const actualLhsIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (actualLhsIdx !== -1) {\n mappedIdx = actualLhsIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n if (lhsByIdIdx !== -1) mappedIdx = lhsByIdIdx;\n }\n }\n const baseStyle = getSectionCompareStyle ? getSectionCompareStyle(mappedIdx) : null;\n \n // let isUIOverlapping = false;\n // if (highlight) {\n // const allHighlights = Object.values(deviations).map((d: any) => d[parentNodeId as string]).filter(Boolean);\n // isUIOverlapping = allHighlights.some((otherHl: any) => otherHl.length > highlight.length && otherHl.includes(highlight));\n // }\n\n const deviationOutput = deviationMap?.evaluation_outputs || resolvedEvalResult?.evaluation_outputs;\n const deviationScore = deviationOutput?.output_value ?? null;\n const deviationColorForBadge = deviationOutput?.metadata?.label_color ?? deviationColorData;\n const deviationPaletteForBadge = generateColorPalette(deviationColorForBadge);\n let badgeStyle = baseStyle\n ? {\n ...baseStyle,\n badgeBg: deviationPaletteForBadge.badgeBg,\n badgeBorder: deviationPaletteForBadge.badgeBorder,\n badgeText: deviationPaletteForBadge.badgeText,\n }\n : { ...deviationPaletteForBadge };\n\n // if (isUIOverlapping) {\n // badgeStyle.badgeBg = \"#FFFBEB\";\n // badgeStyle.badgeBorder = \"#FCD34D\";\n // badgeStyle.badgeText = \"#B45309\";\n // badgeStyle.highlightBg = \"#FDE68A\";\n // }\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary,\n deviation_title: deviationMap?.deviation_title || resolvedEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || resolvedEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || resolvedEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || resolvedEvalResult?.cognitive_decisioning,\n }\n : null;\n\n // Logic for overlapping highlight badges\n let stackIndex = 0;\n const contentStr = baseContent || \"\";\n if (highlight && contentStr) {\n const paragraphs = contentStr.split(/\\n{2,}/);\n const paraIndex = paragraphs.findIndex(p => p.includes(highlight));\n if (paraIndex !== -1) {\n const devsInPara = Object.entries(deviations)\n .filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && paragraphs[paraIndex].includes(hl);\n })\n .sort((a: any, b: any) => paragraphs[paraIndex].indexOf(a[1][parentNodeId]) - paragraphs[paraIndex].indexOf(b[1][parentNodeId]));\n const overlappingDevs = devsInPara.filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && (hl.includes(highlight) || highlight.includes(hl));\n });\n if (overlappingDevs.length > 1) {\n stackIndex = Math.max(0, overlappingDevs.findIndex(([k]) => k === deviationKey));\n }\n }\n }\n const badgeRef = getBadgeRef(columnKey, refId);\n\n return {\n id: refId,\n actionId: actionId,\n label: badgeLabel,\n highlight,\n side: columnKey,\n style: badgeStyle,\n stackIndex,\n score: deviationScore,\n isConnected: connectedSections?.has(actionId),\n showScrollLockToggle:\n connectedSections?.has(actionId) ||\n (isSideBySide && activeSideBySideSection === actionId) ||\n (!!summaryPopupAnchorEl && summaryPopupAnchorEl === badgeRef.current),\n scrollSyncLocked,\n toggleScrollSyncLocked,\n isOrphan: isDeviationOrphan,\n isMissingClause,\n badgeRef,\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n\n if (openMoreFunctionsPopup) {\n openMoreFunctionsPopup(\n e as any, \n popupBaseSec || { id: \"orphan-left\", title: \"\", content: \"\" }, \n isDeviationOrphan, \n popupRefSec || { id: \"orphan-right\", title: \"\", content: \"\" }, \n actionId as any, \n badgeStyle as StyleVariant | null\n );\n }\n },\n\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n },\n };\n }).filter(Boolean);\n const baseShouldRenderBadges =\n showDeviationBadges || (!resolvedRedlineFlow && isProposedFixTarget);\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deviationEntries : [];\n\n // NEW: Sync highlights to prevent ghost highlights\n const highlightsToRender = deviationEntries.map((b: any) => b.highlight).filter(Boolean)\n\n const show =\n section.id && columnKey === navigation?.columnKey ? navigation : null;\n\n // Local ref added to prevent race conditions\n const hasScrolledRef = React.useRef(false);\n\n // Reset scroll flag when section closed\n useEffect(() => {\n if (!isExpanded) {\n hasScrolledRef.current = false;\n }\n }, [isExpanded]);\n // useEffect(()=>{\n // deviationNodeIdRef.current = deviationNodeIdToView;\n // deviationNodeParentRef.current = deviationTargetParentId || null;\n // }, [deviationNodeIdToView, deviationTargetParentId]);\n\n // Commented out the auto scroll functionality which was breaking the LSC -> RHS opening\n // useEffect(() => {\n // const isDeviationTargetSection =\n // !!deviationNodeIdRef.current &&\n // !!deviationNodeParentRef.current &&\n // nodeId === deviationNodeParentRef.current;\n // // NEW CONDITION: Check if the deviation target is one of the direct subsections\n // const isTargetInSubsections =\n // !!deviationNodeIdRef.current &&\n // (section.subsections || []).some(\n // (sub) => sub.id === deviationNodeIdRef.current\n // );\n\n // // Abort scroll if it's already scrolled, not expanded, is the target section, \n // // OR if the target is inside its subsections\n // if (\n // !isExpanded ||\n // hasScrolledRef.current ||\n // isDeviationTargetSection ||\n // isTargetInSubsections\n // ) {\n // return;\n // }\n\n // const timer = setTimeout(() => {\n // const firstDeviationEl = show?.firstDeviationRef?.current;\n // const firstDeviationPosition = show?.firstDeviationPosition;\n\n // if (!firstDeviationEl) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // if (\n // firstDeviationPosition === \"inside\" ||\n // isElementVisibleInScrollParent(firstDeviationEl)\n // ) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // hasScrolledRef.current = true;\n // firstDeviationEl.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }, 600);\n\n // return () => clearTimeout(timer);\n // }, [\n // isExpanded,\n // nodeId,\n // show?.firstDeviationPosition,\n // show?.firstDeviationRef,\n // ]);\n \n return (\n <Box\n key={`${columnKey}-sec-${idx}`}\n ref={colRef}\n sx={{\n mb,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n position: \"relative\",\n minWidth: 0,\n }}\n >\n {isExpanded && show?.showAbove && (\n <div\n style={{\n position: \"sticky\",\n top: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showAboveRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingTop: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronUp\n color={\n show?.showAboveRef?.current\n ? window.getComputedStyle(show.showAboveRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={() => {\n if (!isEmpty) {\n onToggle();\n showOpenNodeRef.current = section.id;\n }\n }}\n sx={{\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #E2E8F0\",\n bgcolor: isEmpty ? \"#FAFAFA\" : \"#FFFFFF\",\n borderRadius: \"6px\",\n flexGrow: 1,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n \"& .MuiAccordion-heading\": {\n position: \"sticky\",\n top: -12,\n zIndex: 10,\n background: \"#fff\",\n },\n }}\n >\n <AccordionSummary\n expandIcon={isEmpty ? null : <ChevronDown size={16} />}\n sx={{\n minHeight: \"36px\",\n flexShrink: 0,\n cursor: isEmpty ? \"default\" : \"pointer\",\n \"& .MuiAccordionSummary-content\": {\n my: 0.5,\n display: \"grid\",\n alignItems: \"center\",\n minWidth: 0,\n width: \"100%\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper\": {\n transition: \"transform 0.2s ease\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded\": {\n transform: \"rotate(180deg)\",\n },\n }}\n >\n {hasTitle && (\n <Tooltip title={displayTitle} placement=\"top\">\n <Typography\n component=\"div\"\n sx={{\n fontSize: \"12px\",\n color: isEmpty ? \"#94A3B8\" : \"#19213D\",\n fontWeight: isEmpty ? 400 : 700,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n width: \"100%\",\n minWidth: 0,\n }}\n >\n {renderSimpleMarkdown(visibleTitle, isMultipleMapping)}\n </Typography>\n </Tooltip>\n )}\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails\n sx={{\n pt: 0,\n pb: 1.25,\n bgcolor: \"#FFFFFF\",\n flex: 1,\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n }}\n >\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n sxStyles={resolvedMarkdownStyles}\n highlights={highlightsToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n deviationBadges={deviationBadgesToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) =>\n renderSubSectionAccordion({\n section: sub,\n keyPath: `${idx}-${subIdx}`,\n depth: 0,\n columnKey,\n parentNodeId,\n sectionOffset,\n rhsOrphanVisualIndexes,\n }),\n )}\n </AccordionDetails>\n )}\n </Accordion>\n {isExpanded && show?.showBelow && (\n <div\n style={{\n position: \"sticky\",\n bottom: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showBelowRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingBottom: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronDown\n color={\n show?.showBelowRef?.current\n ? window.getComputedStyle(show.showBelowRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n </Box>\n );\n};\n\nexport default SectionAccordion;\n"],"names":["renderSimpleMarkdown","text","isMultiTag","safeStringify","replace","split","map","part","i","startsWith","endsWith","children","slice","jsxs","style","display","alignItems","justifyContent","gap","width","jsx","minWidth","overflow","textOverflow","whiteSpace","padding","borderRadius","background","border","color","fontSize","fontWeight","flexShrink","lineHeight","marginRight","SectionAccordion","section","idx","columnKey","colRef","mb","isExpanded","onToggle","navigation","parentNodeId","showOpenNodeRef","resolvedMarkdownStyles","maintainRelativeOrder","showDeviationBadges","renderSubSectionAccordion","treeData","proposedSections","existingSections","deviationNumberRegistry","deviationParentRegistry","getBadgeRef","openSummaryPopup","getSectionCompareStyle","connectedSections","openMoreFunctionsPopup","isProposingFix","proposingFixNodeId","isRedlineFlow","isSideBySide","activeSideBySideSection","scrollSyncLocked","unifiedNumbering","toggleScrollSyncLocked","summaryPopupAnchorEl","useCompareContext","collisionKey","String","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","shouldOverlayContent","baseContent","stripRedlineTags","overlayContent","hasContent","displayContent","isEmpty","isMultipleMapping","refContentIds","length","visibleTitle","trimEnd","targetEvalResult","evaluationResult","lhsSelfIndex","refIndexes","lhsSection","find","s","selfIndex","leftDocId","input_index_map","rightDocId","counterPartNodeId","findNodeByIdDeep","nodes","n","contentId","subsections","found","popupBaseSec","popupRefSec","sectionOffset","React","useMemo","min","Infinity","normalizeInlineContent","value","raw","traverse","node","bNode","rNode","isTopLevel","topNodeId","mappedLhs","filter","l","includes","subNodeId","evalResult","devs","deviations","Object","keys","forEach","devKey","highlight","isMissingStr","normalizedHighlight","canRenderInlineHighlight","refId1","DEVIATION_BADGE_SEPARATOR","idx1","refId2","idx2","subs","bSubs","rSubs","maxLen","Math","max","mappedLhsSections","lhs","rhsSelfIndex","rhs","Boolean","rhsSection","rhsArrayIdx","findIndex","lhsArrayIdx","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","resolvedEvalResult","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","lhsDeviationDisplayIndexes","getLhsDeviationDisplayIndexes","Map","rhsOrphanVisualIndexes","indexes","nextIndex","isOneToOneSection","normalizeContent","resolveNode","rhsNode","isRoot","lhsNode","registryNodeId","reserveMappedIndexes","normalizedContent","entries","deviationKey","deviationMap","registryIndex","child","visit","nodeDeviations","isOrphan","position","indexOf","refId","isRenderable","Number","MAX_SAFE_INTEGER","entry","sort","a","b","set","firstDeviationKey","firstRefId","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","rawDeviationEntries","currentIndex","item","deviationEntries","isMissingClause","leftIdx","rightIdx","rhsByIdIdx","lhsByIdIdx","actionId","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","mappedIdx","actualLhsIdx","baseStyle","deviationOutput","deviationScore","output_value","deviationPaletteForBadge","badgeStyle","badgeBg","badgeBorder","badgeText","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","overlappingDevs","_","dMap","hl","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","current","onClick","e","stopPropagation","onSummaryClick","deviationBadgesToRender","highlightsToRender","show","hasScrolledRef","useRef","useEffect","Box","ref","sx","flexDirection","showAbove","top","height","cursor","showAboveRef","scrollIntoView","behavior","block","transform","paddingTop","right","left","ChevronUp","window","getComputedStyle","Accordion","disableGutters","expanded","onChange","boxShadow","bgcolor","flexGrow","zIndex","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","transition","Tooltip","placement","Typography","component","AccordionDetails","pt","pb","flex","MemoizedMarkdown","sxStyles","highlights","deviationBadges","sub","subIdx","keyPath","depth","showBelow","bottom","showBelowRef","paddingBottom"],"mappings":"2vBA6BA,MAAMA,EAAuB,CAACC,EAAcC,GAAa,KACnD,IAACD,EAAa,OAAA,KAKlB,OAHuBE,EAAcF,GAAMG,QAAQ,OAAQ,MAC9BC,MAAM,kBAEtBC,IAAI,CAACC,EAAcC,IAC1BD,EAAKE,WAAW,OAASF,EAAKG,SAAS,QACjC,SAAgB,CAAAC,SAAAJ,EAAKK,MAAM,GAAG,IAAlBJ,GAIpBK,EAAC,MAAA,CAECC,MAAO,CACLC,QAAS,OACTC,WAAY,SACZC,eAAgB,gBAChBC,IAAK,MACLC,MAAO,QAGTR,SAAA,CAAAS,EAAC,OAAA,CACCN,MAAO,CACLO,SAAU,EACVC,SAAU,SACVC,aAAc,WACdC,WAAY,UAGbb,SAAAJ,IAGFL,GACCkB,EAAC,OAAA,CACCN,MAAO,CACLC,QAAS,cACTC,WAAY,SACZC,eAAgB,SAChBQ,QAAS,UACTC,aAAc,SACdC,WAAY,UACZC,OAAQ,oBACRC,MAAO,UACPC,SAAU,MACVC,WAAY,IACZP,WAAY,SACZQ,WAAY,EACZC,WAAY,IACZC,YAAa,OAEhBvB,SAAA,eAtCEH,KAsFP2B,EAAmB,EACvBC,UACAC,MACAC,YACAC,SACAC,KAAK,EACLC,aACAC,WACAC,aACAC,eAAe,OAET,MAAAC,gBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,0BACtBA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,wBACAA,EAAAC,wBACAA,EAAAC,YACAA,EAAAC,iBACAA,EAAAC,uBACAA,EAAAC,kBACAA,EAAAC,uBACAA,EAAAC,eACAA,EAAAC,mBACAA,EAAAC,cACAA,EAAAC,aACAA,EAAAC,wBACAA,GAAAC,iBACAA,GAAAC,iBACAA,GAAAC,uBACAA,GAAAC,qBACAA,IACEC,IACEC,GAAe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EACVyR,WAAYjD,GACZvO,wBACAkI,eACA9F,uBACAqP,gBAAiBnD,GACjB/M,mBAGFlC,EAAQ4E,aAAe,IAAI1G,IAAI,CAACmU,EAAKC,IACrCzR,EAA0B,CACxBb,QAASqS,EACTE,QAAS,GAAGtS,KAAOqS,IACnBE,MAAO,EACPtS,YACAM,eACAwE,iBACAiE,mCAMT5I,GAAc8O,IAAMsD,WACnBzT,EAAC,MAAA,CACCN,MAAO,CACL2L,SAAU,SACVqI,OAAQ,EACR7C,OAAQ,MACRC,OAAQ,WAEVjB,QAAS,IACPM,IAAMwD,cAAc/D,SAASoB,eAAe,CAC1CC,SAAU,SACVC,MAAO,WAIX3R,SAAAS,EAAC,MAAA,CACCN,MAAO,CACLyR,UAAW,yCACK,SAAdjQ,EAAuB,IAAM,cAE/BmK,SAAU,WACVuI,cAAe,UACG,SAAd1S,EAAuB,CAACmQ,MAAO,SAAW,CAACC,KAAM,UAGvD/R,SAAAS,EAACoS,EAAA,CACC3R,MACE0P,IAAMwD,cAAc/D,QAChB4B,OAAOC,iBAAiBtB,GAAKwD,aAAa/D,SAASnP,WACnD,UAvLT,GAAGS,SAAiBD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useMemo as i}from"react";import{Box as o,Accordion as s,AccordionSummary as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useMemo as i}from"react";import{Box as o,Accordion as s,AccordionSummary as d,Typography as l,AccordionDetails as r}from"@mui/material";import{ChevronDown as a}from"lucide-react";import{MemoizedMarkdown as c}from"../hooks/memoizedMarkdown.js";import{useCompareContext as u}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,stripRedlineTags as f,hasSingleMappedLhsSection as g,getLhsDeviationDisplayIndexes as m,generateColorPalette as x,safeStringify as v,isMissingStr as y,getRhsMappedSectionNumber as S,DEVIATION_BADGE_SEPARATOR as I}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as b}from"../CognitiveCompareConstants.js";const _=n.memo(n=>{const{section:$,keyPath:k,depth:w=0,columnKey:C="left",parentNodeId:F="",sectionOffset:O,rhsOrphanVisualIndexes:P}=n,{expandedSubSections:N,setExpandedSubSections:B,maintainRelativeOrder:M,showDeviationBadges:R=!1,proposedSections:E,existingSections:j,treeData:A,deviationNumberRegistry:K,deviationParentRegistry:W,connectedSections:L,activeSideBySideSection:T,isSideBySide:z,scrollSyncLocked:D,toggleScrollSyncLocked:G,summaryPopupAnchorEl:H,resolvedMarkdownStyles:V,getSubSectionRef:X,getSubSectionCompareStyle:U,getBadgeRef:q,openMoreFunctionsPopup:J,openSummaryPopup:Q,resetSideBySide:Y,setConnectedSections:Z,setConnectedLines:ee,cachedConnectedPositions:te,isProposingFix:ne,proposingFixNodeId:ie,isRedlineFlow:oe,unifiedNumbering:se}=u(),de=T??"",le=($.displayTitle??!0)&&p($.title),re=!(!ne||!ie||"left"!==C||$.id!==ie&&$.nodeId!==ie),ae=h($.content),ce="boolean"==typeof oe?oe:ae,ue=ae,pe=ce&&ae,he=pe?f($.content):$.content,fe=pe?$.content:void 0,ge=(($.displayContent??!0)||ae)&&p($.content),me=!le&&!ge,xe=le?$.title:ge?"No Title Found":"No Matching Section Found",ve=!!N[k],ye=X(C,k),Se=k.split("-").map(Number)[0];let Ie=E[Se],be=j[Se],_e=Se,$e=Se,ke=!1;const we=(e,t,n)=>{if(!e||!t)return null;if(e.id===t||e.nodeId===t||e.contentId===t)return{section:e,keyPath:n};const i=(e.subsections||[]).map((e,t)=>({section:e,keyPath:`${n}-${t}`}));for(;i.length>0;){const e=i.shift();if(e?.section){if(e.section.id===t||e.section.nodeId===t||e.section.contentId===t)return e;(e.section.subsections||[]).forEach((t,n)=>{i.push({section:t,keyPath:`${e.keyPath}-${n}`})})}}return null};if(M)if("left"===C){const e=Ie?.refIndexes?.[0],t=j.findIndex(t=>t.selfIndex===e);-1!==t?(be=j[t],$e=t):ke=!0}else{const e=be?.refIndexes?.[0],t=E.findIndex(t=>t.selfIndex===e);-1!==t?(Ie=E[t],_e=t):ke=!0}const Ce=(e,t)=>{if(!t||!e)return null;for(let n=0;n<e.length;n++){const i=we(e[n],t,String(n));if(i)return i}return null};let Fe=null,Oe=null,Pe="",Ne="";if(M)if("left"===C){Fe=$,Pe=k;let e=we(be,$.nodeId||$.id,String($e));e||(e=Ce(j,$.nodeId||$.id)),Oe=e?.section||null,Ne=e?.keyPath||""}else{Oe=$,Ne=k;let e=we(Ie,$.nodeId||$.id,String(_e));e||(e=Ce(E,$.nodeId||$.id)),Fe=e?.section||null,Pe=e?.keyPath||""}else if("left"===C){Fe=$,Pe=k;const e=Ce(j,$.nodeId||$.id);Oe=e?.section||null,Ne=e?.keyPath||""}else{Oe=$,Ne=k;const e=Ce(E,$.nodeId||$.id);Fe=e?.section||null,Pe=e?.keyPath||""}const Be=(Pe?U(Pe):null)||U(k),Me=A?.input_index_map?.[0],Re=A?.input_index_map?.[1],Ee="left"===C?Re:Me,je="left"===C?!Oe:!Fe,Ae=M&&"right"===C&&g(be,E),Ke=$.evaluationResult||Fe?.evaluationResult||Oe?.evaluationResult,We=Ke?.deviations||{},Le=i(()=>M&&"right"===C?m(E,Me,K):new Map,[M,C,E,Me,K]);let Te=$.nodeId||$.id||Fe?.nodeId||Fe?.id||Oe?.nodeId||Oe?.id;M&&"left"!==C&&Fe?.id&&(Te=Fe.nodeId||Fe.id);const ze=Object.keys(We)[0],De=ze?`${Te}${I}${ze}`:null,Ge=De?W?.[De]:null;let He=Se+1;if(M&&se){const e="left"===C?se.leftNums.get(Ie?.id):se.rightNums.get(be?.id);ke&&void 0!==e?He=e:null!=Ge&&Ge>=0?He=Ge:void 0!==e&&(He=e)}else null!=Ge&&Ge>=0&&(He=Ge);const Ve=Ke?.evaluation_outputs?.metadata?.label_color??b,Xe=x(Ve),{highlightBg:Ue}=Xe,qe=Object.entries(We).map(([e,t])=>{const n=`${Te}${I}${e}`;return{deviationKey:e,deviationMap:t,refId:n,currentIndex:K[n]}}).filter(e=>void 0!==e.currentIndex&&null!==e.currentIndex);qe.sort((e,t)=>e.currentIndex-t.currentIndex);const Je=new Map;if(!P&&M&&"right"===C){const e=v(he||"").replace(/\\n/g,"\n");qe.filter(({deviationMap:e})=>{const t=e[F];return(je||y(e[Ee]))&&!!t&&!y(t)}).map(t=>{const n=v(t.deviationMap[F]||"").replace(/\\n/g,"\n"),i=n?e.indexOf(n):-1;return{...t,position:i}}).sort((e,t)=>(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)-(-1===t.position?Number.MAX_SAFE_INTEGER:t.position)||e.currentIndex-t.currentIndex).forEach((e,t)=>{Je.set(e.refId,t+1)})}const Qe=qe.map(e=>{const{deviationKey:t,deviationMap:n,refId:i}=e;let o=e.currentIndex,s=n[F];const d=y(s);if(d)s="";else if(!s)return null;const l=n[Ee],r=je||y(l),a=P?.get(i)??Je.get(i),c=Le.get(i);M&&"right"===C&&r&&void 0!==a?o=a:M&&"right"===C&&!r&&void 0!==c?o=c:M&&void 0!==O&&("right"!==C||r||Ae)&&(o-=O),o=Math.max(1,o);const u=`${M&&"right"===C&&r&&se?S({section:be,proposedSections:E,leftNums:se.leftNums,fallbackNumber:String(He),firstOnly:!0}):He}.${o}`,p=`${Te}${I}${t}${I}${Pe}${I}${Ne}`,h=n?.evaluation_outputs||Ke?.evaluation_outputs,f=h?.output_value??null;let g={...x(h?.metadata?.label_color??Ve)};const m=n?.deviation_summary?{deviation_summary:n.deviation_summary||Ke?.deviation_summary,deviation_title:n?.deviation_title||Ke?.deviation_title,deviation_impact:n?.deviation_impact||Ke?.deviation_impact,deviation_explanation:n?.deviation_explanation||Ke?.deviation_explanation,evaluation_outputs:h,cognitive_decisioning:n?.cognitive_decisioning||Ke?.cognitive_decisioning}:null;let v=0;const b=he||"";if(s&&b){const e=b.split(/\n{2,}/),n=e.findIndex(e=>e.includes(s));if(-1!==n){const i=Object.entries(We).filter(([t,i])=>{const o=i[F];return o&&e[n].includes(o)}).sort((t,i)=>e[n].indexOf(t[1][F])-e[n].indexOf(i[1][F])).filter(([e,t])=>{const n=t[F];return n&&(n.includes(s)||s.includes(n))});i.length>1&&(v=Math.max(0,i.findIndex(([e])=>e===t)))}}const _=q(C,i);return{id:i,actionId:p,label:u,highlight:s,side:C,style:g,stackIndex:v,score:f,isConnected:L.has(p),showScrollLockToggle:L.has(p)||z&&T===p||!!H&&H===_.current,scrollSyncLocked:D,toggleScrollSyncLocked:G,isOrphan:r,isMissingClause:d,badgeRef:_,onClick:e=>{e.stopPropagation();const t=Fe?{...Fe,title:Ie?.title||Fe?.title||""}:{id:"orphan-left",title:"",content:""},n=Oe?{...Oe,title:be?.title||Oe?.title||""}:{id:"orphan-right",title:"",content:""};J(e,t,r,n,p,g)},onSummaryClick:e=>{e.stopPropagation(),Q(e,p,r,m)}}}).filter(Boolean).sort((e,t)=>parseFloat(e.label)-parseFloat(t.label)),Ye=i(()=>{const e=new Set;return Qe.filter(t=>!e.has(t.id)&&(e.add(t.id),!0))},[Qe]),Ze=R||!ce&&re?Ye:[],et=Ye.map(e=>e.highlight).filter(Boolean),tt=Qe.find(e=>L.has(e.actionId)),nt=!!tt;if(!(le||ge||$.subsections&&0!==$.subsections.length))return null;const it=tt?.style?.badgeBorder||Be?.badgeBorder,ot=nt&&it?{borderRadius:"4px",outline:`2px solid ${it}`,outlineOffset:"1px"}:{};return e(o,le?{ref:ye,sx:{mt:1,width:"100%",minWidth:0,position:"relative"},children:e(o,{sx:{width:"100%",...ot},children:t(s,{disableGutters:!0,expanded:!me&&ve,onChange:()=>{if(!me){if(ve){const e=String(T||"");let t=e.includes(Pe)||e.includes(Ne);t||L.forEach(e=>{(String(e).includes(Pe)||String(e).includes(Ne))&&(t=!0)}),t&&(Y(),Z(new Set),ee([]),te.current=[])}B(e=>({...e,[k]:!e[k]}))}},sx:{mt:0,boxShadow:"none",border:me?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}},children:[e(d,{expandIcon:me?null:e(a,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}},children:e(l,{component:"div",sx:{fontSize:"11px",fontWeight:600,color:me?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0},children:xe||"Untitled Subsection"})}),!me&&t(r,{sx:{pt:0,pb:1,minWidth:0},children:[ge&&e(c,{content:he,overlayContent:fe,sxStyles:V,deviationBadges:Ze,maintainRelativeOrder:M,highlightBg:Ue,suppressHighlightBg:ue,highlights:et,collisionKey:de}),($.subsections||[]).map((t,n)=>e(_,{section:t,keyPath:`${k}-${n}`,depth:w+1,columnKey:C,parentNodeId:F,sectionOffset:O,rhsOrphanVisualIndexes:P},`${k}-${n}`))]})]})})}:{ref:ye,sx:{mt:0===w?1:.75,width:"100%",minWidth:0,position:"relative"},children:!me&&t(o,{sx:{width:"100%",...ot},children:[ge&&e(c,{content:he,overlayContent:fe,sxStyles:V,deviationBadges:Ze,maintainRelativeOrder:M,highlightBg:Ue,suppressHighlightBg:ue,highlights:et,collisionKey:de}),($.subsections||[]).map((t,n)=>e(_,{section:t,keyPath:`${k}-${n}`,depth:w+1,columnKey:C,parentNodeId:F,sectionOffset:O,rhsOrphanVisualIndexes:P},`${k}-${n}`))]})})});export{_ as default};
|
|
2
2
|
//# sourceMappingURL=SubSectionAccordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubSectionAccordion.js","sources":["../../../../src/features/CognitiveCompare/components/SubSectionAccordion.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useRef } from \"react\";\nimport {\n Box,\n Typography,\n Accordion,\n AccordionSummary,\n AccordionDetails,\n Tooltip,\n} from \"@mui/material\";\nimport { ChevronDown, EllipsisVertical } from \"lucide-react\";\n\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport {\n hasValue,\n safeStringify,\n generateColorPalette,\n isMissingStr,\n DEVIATION_BADGE_SEPARATOR,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n findTextMatchRange,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\nimport { normalizeRedlineMarkdown } from \"../utils/normalizeRedlineMarkdown\";\nimport { findTextRangeWithFormatting } from \"../utils/normalizeInlineMarkdown\";\n\ninterface SubSectionAccordionProps {\n section: SectionBlock;\n keyPath: string;\n depth?: number;\n columnKey?: \"left\" | \"right\";\n parentNodeId?: string;\n sectionOffset?: number;\n rhsOrphanVisualIndexes?: ReadonlyMap<string, number>;\n}\n\nconst SubSectionAccordion: React.FC<SubSectionAccordionProps> = React.memo((props) => {\n const {\n section,\n keyPath,\n depth = 0,\n columnKey = \"left\",\n parentNodeId = \"\",\n sectionOffset,\n rhsOrphanVisualIndexes,\n } = props;\n const {\n expandedSubSections,\n setExpandedSubSections,\n maintainRelativeOrder,\n showDeviationBadges = false,\n proposedSections,\n existingSections,\n treeData,\n deviationNumberRegistry,\n deviationParentRegistry,\n connectedSections,\n activeSideBySideSection,\n isSideBySide,\n scrollSyncLocked,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n resolvedMarkdownStyles,\n getSubSectionRef,\n getSubSectionCompareStyle,\n getBadgeRef,\n openMoreFunctionsPopup,\n openSummaryPopup,\n resetSideBySide,\n setConnectedSections,\n setConnectedLines,\n cachedConnectedPositions,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n unifiedNumbering,\n } = useCompareContext();\n\n const collisionKey = activeSideBySideSection ?? \"\";\n\n const hasTitle = (section.displayTitle ?? true) && hasValue(section.title);\n const isProposedFixTarget =\n !!isProposingFix &&\n !!proposingFixNodeId &&\n columnKey === \"left\" &&\n (section.id === proposingFixNodeId ||\n section.nodeId === proposingFixNodeId ||\n section.contentId === proposingFixNodeId);\n \n const hasRedlineTags = hasMeaningfulRedlineTags(section.content);\n const inferredRedlineFlow = hasRedlineTags;\n const resolvedRedlineFlow =\n typeof isRedlineFlow === \"boolean\" ? isRedlineFlow : inferredRedlineFlow;\n const suppressHighlightBg = hasRedlineTags;\n const changeHistoryContent = section.change_history;\n\n // Use all visible redline text as the base so changed-only highlights can match.\n const shouldOverlayContent = resolvedRedlineFlow && hasRedlineTags;\n const normalizedRedlineContent = useMemo(\n () => shouldOverlayContent\n ? normalizeRedlineMarkdown(safeStringify(section.content))\n : safeStringify(section.content),\n [section.content, shouldOverlayContent],\n );\n const baseContent = shouldOverlayContent\n ? stripRedlineTags(normalizedRedlineContent)\n : section.content;\n const overlayContent = shouldOverlayContent ? normalizedRedlineContent : undefined;\n const fallbackContent =\n hasRedlineTags && hasValue(changeHistoryContent)\n ? safeStringify(changeHistoryContent)\n : undefined;\n const hasContent = ((section.displayContent ?? true) || hasRedlineTags) && hasValue(section.content);\n const isEmpty = !hasTitle && !hasContent;\n\n const displayTitle = hasTitle ? section.title : hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n const isExpanded = !!expandedSubSections[keyPath];\n const colRef = getSubSectionRef(columnKey, keyPath);\n \n const pathParts = keyPath.split('-').map(Number);\n const rootIndex = pathParts[0];\n\n let baseRoot: any = proposedSections[rootIndex];\n let refRoot: any = existingSections[rootIndex];\n let leftRootIndex = rootIndex;\n let rightRootIndex = rootIndex;\n let isRootOrphan = false;\n\n const findSectionPathById = (\n root: any,\n targetId: string | undefined,\n rootPath: string,\n ): { section: any; keyPath: string } | null => {\n if (!root || !targetId) return null;\n if (root.id === targetId || root.nodeId === targetId || root.contentId === targetId) return { section: root, keyPath: rootPath };\n\n const stack = (root.subsections || []).map((child: any, idx: number) => ({\n section: child,\n keyPath: `${rootPath}-${idx}`,\n }));\n\n while (stack.length > 0) {\n const current = stack.shift();\n if (!current?.section) continue;\n if (\n current.section.id === targetId ||\n current.section.nodeId === targetId ||\n current.section.contentId === targetId\n ) return current;\n\n (current.section.subsections || []).forEach((child: any, idx: number) => {\n stack.push({\n section: child,\n keyPath: `${current.keyPath}-${idx}`,\n });\n });\n }\n\n return null;\n };\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = baseRoot?.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n refRoot = existingSections[rhsArrayIdx];\n rightRootIndex = rhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n } else {\n const lhsSelfIndex = refRoot?.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n baseRoot = proposedSections[lhsArrayIdx];\n leftRootIndex = lhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n }\n }\n\n // --- UNIFIED COUNTERPART LOOKUP ENGINE ---\n const findGlobalPathById = (sections: any[], targetId: string | undefined) => {\n if (!targetId || !sections) return null;\n for (let i = 0; i < sections.length; i++) {\n const match = findSectionPathById(sections[i], targetId, String(i));\n if (match) return match;\n }\n return null;\n };\n\n let bSec: any = null;\n let rSec: any = null;\n let leftKeyPath = \"\";\n let rightKeyPath = \"\";\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let rightMatch = findSectionPathById(refRoot, section.nodeId || section.id, String(rightRootIndex));\n \n // Fallback globally across the entire RHS tree if cross-wired or mismatched\n if (!rightMatch) {\n rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n }\n\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let leftMatch = findSectionPathById(baseRoot, section.nodeId || section.id, String(leftRootIndex));\n \n // Fallback globally across the entire LHS tree if cross-wired or mismatched\n if (!leftMatch) {\n leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n }\n\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n } else {\n // When maintainRelativeOrder is false, absolute structural paths diverge completely.\n // Index path crawling fails here. Execute absolute global ID tracing to handle re-routed clauses.\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n const rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n const leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n }\n\n const style = (leftKeyPath ? getSubSectionCompareStyle(leftKeyPath) : null) || getSubSectionCompareStyle(keyPath);\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterpartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n\n const isSecOrphan = columnKey === \"left\" ? !rSec : !bSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(refRoot, proposedSections);\n \n const targetEvalResult = section.evaluationResult || bSec?.evaluationResult || rSec?.evaluationResult;\n\n const deviations = targetEvalResult?.deviations || {};\n const lhsDeviationDisplayIndexes = useMemo(\n () =>\n maintainRelativeOrder && columnKey === \"right\"\n ? getLhsDeviationDisplayIndexes(\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n )\n : new Map<string, number>(),\n [\n maintainRelativeOrder,\n columnKey,\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n ],\n );\n let nodeId = section.nodeId || section.id || bSec?.nodeId || bSec?.id || rSec?.nodeId || rSec?.id;\n\n // For Subsections, use the exact LHS counterpart subsection (bSec) ID for registry lookup\n if (maintainRelativeOrder && columnKey !== \"left\") {\n if (bSec?.id) {\n nodeId = bSec.nodeId || bSec.id;\n }\n }\n\n // Derive validatedParentNum from registry\n const firstDeviationKey = Object.keys(deviations)[0];\n const firstRefId = firstDeviationKey ? `${nodeId}${DEVIATION_BADGE_SEPARATOR}${firstDeviationKey}` : null;\n const registeredParentNum = firstRefId ? (deviationParentRegistry?.[firstRefId] as number) : null;\n\n let validatedParentNum: string | number = rootIndex + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(baseRoot?.id) \n : unifiedNumbering.rightNums.get(refRoot?.id);\n\n if (isRootOrphan && unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n } else if (unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n }\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n }\n\n const deviationColorData = targetEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n\n \n const highlights: string[] = [];\n \n let nextFallbackDeviationIndex = Math.max(\n 0,\n ...Object.keys(deviations).map(\n (deviationKey) =>\n deviationNumberRegistry[\n `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`\n ],\n ).filter(\n (value): value is number => typeof value === \"number\" && Number.isFinite(value),\n ),\n ) + 1;\n const rawDeviationEntries = Object.entries(deviations).map(([deviationKey, deviationMap]: [string, any]) => {\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n // Missing numbering metadata must not suppress an otherwise renderable\n // inline deviation badge.\n const currentIndex = deviationNumberRegistry[refId] ?? nextFallbackDeviationIndex++;\n return { deviationKey, deviationMap, refId, currentIndex };\n });\n\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const localRhsOrphanVisualIndexes = new Map<string, number>();\n if (\n !rhsOrphanVisualIndexes &&\n maintainRelativeOrder &&\n columnKey === \"right\"\n ) {\n const normalizedContent = safeStringify(baseContent || \"\").replace(/\\\\n/g, \"\\n\");\n rawDeviationEntries\n .filter(({ deviationMap }) => {\n const ownHighlight = deviationMap[parentNodeId];\n const isOrphan =\n isSecOrphan || isMissingStr(deviationMap[counterpartNodeId as string]);\n return isOrphan && !!ownHighlight && !isMissingStr(ownHighlight);\n })\n .map((entry) => {\n const normalizedHighlight = safeStringify(\n entry.deviationMap[parentNodeId] || \"\",\n ).replace(/\\\\n/g, \"\\n\");\n let position = -1;\n if (normalizedHighlight) {\n position = findTextMatchRange(normalizedContent, normalizedHighlight)?.start ?? -1;\n if (position === -1) {\n position = findTextRangeWithFormatting(normalizedContent, normalizedHighlight)?.start ?? -1;\n }\n }\n return { ...entry, position };\n })\n .sort((a, b) => {\n const aPosition = a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition = b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.currentIndex - b.currentIndex;\n })\n .forEach((entry, index) => {\n localRhsOrphanVisualIndexes.set(entry.refId, index + 1);\n });\n }\n\n const deviationEntries = rawDeviationEntries\n .map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n // if (maintainRelativeOrder && sectionOffset !== undefined) {\n // currentIndex = currentIndex - sectionOffset;\n // }\n // currentIndex = Math.max(1, currentIndex);\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) highlight = \"\";\n else if (!highlight) return null;\n\n highlights.push(highlight);\n\n const counterpartHighlight = deviationMap[counterpartNodeId as string];\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex =\n rhsOrphanVisualIndexes?.get(refId) ??\n localRhsOrphanVisualIndexes.get(refId);\n const mappedLhsIndex = lhsDeviationDisplayIndexes.get(refId);\n if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n orphanVisualIndex !== undefined\n ) {\n currentIndex = orphanVisualIndex;\n } else if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n !isDeviationOrphan &&\n mappedLhsIndex !== undefined\n ) {\n currentIndex = mappedLhsIndex;\n } else if (\n maintainRelativeOrder &&\n sectionOffset !== undefined &&\n (columnKey !== \"right\" || isDeviationOrphan || hasSingleMappedLhs)\n ) {\n currentIndex = currentIndex - sectionOffset;\n }\n currentIndex = Math.max(1, currentIndex);\n\n const badgeParentNum =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n unifiedNumbering\n ? getRhsMappedSectionNumber({\n section: refRoot,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftKeyPath}${DEVIATION_BADGE_SEPARATOR}${rightKeyPath}`;\n const deviationOutput = deviationMap?.evaluation_outputs || targetEvalResult?.evaluation_outputs;\n const deviationScore = deviationOutput?.output_value ?? null;\n const deviationColorForBadge = deviationOutput?.metadata?.label_color ?? deviationColorData;\n const deviationPaletteForBadge = generateColorPalette(deviationColorForBadge);\n let badgeStyle = { ...deviationPaletteForBadge } as StyleVariant;\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary || targetEvalResult?.deviation_summary,\n deviation_title: deviationMap?.deviation_title || targetEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || targetEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || targetEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || targetEvalResult?.cognitive_decisioning,\n }\n : null;\n\n let stackIndex = 0;\n const contentStr = baseContent || \"\";\n if (highlight && contentStr) {\n const paragraphs = contentStr.split(/\\n{2,}/);\n const paraIndex = paragraphs.findIndex(p => p.includes(highlight));\n if (paraIndex !== -1) {\n const devsInPara = Object.entries(deviations)\n .filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && paragraphs[paraIndex].includes(hl);\n })\n .sort((a: any, b: any) => paragraphs[paraIndex].indexOf(a[1][parentNodeId]) - paragraphs[paraIndex].indexOf(b[1][parentNodeId]));\n const overlappingDevs = devsInPara.filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && (hl.includes(highlight) || highlight.includes(hl));\n });\n if (overlappingDevs.length > 1) {\n stackIndex = Math.max(0, overlappingDevs.findIndex(([k]) => k === deviationKey));\n }\n }\n }\n\n const badgeRef = getBadgeRef(columnKey, refId);\n\n return {\n id: refId,\n actionId: actionId,\n label: badgeLabel,\n highlight,\n side: columnKey,\n style: badgeStyle,\n stackIndex,\n score: deviationScore,\n isConnected: connectedSections.has(actionId as any),\n showScrollLockToggle:\n connectedSections.has(actionId as any) ||\n (isSideBySide && activeSideBySideSection === actionId) ||\n (!!summaryPopupAnchorEl && summaryPopupAnchorEl === badgeRef.current),\n scrollSyncLocked,\n toggleScrollSyncLocked,\n isOrphan: isDeviationOrphan,\n isMissingClause,\n badgeRef,\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n const matchedBaseRoot = leftKeyPath\n ? proposedSections[Number(leftKeyPath.split(\"-\")[0])] || baseRoot\n : baseRoot;\n const matchedRefRoot = rightKeyPath\n ? existingSections[Number(rightKeyPath.split(\"-\")[0])] || refRoot\n : refRoot;\n const popupBaseSec = bSec ? { ...bSec, title: matchedBaseRoot?.title || bSec?.title || \"\" } : { id: \"orphan-left\", title: \"\", content: \"\" };\n const popupRefSec = rSec ? { ...rSec, title: matchedRefRoot?.title || rSec?.title || \"\" } : { id: \"orphan-right\", title: \"\", content: \"\" };\n \n openMoreFunctionsPopup(e, popupBaseSec, isDeviationOrphan, popupRefSec, actionId, badgeStyle); \n },\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n }\n };\n })\n .filter(Boolean)\n .sort((a: any, b: any) => {\n const numA = parseFloat(a.label);\n const numB = parseFloat(b.label);\n return numA - numB;\n });\n\n const deduplicatedEntries = useMemo(() => {\n const seenRefIds = new Set<string>();\n return deviationEntries.filter((entry: any) => {\n if (seenRefIds.has(entry.id)) return false;\n seenRefIds.add(entry.id);\n return true;\n });\n }, [deviationEntries]);\n\n\n const baseShouldRenderBadges = showDeviationBadges || isProposedFixTarget;\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deduplicatedEntries : [];\nconst highlightsToRender = deduplicatedEntries.map((b: any) => b.highlight).filter(Boolean);\n\n // const hasScrolledRef = useRef(false);\n\n // useEffect(() => {\n // if (!isExpanded) {\n // hasScrolledRef.current = false;\n // }\n // }, [isExpanded]);\n\n // useEffect(() => {\n // if (!isExpanded || hasScrolledRef.current) return;\n\n // const timer = setTimeout(() => {\n // hasScrolledRef.current = true;\n \n // const firstBadgeRef = deviationEntries[0]?.badgeRef?.current;\n \n // if (firstBadgeRef) {\n // firstBadgeRef.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }\n // }, 350); \n\n // return () => clearTimeout(timer);\n // }, [isExpanded, deviationEntries]);\n\n const connectedBadge = deviationEntries.find((b: any) => connectedSections.has(b.actionId));\n const isConnected = !!connectedBadge;\n\n if (!hasTitle && !hasContent && (!section.subsections || section.subsections.length === 0)) return null;\n\n const handleToggle = () => {\n if (!isEmpty) {\n if (isExpanded) {\n const activeBadgeIdStr = String(activeSideBySideSection || \"\");\n let needsReset = activeBadgeIdStr.includes(leftKeyPath) || activeBadgeIdStr.includes(rightKeyPath);\n\n if (!needsReset) {\n connectedSections.forEach((id) => {\n if (String(id).includes(leftKeyPath) || String(id).includes(rightKeyPath)) needsReset = true;\n });\n }\n\n if (needsReset) {\n resetSideBySide();\n setConnectedSections(new Set());\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n }\n }\n setExpandedSubSections((prev) => ({ ...prev, [keyPath]: !prev[keyPath] }));\n }\n };\n const outlineColor = connectedBadge?.style?.badgeBorder || style?.badgeBorder;\n const outlineStyles = isConnected && outlineColor\n ? { borderRadius: \"4px\", outline: `2px solid ${outlineColor}`, outlineOffset: \"1px\" }\n : {};\n\n if (!hasTitle) {\n return (\n <Box ref={colRef} sx={{ mt: depth === 0 ? 1 : 0.75, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n {!isEmpty && (\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n fallbackContent={fallbackContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender} \n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </Box>\n )}\n </Box>\n );\n }\n\n return (\n <Box ref={colRef} sx={{ mt: 1, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={handleToggle}\n sx={{\n mt: 0,\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #EEF2F7\",\n borderRadius: \"4px !important\",\n bgcolor: \"#FFFFFF\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n }}\n >\n <AccordionSummary expandIcon={isEmpty ? null : <ChevronDown size={14} />} sx={{ minHeight: \"32px\", \"& .MuiAccordionSummary-content\": { my: 0.5, display: \"grid\", alignItems: \"center\", minWidth: 0, width: \"100%\" } }}>\n <Typography component=\"div\" sx={{ fontSize: \"11px\", fontWeight: 600, color: isEmpty ? \"#94A3B8\" : \"#19213D\", overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", width: \"100%\", minWidth: 0 }}>\n {displayTitle || \"Untitled Subsection\"}\n </Typography>\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails sx={{ pt: 0, pb: 1, minWidth: 0 }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n fallbackContent={fallbackContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </AccordionDetails>\n )}\n </Accordion>\n </Box>\n </Box>\n );\n});\n\nexport default SubSectionAccordion;\n"],"names":["SubSectionAccordion","React","memo","props","section","keyPath","depth","columnKey","parentNodeId","sectionOffset","rhsOrphanVisualIndexes","expandedSubSections","setExpandedSubSections","maintainRelativeOrder","showDeviationBadges","proposedSections","existingSections","treeData","deviationNumberRegistry","deviationParentRegistry","connectedSections","activeSideBySideSection","isSideBySide","scrollSyncLocked","toggleScrollSyncLocked","summaryPopupAnchorEl","resolvedMarkdownStyles","getSubSectionRef","getSubSectionCompareStyle","getBadgeRef","openMoreFunctionsPopup","openSummaryPopup","resetSideBySide","setConnectedSections","setConnectedLines","cachedConnectedPositions","isProposingFix","proposingFixNodeId","isRedlineFlow","unifiedNumbering","useCompareContext","collisionKey","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","contentId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","changeHistoryContent","change_history","shouldOverlayContent","normalizedRedlineContent","useMemo","normalizeRedlineMarkdown","safeStringify","baseContent","stripRedlineTags","overlayContent","fallbackContent","hasContent","displayContent","isEmpty","isExpanded","colRef","rootIndex","split","map","Number","baseRoot","refRoot","leftRootIndex","rightRootIndex","isRootOrphan","findSectionPathById","root","targetId","rootPath","stack","subsections","child","idx","length","current","shift","forEach","push","rhsSelfIndex","refIndexes","rhsArrayIdx","findIndex","s","selfIndex","lhsSelfIndex","lhsArrayIdx","findGlobalPathById","sections","i","match","String","bSec","rSec","leftKeyPath","rightKeyPath","rightMatch","leftMatch","style","leftDocId","input_index_map","rightDocId","counterpartNodeId","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","targetEvalResult","evaluationResult","deviations","lhsDeviationDisplayIndexes","getLhsDeviationDisplayIndexes","Map","firstDeviationKey","Object","keys","firstRefId","DEVIATION_BADGE_SEPARATOR","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","nextFallbackDeviationIndex","Math","max","deviationKey","filter","value","isFinite","rawDeviationEntries","entries","deviationMap","refId","currentIndex","sort","a","b","localRhsOrphanVisualIndexes","normalizedContent","replace","ownHighlight","isMissingStr","entry","normalizedHighlight","position","findTextMatchRange","start","findTextRangeWithFormatting","MAX_SAFE_INTEGER","index","set","deviationEntries","item","highlight","isMissingClause","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","actionId","deviationOutput","deviationScore","output_value","badgeStyle","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","includes","overlappingDevs","_","dMap","hl","indexOf","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","isOrphan","onClick","e","stopPropagation","matchedBaseRoot","matchedRefRoot","popupBaseSec","popupRefSec","onSummaryClick","Boolean","parseFloat","deduplicatedEntries","seenRefIds","Set","add","deviationBadgesToRender","highlightsToRender","connectedBadge","find","outlineColor","badgeBorder","outlineStyles","borderRadius","outline","outlineOffset","jsx","Box","ref","sx","mt","width","minWidth","children","jsxs","Accordion","disableGutters","expanded","onChange","activeBadgeIdStr","needsReset","prev","boxShadow","border","bgcolor","display","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","alignItems","Typography","component","fontSize","fontWeight","color","overflow","textOverflow","whiteSpace","AccordionDetails","pt","pb","MemoizedMarkdown","sxStyles","deviationBadges","highlights","sub","subIdx"],"mappings":"u5BA0CA,MAAMA,EAA0DC,EAAMC,KAAMC,IACpE,MAAAC,QACJA,EAAAC,QACAA,EAAAC,MACAA,EAAQ,EAAAC,UACRA,EAAY,OAAAC,aACZA,EAAe,GAAAC,cACfA,EAAAC,uBACAA,GACEP,GACEQ,oBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,iBACtBA,EAAAC,iBACAA,EAAAC,SACAA,EAAAC,wBACAA,EAAAC,wBACAA,EAAAC,kBACAA,EAAAC,wBACAA,EAAAC,aACAA,EAAAC,iBACAA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c,IAAV/O,EAAc,EAAI,IAAMgP,MAAO,OAAQC,SAAU,EAAGhF,SAAU,YACvFiF,UAACpL,IACCqL,EAAAP,EAAA,CAAIE,GAAI,CAAEE,MAAO,UAAWT,IAC1BW,SAAA,CACCtL,IAAA+K,EAACsC,EAAA,CACCnO,QAASU,GACTE,kBACAC,mBACAuN,SAAU9P,EACV+P,gBAAiBlD,GACjB1N,wBACAmI,eACA1F,uBACAoO,WAAYlD,GACZ/L,mBAGFrC,EAAQiF,aAAe,IAAIZ,IAAI,CAACkN,EAAKC,IACnC3C,EAACjP,EAAA,CAECI,QAASuR,EACTtR,QAAS,GAAGA,KAAWuR,IACvBtR,MAAOA,EAAQ,EACfC,YACAC,eACAC,gBACAC,0BAPK,GAAGL,KAAWuR"}
|
|
1
|
+
{"version":3,"file":"SubSectionAccordion.js","sources":["../../../../src/features/CognitiveCompare/components/SubSectionAccordion.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useRef } from \"react\";\nimport {\n Box,\n Typography,\n Accordion,\n AccordionSummary,\n AccordionDetails,\n Tooltip,\n} from \"@mui/material\";\nimport { ChevronDown, EllipsisVertical } from \"lucide-react\";\n\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport {\n hasValue,\n safeStringify,\n generateColorPalette,\n isMissingStr,\n DEVIATION_BADGE_SEPARATOR,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\n\ninterface SubSectionAccordionProps {\n section: SectionBlock;\n keyPath: string;\n depth?: number;\n columnKey?: \"left\" | \"right\";\n parentNodeId?: string;\n sectionOffset?: number;\n rhsOrphanVisualIndexes?: ReadonlyMap<string, number>;\n}\n\nconst SubSectionAccordion: React.FC<SubSectionAccordionProps> = React.memo((props) => {\n const {\n section,\n keyPath,\n depth = 0,\n columnKey = \"left\",\n parentNodeId = \"\",\n sectionOffset,\n rhsOrphanVisualIndexes,\n } = props;\n const {\n expandedSubSections,\n setExpandedSubSections,\n maintainRelativeOrder,\n showDeviationBadges = false,\n proposedSections,\n existingSections,\n treeData,\n deviationNumberRegistry,\n deviationParentRegistry,\n connectedSections,\n activeSideBySideSection,\n isSideBySide,\n scrollSyncLocked,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n resolvedMarkdownStyles,\n getSubSectionRef,\n getSubSectionCompareStyle,\n getBadgeRef,\n openMoreFunctionsPopup,\n openSummaryPopup,\n resetSideBySide,\n setConnectedSections,\n setConnectedLines,\n cachedConnectedPositions,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n unifiedNumbering,\n } = useCompareContext();\n\n const collisionKey = activeSideBySideSection ?? \"\";\n\n const hasTitle = (section.displayTitle ?? true) && hasValue(section.title);\n const isProposedFixTarget =\n !!isProposingFix &&\n !!proposingFixNodeId &&\n columnKey === \"left\" &&\n (section.id === proposingFixNodeId || section.nodeId === proposingFixNodeId);\n \n const hasRedlineTags = hasMeaningfulRedlineTags(section.content);\n const inferredRedlineFlow = hasRedlineTags;\n const resolvedRedlineFlow =\n typeof isRedlineFlow === \"boolean\" ? isRedlineFlow : inferredRedlineFlow;\n const suppressHighlightBg = hasRedlineTags;\n\n // Use history as the base when redlines exist so badge matching still works.\n const shouldOverlayContent = resolvedRedlineFlow && hasRedlineTags;\n const baseContent = shouldOverlayContent\n ? stripRedlineTags(section.content)\n : section.content;\n const overlayContent = shouldOverlayContent ? section.content : undefined;\n const hasContent = ((section.displayContent ?? true) || hasRedlineTags) && hasValue(section.content);\n const isEmpty = !hasTitle && !hasContent;\n\n const displayTitle = hasTitle ? section.title : hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n const isExpanded = !!expandedSubSections[keyPath];\n const colRef = getSubSectionRef(columnKey, keyPath);\n \n const pathParts = keyPath.split('-').map(Number);\n const rootIndex = pathParts[0];\n\n let baseRoot: any = proposedSections[rootIndex];\n let refRoot: any = existingSections[rootIndex];\n let leftRootIndex = rootIndex;\n let rightRootIndex = rootIndex;\n let isRootOrphan = false;\n\n const findSectionPathById = (\n root: any,\n targetId: string | undefined,\n rootPath: string,\n ): { section: any; keyPath: string } | null => {\n if (!root || !targetId) return null;\n if (root.id === targetId || root.nodeId === targetId || root.contentId === targetId) return { section: root, keyPath: rootPath };\n\n const stack = (root.subsections || []).map((child: any, idx: number) => ({\n section: child,\n keyPath: `${rootPath}-${idx}`,\n }));\n\n while (stack.length > 0) {\n const current = stack.shift();\n if (!current?.section) continue;\n if (\n current.section.id === targetId ||\n current.section.nodeId === targetId ||\n current.section.contentId === targetId\n ) return current;\n\n (current.section.subsections || []).forEach((child: any, idx: number) => {\n stack.push({\n section: child,\n keyPath: `${current.keyPath}-${idx}`,\n });\n });\n }\n\n return null;\n };\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = baseRoot?.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n refRoot = existingSections[rhsArrayIdx];\n rightRootIndex = rhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n } else {\n const lhsSelfIndex = refRoot?.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n baseRoot = proposedSections[lhsArrayIdx];\n leftRootIndex = lhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n }\n }\n\n // --- UNIFIED COUNTERPART LOOKUP ENGINE ---\n const findGlobalPathById = (sections: any[], targetId: string | undefined) => {\n if (!targetId || !sections) return null;\n for (let i = 0; i < sections.length; i++) {\n const match = findSectionPathById(sections[i], targetId, String(i));\n if (match) return match;\n }\n return null;\n };\n\n let bSec: any = null;\n let rSec: any = null;\n let leftKeyPath = \"\";\n let rightKeyPath = \"\";\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let rightMatch = findSectionPathById(refRoot, section.nodeId || section.id, String(rightRootIndex));\n \n // Fallback globally across the entire RHS tree if cross-wired or mismatched\n if (!rightMatch) {\n rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n }\n\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let leftMatch = findSectionPathById(baseRoot, section.nodeId || section.id, String(leftRootIndex));\n \n // Fallback globally across the entire LHS tree if cross-wired or mismatched\n if (!leftMatch) {\n leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n }\n\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n } else {\n // When maintainRelativeOrder is false, absolute structural paths diverge completely.\n // Index path crawling fails here. Execute absolute global ID tracing to handle re-routed clauses.\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n const rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n const leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n }\n\n const style = (leftKeyPath ? getSubSectionCompareStyle(leftKeyPath) : null) || getSubSectionCompareStyle(keyPath);\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterpartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n\n const isSecOrphan = columnKey === \"left\" ? !rSec : !bSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(refRoot, proposedSections);\n \n const targetEvalResult = section.evaluationResult || bSec?.evaluationResult || rSec?.evaluationResult;\n\n const deviations = targetEvalResult?.deviations || {};\n const lhsDeviationDisplayIndexes = useMemo(\n () =>\n maintainRelativeOrder && columnKey === \"right\"\n ? getLhsDeviationDisplayIndexes(\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n )\n : new Map<string, number>(),\n [\n maintainRelativeOrder,\n columnKey,\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n ],\n );\n let nodeId = section.nodeId || section.id || bSec?.nodeId || bSec?.id || rSec?.nodeId || rSec?.id;\n\n // For Subsections, use the exact LHS counterpart subsection (bSec) ID for registry lookup\n if (maintainRelativeOrder && columnKey !== \"left\") {\n if (bSec?.id) {\n nodeId = bSec.nodeId || bSec.id;\n }\n }\n\n // Derive validatedParentNum from registry\n const firstDeviationKey = Object.keys(deviations)[0];\n const firstRefId = firstDeviationKey ? `${nodeId}${DEVIATION_BADGE_SEPARATOR}${firstDeviationKey}` : null;\n const registeredParentNum = firstRefId ? (deviationParentRegistry?.[firstRefId] as number) : null;\n\n let validatedParentNum: string | number = rootIndex + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(baseRoot?.id) \n : unifiedNumbering.rightNums.get(refRoot?.id);\n\n if (isRootOrphan && unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n } else if (unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n }\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n }\n\n const deviationColorData = targetEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n\n \n const highlights: string[] = [];\n \n const rawDeviationEntries = Object.entries(deviations).map(([deviationKey, deviationMap]: [string, any]) => {\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const currentIndex = deviationNumberRegistry[refId];\n return { deviationKey, deviationMap, refId, currentIndex };\n }).filter(item => item.currentIndex !== undefined && item.currentIndex !== null);\n\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const localRhsOrphanVisualIndexes = new Map<string, number>();\n if (\n !rhsOrphanVisualIndexes &&\n maintainRelativeOrder &&\n columnKey === \"right\"\n ) {\n const normalizedContent = safeStringify(baseContent || \"\").replace(/\\\\n/g, \"\\n\");\n rawDeviationEntries\n .filter(({ deviationMap }) => {\n const ownHighlight = deviationMap[parentNodeId];\n const isOrphan =\n isSecOrphan || isMissingStr(deviationMap[counterpartNodeId as string]);\n return isOrphan && !!ownHighlight && !isMissingStr(ownHighlight);\n })\n .map((entry) => {\n const normalizedHighlight = safeStringify(\n entry.deviationMap[parentNodeId] || \"\",\n ).replace(/\\\\n/g, \"\\n\");\n const position = normalizedHighlight\n ? normalizedContent.indexOf(normalizedHighlight)\n : -1;\n return { ...entry, position };\n })\n .sort((a, b) => {\n const aPosition = a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition = b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.currentIndex - b.currentIndex;\n })\n .forEach((entry, index) => {\n localRhsOrphanVisualIndexes.set(entry.refId, index + 1);\n });\n }\n\n const deviationEntries = rawDeviationEntries\n .map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n // if (maintainRelativeOrder && sectionOffset !== undefined) {\n // currentIndex = currentIndex - sectionOffset;\n // }\n // currentIndex = Math.max(1, currentIndex);\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) highlight = \"\";\n else if (!highlight) return null;\n\n highlights.push(highlight);\n\n const counterpartHighlight = deviationMap[counterpartNodeId as string];\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex =\n rhsOrphanVisualIndexes?.get(refId) ??\n localRhsOrphanVisualIndexes.get(refId);\n const mappedLhsIndex = lhsDeviationDisplayIndexes.get(refId);\n if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n orphanVisualIndex !== undefined\n ) {\n currentIndex = orphanVisualIndex;\n } else if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n !isDeviationOrphan &&\n mappedLhsIndex !== undefined\n ) {\n currentIndex = mappedLhsIndex;\n } else if (\n maintainRelativeOrder &&\n sectionOffset !== undefined &&\n (columnKey !== \"right\" || isDeviationOrphan || hasSingleMappedLhs)\n ) {\n currentIndex = currentIndex - sectionOffset;\n }\n currentIndex = Math.max(1, currentIndex);\n\n const badgeParentNum =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n unifiedNumbering\n ? getRhsMappedSectionNumber({\n section: refRoot,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftKeyPath}${DEVIATION_BADGE_SEPARATOR}${rightKeyPath}`;\n const deviationOutput = deviationMap?.evaluation_outputs || targetEvalResult?.evaluation_outputs;\n const deviationScore = deviationOutput?.output_value ?? null;\n const deviationColorForBadge = deviationOutput?.metadata?.label_color ?? deviationColorData;\n const deviationPaletteForBadge = generateColorPalette(deviationColorForBadge);\n let badgeStyle = { ...deviationPaletteForBadge } as StyleVariant;\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary || targetEvalResult?.deviation_summary,\n deviation_title: deviationMap?.deviation_title || targetEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || targetEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || targetEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || targetEvalResult?.cognitive_decisioning,\n }\n : null;\n\n let stackIndex = 0;\n const contentStr = baseContent || \"\";\n if (highlight && contentStr) {\n const paragraphs = contentStr.split(/\\n{2,}/);\n const paraIndex = paragraphs.findIndex(p => p.includes(highlight));\n if (paraIndex !== -1) {\n const devsInPara = Object.entries(deviations)\n .filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && paragraphs[paraIndex].includes(hl);\n })\n .sort((a: any, b: any) => paragraphs[paraIndex].indexOf(a[1][parentNodeId]) - paragraphs[paraIndex].indexOf(b[1][parentNodeId]));\n const overlappingDevs = devsInPara.filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && (hl.includes(highlight) || highlight.includes(hl));\n });\n if (overlappingDevs.length > 1) {\n stackIndex = Math.max(0, overlappingDevs.findIndex(([k]) => k === deviationKey));\n }\n }\n }\n\n const badgeRef = getBadgeRef(columnKey, refId);\n\n return {\n id: refId,\n actionId: actionId,\n label: badgeLabel,\n highlight,\n side: columnKey,\n style: badgeStyle,\n stackIndex,\n score: deviationScore,\n isConnected: connectedSections.has(actionId as any),\n showScrollLockToggle:\n connectedSections.has(actionId as any) ||\n (isSideBySide && activeSideBySideSection === actionId) ||\n (!!summaryPopupAnchorEl && summaryPopupAnchorEl === badgeRef.current),\n scrollSyncLocked,\n toggleScrollSyncLocked,\n isOrphan: isDeviationOrphan,\n isMissingClause,\n badgeRef,\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n const popupBaseSec = bSec ? { ...bSec, title: baseRoot?.title || bSec?.title || \"\" } : { id: \"orphan-left\", title: \"\", content: \"\" };\n const popupRefSec = rSec ? { ...rSec, title: refRoot?.title || rSec?.title || \"\" } : { id: \"orphan-right\", title: \"\", content: \"\" };\n \n openMoreFunctionsPopup(e, popupBaseSec, isDeviationOrphan, popupRefSec, actionId, badgeStyle); \n },\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n }\n };\n })\n .filter(Boolean)\n .sort((a: any, b: any) => {\n const numA = parseFloat(a.label);\n const numB = parseFloat(b.label);\n return numA - numB;\n });\n\n const deduplicatedEntries = useMemo(() => {\n const seenRefIds = new Set<string>();\n return deviationEntries.filter((entry: any) => {\n if (seenRefIds.has(entry.id)) return false;\n seenRefIds.add(entry.id);\n return true;\n });\n }, [deviationEntries]);\n\n\n const baseShouldRenderBadges =\n showDeviationBadges || (!resolvedRedlineFlow && isProposedFixTarget);\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deduplicatedEntries : [];\nconst highlightsToRender = deduplicatedEntries.map((b: any) => b.highlight).filter(Boolean);\n\n // const hasScrolledRef = useRef(false);\n\n // useEffect(() => {\n // if (!isExpanded) {\n // hasScrolledRef.current = false;\n // }\n // }, [isExpanded]);\n\n // useEffect(() => {\n // if (!isExpanded || hasScrolledRef.current) return;\n\n // const timer = setTimeout(() => {\n // hasScrolledRef.current = true;\n \n // const firstBadgeRef = deviationEntries[0]?.badgeRef?.current;\n \n // if (firstBadgeRef) {\n // firstBadgeRef.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }\n // }, 350); \n\n // return () => clearTimeout(timer);\n // }, [isExpanded, deviationEntries]);\n\n const connectedBadge = deviationEntries.find((b: any) => connectedSections.has(b.actionId));\n const isConnected = !!connectedBadge;\n\n if (!hasTitle && !hasContent && (!section.subsections || section.subsections.length === 0)) return null;\n\n const handleToggle = () => {\n if (!isEmpty) {\n if (isExpanded) {\n const activeBadgeIdStr = String(activeSideBySideSection || \"\");\n let needsReset = activeBadgeIdStr.includes(leftKeyPath) || activeBadgeIdStr.includes(rightKeyPath);\n\n if (!needsReset) {\n connectedSections.forEach((id) => {\n if (String(id).includes(leftKeyPath) || String(id).includes(rightKeyPath)) needsReset = true;\n });\n }\n\n if (needsReset) {\n resetSideBySide();\n setConnectedSections(new Set());\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n }\n }\n setExpandedSubSections((prev) => ({ ...prev, [keyPath]: !prev[keyPath] }));\n }\n };\n const outlineColor = connectedBadge?.style?.badgeBorder || style?.badgeBorder;\n const outlineStyles = isConnected && outlineColor\n ? { borderRadius: \"4px\", outline: `2px solid ${outlineColor}`, outlineOffset: \"1px\" }\n : {};\n\n if (!hasTitle) {\n return (\n <Box ref={colRef} sx={{ mt: depth === 0 ? 1 : 0.75, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n {!isEmpty && (\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender} \n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </Box>\n )}\n </Box>\n );\n }\n\n return (\n <Box ref={colRef} sx={{ mt: 1, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={handleToggle}\n sx={{\n mt: 0,\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #EEF2F7\",\n borderRadius: \"4px !important\",\n bgcolor: \"#FFFFFF\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n }}\n >\n <AccordionSummary expandIcon={isEmpty ? null : <ChevronDown size={14} />} sx={{ minHeight: \"32px\", \"& .MuiAccordionSummary-content\": { my: 0.5, display: \"grid\", alignItems: \"center\", minWidth: 0, width: \"100%\" } }}>\n <Typography component=\"div\" sx={{ fontSize: \"11px\", fontWeight: 600, color: isEmpty ? \"#94A3B8\" : \"#19213D\", overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", width: \"100%\", minWidth: 0 }}>\n {displayTitle || \"Untitled Subsection\"}\n </Typography>\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails sx={{ pt: 0, pb: 1, minWidth: 0 }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </AccordionDetails>\n )}\n </Accordion>\n </Box>\n </Box>\n );\n});\n\nexport default SubSectionAccordion;\n"],"names":["SubSectionAccordion","React","memo","props","section","keyPath","depth","columnKey","parentNodeId","sectionOffset","rhsOrphanVisualIndexes","expandedSubSections","setExpandedSubSections","maintainRelativeOrder","showDeviationBadges","proposedSections","existingSections","treeData","deviationNumberRegistry","deviationParentRegistry","connectedSections","activeSideBySideSection","isSideBySide","scrollSyncLocked","toggleScrollSyncLocked","summaryPopupAnchorEl","resolvedMarkdownStyles","getSubSectionRef","getSubSectionCompareStyle","getBadgeRef","openMoreFunctionsPopup","openSummaryPopup","resetSideBySide","setConnectedSections","setConnectedLines","cachedConnectedPositions","isProposingFix","proposingFixNodeId","isRedlineFlow","unifiedNumbering","useCompareContext","collisionKey","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","shouldOverlayContent","baseContent","stripRedlineTags","overlayContent","hasContent","displayContent","isEmpty","isExpanded","colRef","rootIndex","split","map","Number","baseRoot","refRoot","leftRootIndex","rightRootIndex","isRootOrphan","findSectionPathById","root","targetId","rootPath","contentId","stack","subsections","child","idx","length","current","shift","forEach","push","rhsSelfIndex","refIndexes","rhsArrayIdx","findIndex","s","selfIndex","lhsSelfIndex","lhsArrayIdx","findGlobalPathById","sections","i","match","String","bSec","rSec","leftKeyPath","rightKeyPath","rightMatch","leftMatch","style","leftDocId","input_index_map","rightDocId","counterpartNodeId","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","targetEvalResult","evaluationResult","deviations","lhsDeviationDisplayIndexes","useMemo","getLhsDeviationDisplayIndexes","Map","firstDeviationKey","Object","keys","firstRefId","DEVIATION_BADGE_SEPARATOR","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","rawDeviationEntries","entries","deviationKey","deviationMap","refId","currentIndex","filter","item","sort","a","b","localRhsOrphanVisualIndexes","normalizedContent","safeStringify","replace","ownHighlight","isMissingStr","entry","normalizedHighlight","position","indexOf","MAX_SAFE_INTEGER","index","set","deviationEntries","highlight","isMissingClause","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","Math","max","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","actionId","deviationOutput","deviationScore","output_value","badgeStyle","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","includes","overlappingDevs","_","dMap","hl","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","isOrphan","onClick","e","stopPropagation","popupBaseSec","popupRefSec","onSummaryClick","Boolean","parseFloat","deduplicatedEntries","seenRefIds","Set","add","deviationBadgesToRender","highlightsToRender","connectedBadge","find","outlineColor","badgeBorder","outlineStyles","borderRadius","outline","outlineOffset","jsx","Box","ref","sx","mt","width","minWidth","children","jsxs","Accordion","disableGutters","expanded","onChange","activeBadgeIdStr","needsReset","prev","boxShadow","border","bgcolor","display","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","alignItems","Typography","component","fontSize","fontWeight","color","overflow","textOverflow","whiteSpace","AccordionDetails","pt","pb","MemoizedMarkdown","sxStyles","deviationBadges","highlights","sub","subIdx"],"mappings":"6tBAuCA,MAAMA,EAA0DC,EAAMC,KAAMC,IACpE,MAAAC,QACJA,EAAAC,QACAA,EAAAC,MACAA,EAAQ,EAAAC,UACRA,EAAY,OAAAC,aACZA,EAAe,GAAAC,cACfA,EAAAC,uBACAA,GACEP,GACEQ,oBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,iBACtBA,EAAAC,iBACAA,EAAAC,SACAA,EAAAC,wBACAA,EAAAC,wBACAA,EAAAC,kBACAA,EAAAC,wBACAA,EAAAC,aACAA,EAAAC,iBACAA,EAAAC,uBACAA,EAAAC,qBACAA,EAAAC,uBACAA,EAAAC,iBACAA,EAAAC,0BACAA,EAAAC,YACAA,EAAAC,uBACAA,EAAAC,iBACAA,EAAAC,gBACAA,EAAAC,qBACAA,EAAAC,kBACAA,GAAAC,yBACAA,GAAAC,eACAA,GAAAC,mBACAA,GAAAC,cACAA,GAAAC,iBACAA,IACEC,IAE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