@e-llm-studio/citation 0.0.251 → 0.0.253
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/CitationRendererInner.js +2 -0
- package/dist/cjs/features/CognitiveCompare/CitationRendererInner.js.map +1 -0
- 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/GptWebCitationPanel.js +2 -0
- package/dist/cjs/features/CognitiveCompare/GptWebCitationPanel.js.map +1 -0
- 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/guidelineTargets.js +2 -0
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
- 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/Guidelines/utils/resolveGuidelineSelection.js +2 -0
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
- package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
- 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/useOnDemandCitationCache.js +2 -0
- package/dist/cjs/features/CognitiveCompare/hooks/useOnDemandCitationCache.js.map +1 -0
- 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/CognitiveCompare/onDemandCitations/cacheKey.js +2 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/cacheKey.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/contextBuilder.js +2 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/contextBuilder.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/href.js +2 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/href.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/payload.js +2 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/payload.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/response.js +2 -0
- package/dist/cjs/features/CognitiveCompare/onDemandCitations/response.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js +2 -0
- package/dist/cjs/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
- package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js +2 -0
- package/dist/cjs/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js.map +1 -0
- package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfContainer.js.map +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/SegmentReviewComponents/ApprovalDescriptionBanner.js +2 -0
- package/dist/cjs/features/SegmentReviewComponents/ApprovalDescriptionBanner.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js.map +1 -1
- package/dist/cjs/features/SegmentReviewComponents/RevertCard.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/RevertCard.js.map +1 -1
- package/dist/cjs/features/SegmentReviewComponents/SaveAsLearningCard.js +2 -0
- package/dist/cjs/features/SegmentReviewComponents/SaveAsLearningCard.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
- package/dist/cjs/hooks/useOnDemandCitationFetch.js +1 -1
- package/dist/cjs/hooks/useOnDemandCitationFetch.js.map +1 -1
- package/dist/cjs/service/onDemandApi.js +1 -1
- package/dist/cjs/service/onDemandApi.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/CitationRendererInner.js +2 -0
- package/dist/features/CognitiveCompare/CitationRendererInner.js.map +1 -0
- 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/GptWebCitationPanel.js +2 -0
- package/dist/features/CognitiveCompare/GptWebCitationPanel.js.map +1 -0
- 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/guidelineTargets.js +2 -0
- package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
- package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
- package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
- 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/Guidelines/utils/resolveGuidelineSelection.js +2 -0
- package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
- package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
- package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
- 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/useOnDemandCitationCache.js +2 -0
- package/dist/features/CognitiveCompare/hooks/useOnDemandCitationCache.js.map +1 -0
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/features/CognitiveCompare/onDemandCitations/cacheKey.js +2 -0
- package/dist/features/CognitiveCompare/onDemandCitations/cacheKey.js.map +1 -0
- package/dist/features/CognitiveCompare/onDemandCitations/contextBuilder.js +2 -0
- package/dist/features/CognitiveCompare/onDemandCitations/contextBuilder.js.map +1 -0
- package/dist/features/CognitiveCompare/onDemandCitations/href.js +2 -0
- package/dist/features/CognitiveCompare/onDemandCitations/href.js.map +1 -0
- package/dist/features/CognitiveCompare/onDemandCitations/payload.js +2 -0
- package/dist/features/CognitiveCompare/onDemandCitations/payload.js.map +1 -0
- package/dist/features/CognitiveCompare/onDemandCitations/response.js +2 -0
- package/dist/features/CognitiveCompare/onDemandCitations/response.js.map +1 -0
- package/dist/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js +2 -0
- package/dist/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js.map +1 -0
- package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
- package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
- package/dist/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js +2 -0
- package/dist/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js.map +1 -0
- package/dist/features/PdfViewer/PdfContainer.js +1 -1
- package/dist/features/PdfViewer/PdfContainer.js.map +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/features/SegmentReviewComponents/ApprovalDescriptionBanner.js +2 -0
- package/dist/features/SegmentReviewComponents/ApprovalDescriptionBanner.js.map +1 -0
- package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
- package/dist/features/SegmentReviewComponents/BoundaryCard.js.map +1 -1
- package/dist/features/SegmentReviewComponents/RevertCard.js +1 -1
- package/dist/features/SegmentReviewComponents/RevertCard.js.map +1 -1
- package/dist/features/SegmentReviewComponents/SaveAsLearningCard.js +2 -0
- package/dist/features/SegmentReviewComponents/SaveAsLearningCard.js.map +1 -0
- package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
- package/dist/hooks/useOnDemandCitationFetch.js +1 -1
- package/dist/hooks/useOnDemandCitationFetch.js.map +1 -1
- package/dist/service/onDemandApi.js +1 -1
- package/dist/service/onDemandApi.js.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +2 -0
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +8 -1
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationRendererInner.d.ts +13 -0
- package/dist/types/features/CognitiveCompare/CitationRendererInner.d.ts.map +1 -0
- 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 +14 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +12 -0
- 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 +10 -1
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/GptWebCitationPanel.d.ts +7 -0
- package/dist/types/features/CognitiveCompare/GptWebCitationPanel.d.ts.map +1 -0
- 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/guidelineTargets.d.ts +3 -0
- package/dist/types/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts +3 -0
- package/dist/types/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +14 -1
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts +19 -0
- package/dist/types/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts +8 -0
- package/dist/types/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts.map +1 -0
- 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 +2 -1
- 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/useOnDemandCitationCache.d.ts +10 -0
- package/dist/types/features/CognitiveCompare/hooks/useOnDemandCitationCache.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/onDemandCitations/cacheKey.d.ts +3 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/cacheKey.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/contextBuilder.d.ts +16 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/contextBuilder.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/href.d.ts +6 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/href.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/index.d.ts +7 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/index.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/payload.d.ts +4 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/payload.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/response.d.ts +3 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/response.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/types.d.ts +134 -0
- package/dist/types/features/CognitiveCompare/onDemandCitations/types.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/utils/normalizeCompactedGfmTables.d.ts +7 -0
- package/dist/types/features/CognitiveCompare/utils/normalizeCompactedGfmTables.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts +6 -0
- package/dist/types/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts.map +1 -0
- package/dist/types/features/CognitiveCompare/utils/normalizeRedlineMarkdown.d.ts +6 -0
- package/dist/types/features/CognitiveCompare/utils/normalizeRedlineMarkdown.d.ts.map +1 -0
- package/dist/types/features/PdfViewer/PdfContainer.d.ts +3 -2
- package/dist/types/features/PdfViewer/PdfContainer.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfViewer.d.ts +3 -2
- package/dist/types/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/features/SegmentReviewComponents/ApprovalDescriptionBanner.d.ts +11 -0
- package/dist/types/features/SegmentReviewComponents/ApprovalDescriptionBanner.d.ts.map +1 -0
- package/dist/types/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
- package/dist/types/features/SegmentReviewComponents/RevertCard.d.ts +9 -1
- package/dist/types/features/SegmentReviewComponents/RevertCard.d.ts.map +1 -1
- package/dist/types/features/SegmentReviewComponents/SaveAsLearningCard.d.ts +15 -0
- package/dist/types/features/SegmentReviewComponents/SaveAsLearningCard.d.ts.map +1 -0
- package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +14 -1
- package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
- package/dist/types/hooks/useOnDemandCitationFetch.d.ts.map +1 -1
- package/dist/types/service/onDemandApi.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/features/Bookemon/BookemonStyles.js +0 -2
- package/dist/cjs/features/Bookemon/BookemonStyles.js.map +0 -1
- package/dist/cjs/lib/ui/icons.js +0 -2
- package/dist/cjs/lib/ui/icons.js.map +0 -1
- package/dist/cjs/lib/ui/materialCompat.js +0 -2
- package/dist/cjs/lib/ui/materialCompat.js.map +0 -1
- package/dist/features/Bookemon/BookemonStyles.js +0 -2
- package/dist/features/Bookemon/BookemonStyles.js.map +0 -1
- package/dist/lib/ui/icons.js +0 -2
- package/dist/lib/ui/icons.js.map +0 -1
- package/dist/lib/ui/materialCompat.js +0 -2
- package/dist/lib/ui/materialCompat.js.map +0 -1
- package/dist/types/features/Bookemon/BookemonStyles.d.ts +0 -6
- package/dist/types/features/Bookemon/BookemonStyles.d.ts.map +0 -1
- package/dist/types/lib/ui/icons.d.ts +0 -46
- package/dist/types/lib/ui/icons.d.ts.map +0 -1
- package/dist/types/lib/ui/materialCompat.d.ts +0 -117
- package/dist/types/lib/ui/materialCompat.d.ts.map +0 -1
|
@@ -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 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,uB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SAAUC,aAAc,WAAYC,WAAY,SAAU7B,MAAO,OAAQC,SAAU,GACvMC,SAAgBhM,IAAA,2BAGnBiB,IACCgL,EAAA2B,EAAA,CAAiBhC,GAAI,CAAEiC,GAAI,EAAGC,GAAI,EAAG/B,SAAU,GAC7CC,SAAA,CACCjL,IAAA0K,EAACsC,EAAA,CACCvN,QAASI,GACTE,kBACAkN,SAAUjP,EACVkP,gBAAiBlD,GACjB7M,wBACA6H,eACArF,uBACAwN,WAAYlD,GACZlL,mBAGFrC,EAAQ0E,aAAe,IAAIb,IAAI,CAAC6M,EAAKC,IACrC3C,EAACpO,EAAA,CAECI,QAAS0Q,EACTzQ,QAAS,GAAGA,KAAW0Q,IACvBzQ,MAAOA,EAAQ,EACfC,YACAC,eACAC,gBACAC,0BAPK,GAAGL,KAAW0Q,eAzE9B,CAAIzC,IAAKxK,GAAQyK,GAAI,CAAEC,GAAc,IAAVlO,EAAc,EAAI,IAAMmO,MAAO,OAAQC,SAAU,EAAG5E,SAAU,YACvF6E,UAAC/K,IACCgL,EAAAP,EAAA,CAAIE,GAAI,CAAEE,MAAO,UAAWT,IAC1BW,SAAA,CACCjL,IAAA0K,EAACsC,EAAA,CACCvN,QAASI,GACTE,kBACAkN,SAAUjP,EACVkP,gBAAiBlD,GACjB7M,wBACA6H,eACArF,uBACAwN,WAAYlD,GACZlL,mBAGFrC,EAAQ0E,aAAe,IAAIb,IAAI,CAAC6M,EAAKC,IACnC3C,EAACpO,EAAA,CAECI,QAAS0Q,EACTzQ,QAAS,GAAGA,KAAW0Q,IACvBzQ,MAAOA,EAAQ,EACfC,YACAC,eACAC,gBACAC,0BAPK,GAAGL,KAAW0Q"}
|
|
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,wB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0BAPK,GAAGL,KAAWuR,eA3E9B,CAAIzC,IAAK7K,GAAQ8K,GAAI,CAAEC,GAAc,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,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{ChevronDown as i}from"lucide-react";import{ButtonCognitiveIcon as n}from"../../../assests/svg/ButtonCognitiveIcon.js";import{getBentArrowPath as o,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{ChevronDown as i}from"lucide-react";import{ButtonCognitiveIcon as n}from"../../../assests/svg/ButtonCognitiveIcon.js";import{getBentArrowPath as o,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import l from"./ThreeDotsLoader.js";import a from"./connectedLines.js";import{Box as r,Tooltip as c}from"@mui/material";function d({svgContainerRef:d,svgDimensions:p,isResizing:g,overallConnector:u,rootDeviationStyle:h,lines:y,isSideBySide:m,activeSideBySideSection:x,isArrowVisible:f,maintainRelativeOrder:b,proposedSections:v,existingSections:S,cognitivePopup:C,activeBadgeId:I,closeCognitivePopup:B,setActiveBadgeId:R,openCognitivePopupFromState:w,buildSectionPopupState:$,connectedLines:P,pathRefs:M,isGuidelineMode:j,deviationAnalysisStatus:D}){const L=[...y].sort((e,t)=>Number(Boolean(t.isMappingContinuation))-Number(Boolean(e.isMappingContinuation)));return e("svg",{ref:d,style:{position:"absolute",top:0,left:0,width:p.width||"100%",height:p.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:g?0:1,transition:"opacity 0.15s ease-in-out"},children:[u&&t("g",{children:t("line",{x1:u.x1,y1:u.y,x2:u.x2,y2:u.y,stroke:h.badgeBorder,strokeWidth:"1.5"})}),L.map(a=>{const d=a.x1+.5*(a.x2-a.x1),p=(a.y1+a.y2)/2,g=d;if("Not Defined"===a.style.label&&!a.hasCognitive)return null;if(a.isSubSection?m&&x===a.subSectionKeyPath&&f:m&&x===a.sectionIdx&&f)return null;if(b)return null;const u=a.isMappingContinuation?`M ${g} ${a.y1} L ${g} ${a.y2} L ${a.x2} ${a.y2}`:a.isSubSection?o(a.x1,a.y1,a.x2,a.y2):`M ${a.x1} ${a.y1} L ${a.x2} ${a.y2}`;let h=v[a.sectionIdx]||{title:"",content:""},y=S[a.targetRightIdx??a.sectionIdx]||{title:"",content:""};if(a.isSubSection&&a.subSectionKeyPath){const e=a.subSectionKeyPath.includes(s)?a.subSectionKeyPath.split(s):[],t=e[2]||a.subSectionKeyPath,i=e[3]||t,n=t.split("-").map(Number),o=i.split("-").map(Number);let l=null,r=null;n.length>0&&(l=v[n[0]]||null),o.length>0&&(r=S[o[0]]||null);const c=l?.title||"",d=r?.title||"";for(let e=1;e<n.length;e+=1)l?.subsections&&(l=l.subsections[n[e]]||null);for(let e=1;e<o.length;e+=1)r?.subsections&&(r=r.subsections[o[e]]||null);l&&(h={...l,title:c||l.title}),r&&(y={...r,title:d||r.title})}const P=!h.cognitiveData?.isMissingRationale||Boolean(h.cognitiveData?.decisioning?.length),M=h.evaluationResult?.cognitive_decisioning?.decisioning_factors?.length||!1,j=P||M,L=null!=h.evaluationResult||null!=y.evaluationResult,k=("mapping_ready"===D||"deviations_streaming"===D)&&!L,K="complete"!==D||L?null:"Same";return e("g",{children:[t("path",{d:u,fill:"none",stroke:a.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),!a.isMappingContinuation&&t("foreignObject",{x:d-100,y:p-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"},children:t(r,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e(r,{onClick:e=>{e.stopPropagation(),j&&(C.open&&I===a.id?B():(R(a.id),w($(e.currentTarget,h,y,a.sectionIdx,!1,a.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.style.badgeBg,color:a.style.badgeText,border:`1px solid ${a.style.badgeBorder}`,borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:j?"pointer":"default"},children:[k?t(c,{title:"Deviation data generation in progress",placement:"top",arrow:!0,children:t(r,{component:"span",sx:{display:"inline-flex",alignItems:"center"},children:t(l,{color:a.style.badgeText})})}):null==a.style.label?K:"0"===String(a.style.label)?"Same":a.style.label,t(r,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:t(n,{})}),j&&t(i,{size:11,style:{transform:C.open&&I===a.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})})]},a.id)}),t(a,{maintainRelativeOrder:b,connectedLines:P,pathRefs:M,isGuidelineMode:j})]})}export{d as default};
|
|
2
2
|
//# sourceMappingURL=SvgConnectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SvgConnectors.js","sources":["../../../../src/features/CognitiveCompare/components/SvgConnectors.tsx"],"sourcesContent":["import { ChevronDown } from \"lucide-react\";\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { DEVIATION_BADGE_SEPARATOR, getBentArrowPath } from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport ThreeDotsLoader from \"./ThreeDotsLoader\";\nimport ConnectedLinesComp from \"./connectedLines\";\nimport { Box } from \"@mui/material\";\nimport {\n SectionBlock,\n SectionPopupState,\n StyleVariant,\n} from \"../CognitiveCompareTypes\";\n\ntype SvgConnectorLine = {\n id: string;\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n style: StyleVariant;\n sectionIdx: number | string;\n targetRightIdx?: number;\n isSubSection?: boolean;\n isMappingContinuation?: boolean;\n subSectionKeyPath?: string;\n hasCognitive?: boolean;\n};\n\ntype SvgConnectorsProps = {\n svgContainerRef: React.MutableRefObject<SVGSVGElement | null>;\n svgDimensions: { width: number; height: number };\n isResizing: boolean;\n overallConnector: { x1: number; x2: number; y: number } | null;\n rootDeviationStyle: { badgeBorder: string };\n lines: Record<string, any>[];\n isSideBySide: boolean;\n activeSideBySideSection: number | string | null;\n isArrowVisible: boolean;\n maintainRelativeOrder: boolean | undefined;\n proposedSections: SectionBlock[];\n existingSections: SectionBlock[];\n cognitivePopup: SectionPopupState;\n activeBadgeId: string | null;\n closeCognitivePopup: () => void;\n setActiveBadgeId: React.Dispatch<React.SetStateAction<string | null>>;\n openCognitivePopupFromState: (nextPopup: SectionPopupState) => void;\n buildSectionPopupState: (\n anchorEl: HTMLElement | null,\n baseSec: SectionBlock | null,\n refSec: SectionBlock | null,\n sectionIdx: number | string,\n isOrphan?: boolean,\n style?: StyleVariant | null,\n rootNode?: boolean,\n ) => SectionPopupState;\n connectedLines: Record<string, any>[];\n pathRefs: React.MutableRefObject<Record<string, SVGPathElement | null>>;\n isGuidelineMode ?: boolean;\n};\n\nexport default function SvgConnectors({\n svgContainerRef,\n svgDimensions,\n isResizing,\n overallConnector,\n rootDeviationStyle,\n lines,\n isSideBySide,\n activeSideBySideSection,\n isArrowVisible,\n maintainRelativeOrder,\n proposedSections,\n existingSections,\n cognitivePopup,\n activeBadgeId,\n closeCognitivePopup,\n setActiveBadgeId,\n openCognitivePopupFromState,\n buildSectionPopupState,\n connectedLines,\n pathRefs,\n isGuidelineMode,\n}: SvgConnectorsProps) {\n const orderedLines = [...lines].sort(\n (left, right) =>\n Number(Boolean(right.isMappingContinuation)) -\n Number(Boolean(left.isMappingContinuation)),\n );\n\n return (\n <svg\n ref={svgContainerRef}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: svgDimensions.width || \"100%\",\n height: svgDimensions.height || \"100%\",\n pointerEvents: \"none\",\n zIndex: 10,\n overflow: \"visible\",\n opacity: isResizing ? 0 : 1,\n transition: \"opacity 0.15s ease-in-out\",\n }}\n >\n {overallConnector && (\n <g>\n <line\n x1={overallConnector.x1}\n y1={overallConnector.y}\n x2={overallConnector.x2}\n y2={overallConnector.y}\n stroke={rootDeviationStyle.badgeBorder}\n strokeWidth=\"1.5\"\n />\n </g>\n )}\n\n {orderedLines.map((line) => {\n const bendX = line.x1 + (line.x2 - line.x1) * 0.5;\n const midY = (line.y1 + line.y2) / 2;\n const continuationJunctionX = bendX;\n\n if (line.style.label === \"Not Defined\" && !line.hasCognitive) {\n return null;\n }\n\n const isActive = line.isSubSection\n ? isSideBySide &&\n activeSideBySideSection === line.subSectionKeyPath &&\n isArrowVisible\n : isSideBySide &&\n activeSideBySideSection === line.sectionIdx &&\n isArrowVisible;\n\n if (isActive) {\n return null;\n }\n\n if (maintainRelativeOrder) {\n return null;\n }\n\n const pathD = line.isMappingContinuation\n ? `M ${continuationJunctionX} ${line.y1} L ${continuationJunctionX} ${line.y2} L ${line.x2} ${line.y2}`\n : !line.isSubSection\n ? `M ${line.x1} ${line.y1} L ${line.x2} ${line.y2}`\n : getBentArrowPath(line.x1, line.y1, line.x2, line.y2);\n\n let baseSec = proposedSections[line.sectionIdx as number] || { title: \"\", content: \"\" };\n let refSec = existingSections[line.targetRightIdx ?? (line.sectionIdx as number)] || {\n title: \"\",\n content: \"\",\n };\n\n if (line.isSubSection && line.subSectionKeyPath) {\n const pathParts = line.subSectionKeyPath.includes(DEVIATION_BADGE_SEPARATOR)\n ? line.subSectionKeyPath.split(DEVIATION_BADGE_SEPARATOR)\n : [];\n const leftPath = pathParts[2] || line.subSectionKeyPath;\n const rightPath = pathParts[3] || leftPath;\n const leftPathParts = leftPath.split(\"-\").map(Number);\n const rightPathParts = rightPath.split(\"-\").map(Number);\n let leftSection: SectionBlock | null = null;\n let rightSection: SectionBlock | null = null;\n\n if (leftPathParts.length > 0) {\n leftSection = proposedSections[leftPathParts[0]] || null;\n }\n if (rightPathParts.length > 0) {\n rightSection = existingSections[rightPathParts[0]] || null;\n }\n\n const rootParentTitle = leftSection?.title || \"\";\n const rootRefParentTitle = rightSection?.title || \"\";\n\n for (let i = 1; i < leftPathParts.length; i += 1) {\n if (leftSection?.subsections) leftSection = leftSection.subsections[leftPathParts[i]] || null;\n }\n for (let i = 1; i < rightPathParts.length; i += 1) {\n if (rightSection?.subsections) rightSection = rightSection.subsections[rightPathParts[i]] || null;\n }\n\n if (leftSection) baseSec = { ...leftSection, title: rootParentTitle || leftSection.title };\n if (rightSection) refSec = { ...rightSection, title: rootRefParentTitle || rightSection.title };\n }\n\n const isMappingCD =\n !baseSec.cognitiveData?.isMissingRationale ||\n Boolean(baseSec.cognitiveData?.decisioning?.length);\n const isDeviationCD =\n baseSec.evaluationResult?.cognitive_decisioning?.decisioning_factors?.length || false;\n const hasMapping = isMappingCD || isDeviationCD;\n\n return (\n <g key={line.id}>\n <path\n d={pathD}\n fill=\"none\"\n stroke={line.style.badgeBorder || \"#E2E8F0\"}\n strokeWidth=\"1.5\"\n />\n {!line.isMappingContinuation && (\n <foreignObject\n x={bendX - 100}\n y={midY - 14}\n width=\"200\"\n height=\"28\"\n style={{ pointerEvents: \"auto\", overflow: \"visible\" }}\n >\n <Box\n sx={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: \"100%\",\n }}\n >\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (!hasMapping) return;\n if (cognitivePopup.open && activeBadgeId === line.id) {\n closeCognitivePopup();\n return;\n }\n\n setActiveBadgeId(line.id);\n openCognitivePopupFromState(\n buildSectionPopupState(\n e.currentTarget as HTMLElement,\n baseSec,\n refSec,\n line.sectionIdx,\n false,\n line.style,\n ),\n );\n }}\n sx={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n fontSize: \"11px\",\n bgcolor: line.style.badgeBg,\n color: line.style.badgeText,\n border: `1px solid ${line.style.badgeBorder}`,\n borderRadius: \"12px\",\n px: 1.5,\n py: 0.5,\n fontWeight: 600,\n textAlign: \"center\",\n whiteSpace: \"nowrap\",\n cursor: !hasMapping ? \"default\" : \"pointer\",\n }}\n >\n {line.style.badgeText === DEFAULT_DEVIAION_COLOR && line.style.label == null\n ? <ThreeDotsLoader color={line.style.badgeText} />\n : line.style.label == null\n ? null\n : String(line.style.label) === \"0\"\n ? \"Same\"\n : line.style.label}\n <Box\n component=\"span\"\n sx={{\n width: 14,\n height: 14,\n display: \"flex\",\n alignItems: \"center\",\n \"& svg\": { width: \"14px\", height: \"14px\" },\n }}\n >\n <ButtonCognitiveIcon />\n </Box>\n\n {hasMapping && (\n <ChevronDown\n size={11}\n style={{\n transform:\n cognitivePopup.open && activeBadgeId === line.id\n ? \"rotate(180deg)\"\n : \"rotate(0deg)\",\n transition: \"transform 0.25s ease\",\n }}\n />\n )}\n </Box>\n </Box>\n </foreignObject>\n )}\n </g>\n );\n })}\n\n <ConnectedLinesComp \n maintainRelativeOrder={maintainRelativeOrder} \n connectedLines={connectedLines} \n pathRefs={pathRefs} \n isGuidelineMode={isGuidelineMode}\n />\n </svg>\n );\n}\n"],"names":["SvgConnectors","svgContainerRef","svgDimensions","isResizing","overallConnector","rootDeviationStyle","lines","isSideBySide","activeSideBySideSection","isArrowVisible","maintainRelativeOrder","proposedSections","existingSections","cognitivePopup","activeBadgeId","closeCognitivePopup","setActiveBadgeId","openCognitivePopupFromState","buildSectionPopupState","connectedLines","pathRefs","isGuidelineMode","orderedLines","sort","left","right","Number","Boolean","isMappingContinuation","jsxs","ref","style","position","top","width","height","pointerEvents","zIndex","overflow","opacity","transition","children","jsx","x1","y1","y","x2","y2","stroke","badgeBorder","strokeWidth","map","line","bendX","midY","continuationJunctionX","label","hasCognitive","isSubSection","subSectionKeyPath","sectionIdx","pathD","getBentArrowPath","baseSec","title","content","refSec","targetRightIdx","pathParts","includes","DEVIATION_BADGE_SEPARATOR","split","leftPath","rightPath","leftPathParts","rightPathParts","leftSection","rightSection","length","rootParentTitle","rootRefParentTitle","i","subsections","isMappingCD","cognitiveData","isMissingRationale","decisioning","isDeviationCD","evaluationResult","cognitive_decisioning","decisioning_factors","hasMapping","d","fill","x","Box","sx","display","justifyContent","alignItems","onClick","e","stopPropagation","open","id","currentTarget","gap","fontSize","bgcolor","badgeBg","color","badgeText","border","borderRadius","px","py","fontWeight","textAlign","whiteSpace","cursor","DEFAULT_DEVIAION_COLOR","ThreeDotsLoader","String","component","ButtonCognitiveIcon","ChevronDown","size","transform","ConnectedLinesComp"],"mappings":"mcA4DA,SAAwBA,GAAcC,gBACpCA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,iBACAA,EAAAC,mBACAA,EAAAC,MACAA,EAAAC,aACAA,EAAAC,wBACAA,EAAAC,eACAA,EAAAC,sBACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,eACAA,EAAAC,cACAA,EAAAC,oBACAA,EAAAC,iBACAA,EAAAC,4BACAA,EAAAC,uBACAA,EAAAC,eACAA,EAAAC,SACAA,EAAAC,gBACAA,IAEA,MAAMC,EAAe,IAAIhB,GAAOiB,KAC9B,CAACC,EAAMC,IACLC,OAAOC,QAAQF,EAAMG,wBACrBF,OAAOC,QAAQH,EAAKI,yBAItB,OAAAC,EAAC,MAAA,CACCC,IAAK7B,EACL8B,MAAO,CACLC,SAAU,WACVC,IAAK,EACLT,KAAM,EACNU,MAAOhC,EAAcgC,OAAS,OAC9BC,OAAQjC,EAAciC,QAAU,OAChCC,cAAe,OACfC,OAAQ,GACRC,SA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ACD9E,EAAe0F,MAAQzF,IAAkBsC,EAAKoD,GAC5BzF,KAItBC,EAAiBoC,EAAKoD,IACtBvF,EACEC,EACEmF,EAAEI,cACF1C,EACAG,EACAd,EAAKQ,YACL,EACAR,EAAKrB,WAIXiE,GAAI,CACFC,QAAS,cACTE,WAAY,SACZO,IAAK,MACLC,SAAU,OACVC,QAASxD,EAAKrB,MAAM8E,QACpBC,MAAO1D,EAAKrB,MAAMgF,UAClBC,OAAQ,aAAa5D,EAAKrB,MAAMkB,cAChCgE,aAAc,OACdC,GAAI,IACJC,GAAI,GACJC,WAAY,IACZC,UAAW,SACXC,WAAY,SACZC,OAAS5B,EAAyB,UAAZ,WAGvBlD,SAAA,CAAKW,EAAArB,MAAMgF,YAAcS,GAA8C,MAApBpE,EAAKrB,MAAMyB,MAC1Dd,EAAA+E,EAAA,CAAgBX,MAAO1D,EAAKrB,MAAMgF,YACf,MAApB3D,EAAKrB,MAAMyB,MACT,KAC6B,MAA7BkE,OAAOtE,EAAKrB,MAAMyB,OAChB,OACAJ,EAAKrB,MAAMyB,MACnBd,EAACqD,EAAA,CACC4B,UAAU,OACV3B,GAAI,CACF9D,MAAO,GACPC,OAAQ,GACR8D,QAAS,OACTE,WAAY,SACZ,QAAS,CAAEjE,MAAO,OAAQC,OAAQ,SAGpCM,WAACmF,EAAoB,MAGtBjC,GACCjD,EAACmF,EAAA,CACCC,KAAM,GACN/F,MAAO,CACLgG,UACElH,EAAe0F,MAAQzF,IAAkBsC,EAAKoD,GAC1C,iBACA,eACNhE,WAAY,mCAzFpBY,EAAKoD,MAqGjB9D,EAACsF,EAAA,CACCtH,wBACAS,iBACAC,WACAC,sBAIR"}
|
|
1
|
+
{"version":3,"file":"SvgConnectors.js","sources":["../../../../src/features/CognitiveCompare/components/SvgConnectors.tsx"],"sourcesContent":["import { ChevronDown } from \"lucide-react\";\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { DEVIATION_BADGE_SEPARATOR, getBentArrowPath } from \"../CognitiveComparehelpers\";\nimport ThreeDotsLoader from \"./ThreeDotsLoader\";\nimport ConnectedLinesComp from \"./connectedLines\";\nimport { Box, Tooltip } from \"@mui/material\";\nimport {\n DeviationAnalysisStatus,\n SectionBlock,\n SectionPopupState,\n StyleVariant,\n} from \"../CognitiveCompareTypes\";\n\ntype SvgConnectorLine = {\n id: string;\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n style: StyleVariant;\n sectionIdx: number | string;\n targetRightIdx?: number;\n isSubSection?: boolean;\n isMappingContinuation?: boolean;\n subSectionKeyPath?: string;\n hasCognitive?: boolean;\n};\n\ntype SvgConnectorsProps = {\n svgContainerRef: React.MutableRefObject<SVGSVGElement | null>;\n svgDimensions: { width: number; height: number };\n isResizing: boolean;\n overallConnector: { x1: number; x2: number; y: number } | null;\n rootDeviationStyle: { badgeBorder: string };\n lines: Record<string, any>[];\n isSideBySide: boolean;\n activeSideBySideSection: number | string | null;\n isArrowVisible: boolean;\n maintainRelativeOrder: boolean | undefined;\n proposedSections: SectionBlock[];\n existingSections: SectionBlock[];\n cognitivePopup: SectionPopupState;\n activeBadgeId: string | null;\n closeCognitivePopup: () => void;\n setActiveBadgeId: React.Dispatch<React.SetStateAction<string | null>>;\n openCognitivePopupFromState: (nextPopup: SectionPopupState) => void;\n buildSectionPopupState: (\n anchorEl: HTMLElement | null,\n baseSec: SectionBlock | null,\n refSec: SectionBlock | null,\n sectionIdx: number | string,\n isOrphan?: boolean,\n style?: StyleVariant | null,\n rootNode?: boolean,\n ) => SectionPopupState;\n connectedLines: Record<string, any>[];\n pathRefs: React.MutableRefObject<Record<string, SVGPathElement | null>>;\n isGuidelineMode ?: boolean;\n deviationAnalysisStatus: DeviationAnalysisStatus;\n};\n\nexport default function SvgConnectors({\n svgContainerRef,\n svgDimensions,\n isResizing,\n overallConnector,\n rootDeviationStyle,\n lines,\n isSideBySide,\n activeSideBySideSection,\n isArrowVisible,\n maintainRelativeOrder,\n proposedSections,\n existingSections,\n cognitivePopup,\n activeBadgeId,\n closeCognitivePopup,\n setActiveBadgeId,\n openCognitivePopupFromState,\n buildSectionPopupState,\n connectedLines,\n pathRefs,\n isGuidelineMode,\n deviationAnalysisStatus,\n}: SvgConnectorsProps) {\n const orderedLines = [...lines].sort(\n (left, right) =>\n Number(Boolean(right.isMappingContinuation)) -\n Number(Boolean(left.isMappingContinuation)),\n );\n\n return (\n <svg\n ref={svgContainerRef}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: svgDimensions.width || \"100%\",\n height: svgDimensions.height || \"100%\",\n pointerEvents: \"none\",\n zIndex: 10,\n overflow: \"visible\",\n opacity: isResizing ? 0 : 1,\n transition: \"opacity 0.15s ease-in-out\",\n }}\n >\n {overallConnector && (\n <g>\n <line\n x1={overallConnector.x1}\n y1={overallConnector.y}\n x2={overallConnector.x2}\n y2={overallConnector.y}\n stroke={rootDeviationStyle.badgeBorder}\n strokeWidth=\"1.5\"\n />\n </g>\n )}\n\n {orderedLines.map((line) => {\n const bendX = line.x1 + (line.x2 - line.x1) * 0.5;\n const midY = (line.y1 + line.y2) / 2;\n const continuationJunctionX = bendX;\n\n if (line.style.label === \"Not Defined\" && !line.hasCognitive) {\n return null;\n }\n\n const isActive = line.isSubSection\n ? isSideBySide &&\n activeSideBySideSection === line.subSectionKeyPath &&\n isArrowVisible\n : isSideBySide &&\n activeSideBySideSection === line.sectionIdx &&\n isArrowVisible;\n\n if (isActive) {\n return null;\n }\n\n if (maintainRelativeOrder) {\n return null;\n }\n\n const pathD = line.isMappingContinuation\n ? `M ${continuationJunctionX} ${line.y1} L ${continuationJunctionX} ${line.y2} L ${line.x2} ${line.y2}`\n : !line.isSubSection\n ? `M ${line.x1} ${line.y1} L ${line.x2} ${line.y2}`\n : getBentArrowPath(line.x1, line.y1, line.x2, line.y2);\n\n let baseSec = proposedSections[line.sectionIdx as number] || { title: \"\", content: \"\" };\n let refSec = existingSections[line.targetRightIdx ?? (line.sectionIdx as number)] || {\n title: \"\",\n content: \"\",\n };\n\n if (line.isSubSection && line.subSectionKeyPath) {\n const pathParts = line.subSectionKeyPath.includes(DEVIATION_BADGE_SEPARATOR)\n ? line.subSectionKeyPath.split(DEVIATION_BADGE_SEPARATOR)\n : [];\n const leftPath = pathParts[2] || line.subSectionKeyPath;\n const rightPath = pathParts[3] || leftPath;\n const leftPathParts = leftPath.split(\"-\").map(Number);\n const rightPathParts = rightPath.split(\"-\").map(Number);\n let leftSection: SectionBlock | null = null;\n let rightSection: SectionBlock | null = null;\n\n if (leftPathParts.length > 0) {\n leftSection = proposedSections[leftPathParts[0]] || null;\n }\n if (rightPathParts.length > 0) {\n rightSection = existingSections[rightPathParts[0]] || null;\n }\n\n const rootParentTitle = leftSection?.title || \"\";\n const rootRefParentTitle = rightSection?.title || \"\";\n\n for (let i = 1; i < leftPathParts.length; i += 1) {\n if (leftSection?.subsections) leftSection = leftSection.subsections[leftPathParts[i]] || null;\n }\n for (let i = 1; i < rightPathParts.length; i += 1) {\n if (rightSection?.subsections) rightSection = rightSection.subsections[rightPathParts[i]] || null;\n }\n\n if (leftSection) baseSec = { ...leftSection, title: rootParentTitle || leftSection.title };\n if (rightSection) refSec = { ...rightSection, title: rootRefParentTitle || rightSection.title };\n }\n\n const isMappingCD =\n !baseSec.cognitiveData?.isMissingRationale ||\n Boolean(baseSec.cognitiveData?.decisioning?.length);\n const isDeviationCD =\n baseSec.evaluationResult?.cognitive_decisioning?.decisioning_factors?.length || false;\n const hasMapping = isMappingCD || isDeviationCD;\n const hasDeviationResult =\n baseSec.evaluationResult != null ||\n refSec.evaluationResult != null;\n const isDeviationGenerationInProgress =\n deviationAnalysisStatus === \"mapping_ready\" ||\n deviationAnalysisStatus === \"deviations_streaming\";\n const shouldShowDeviationLoader =\n isDeviationGenerationInProgress && !hasDeviationResult;\n const fallbackLabel =\n deviationAnalysisStatus === \"complete\" && !hasDeviationResult\n ? \"Same\"\n : null;\n\n return (\n <g key={line.id}>\n <path\n d={pathD}\n fill=\"none\"\n stroke={line.style.badgeBorder || \"#E2E8F0\"}\n strokeWidth=\"1.5\"\n />\n {!line.isMappingContinuation && (\n <foreignObject\n x={bendX - 100}\n y={midY - 14}\n width=\"200\"\n height=\"28\"\n style={{ pointerEvents: \"auto\", overflow: \"visible\" }}\n >\n <Box\n sx={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: \"100%\",\n }}\n >\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (!hasMapping) return;\n if (cognitivePopup.open && activeBadgeId === line.id) {\n closeCognitivePopup();\n return;\n }\n\n setActiveBadgeId(line.id);\n openCognitivePopupFromState(\n buildSectionPopupState(\n e.currentTarget as HTMLElement,\n baseSec,\n refSec,\n line.sectionIdx,\n false,\n line.style,\n ),\n );\n }}\n sx={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n fontSize: \"11px\",\n bgcolor: line.style.badgeBg,\n color: line.style.badgeText,\n border: `1px solid ${line.style.badgeBorder}`,\n borderRadius: \"12px\",\n px: 1.5,\n py: 0.5,\n fontWeight: 600,\n textAlign: \"center\",\n whiteSpace: \"nowrap\",\n cursor: !hasMapping ? \"default\" : \"pointer\",\n }}\n >\n {shouldShowDeviationLoader\n ? (\n <Tooltip title=\"Deviation data generation in progress\" placement=\"top\" arrow>\n <Box component=\"span\" sx={{ display: \"inline-flex\", alignItems: \"center\" }}>\n <ThreeDotsLoader color={line.style.badgeText} />\n </Box>\n </Tooltip>\n )\n : line.style.label == null\n ? fallbackLabel\n : String(line.style.label) === \"0\"\n ? \"Same\"\n : line.style.label}\n <Box\n component=\"span\"\n sx={{\n width: 14,\n height: 14,\n display: \"flex\",\n alignItems: \"center\",\n \"& svg\": { width: \"14px\", height: \"14px\" },\n }}\n >\n <ButtonCognitiveIcon />\n </Box>\n\n {hasMapping && (\n <ChevronDown\n size={11}\n style={{\n transform:\n cognitivePopup.open && activeBadgeId === line.id\n ? \"rotate(180deg)\"\n : \"rotate(0deg)\",\n transition: \"transform 0.25s ease\",\n }}\n />\n )}\n </Box>\n </Box>\n </foreignObject>\n )}\n </g>\n );\n })}\n\n <ConnectedLinesComp \n maintainRelativeOrder={maintainRelativeOrder} \n connectedLines={connectedLines} \n pathRefs={pathRefs} \n isGuidelineMode={isGuidelineMode}\n />\n </svg>\n );\n}\n"],"names":["SvgConnectors","svgContainerRef","svgDimensions","isResizing","overallConnector","rootDeviationStyle","lines","isSideBySide","activeSideBySideSection","isArrowVisible","maintainRelativeOrder","proposedSections","existingSections","cognitivePopup","activeBadgeId","closeCognitivePopup","setActiveBadgeId","openCognitivePopupFromState","buildSectionPopupState","connectedLines","pathRefs","isGuidelineMode","deviationAnalysisStatus","orderedLines","sort","left","right","Number","Boolean","isMappingContinuation","jsxs","ref","style","position","top","width","height","pointerEvents","zIndex","overflow","opacity","transition","children","jsx","x1","y1","y","x2","y2","stroke","badgeBorder","strokeWidth","map","line","bendX","midY","continuationJunctionX","label","hasCognitive","isSubSection","subSectionKeyPath","sectionIdx","pathD","getBentArrowPath","baseSec","title","content","refSec","targetRightIdx","pathParts","includes","DEVIATION_BADGE_SEPARATOR","split","leftPath","rightPath","leftPathParts","rightPathParts","leftSection","rightSection","length","rootParentTitle","rootRefParentTitle","i","subsections","isMappingCD","cognitiveData","isMissingRationale","decisioning","isDeviationCD","evaluationResult","cognitive_decisioning","decisioning_factors","hasMapping","hasDeviationResult","shouldShowDeviationLoader","fallbackLabel","d","fill","x","Box","sx","display","justifyContent","alignItems","onClick","e","stopPropagation","open","id","currentTarget","gap","fontSize","bgcolor","badgeBg","color","badgeText","border","borderRadius","px","py","fontWeight","textAlign","whiteSpace","cursor","Tooltip","placement","arrow","component","ThreeDotsLoader","String","ButtonCognitiveIcon","ChevronDown","size","transform","ConnectedLinesComp"],"mappings":"uYA6DA,SAAwBA,GAAcC,gBACpCA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,iBACAA,EAAAC,mBACAA,EAAAC,MACAA,EAAAC,aACAA,EAAAC,wBACAA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cAAeE,WAAY,UAC9D7D,SAAAC,EAACqF,EAAgB,CAAAd,MAAO7D,EAAKrB,MAAMmF,gBAInB,MAApB9D,EAAKrB,MAAMyB,MACTsC,EAC6B,MAA7BkC,OAAO5E,EAAKrB,MAAMyB,OAChB,OACAJ,EAAKrB,MAAMyB,MACnBd,EAACwD,EAAA,CACC4B,UAAU,OACV3B,GAAI,CACFjE,MAAO,GACPC,OAAQ,GACRiE,QAAS,OACTE,WAAY,SACZ,QAAS,CAAEpE,MAAO,OAAQC,OAAQ,SAGpCM,WAACwF,EAAoB,MAGtBtC,GACCjD,EAACwF,EAAA,CACCC,KAAM,GACNpG,MAAO,CACLqG,UACExH,EAAe8F,MAAQ7F,IAAkBuC,EAAKuD,GAC1C,iBACA,eACNnE,WAAY,mCA/FpBY,EAAKuD,MA2GjBjE,EAAC2F,EAAA,CACC5H,wBACAS,iBACAC,WACAC,sBAIR"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Box as n,Typography as i}from"@mui/material";import o,{useRef as a,useMemo as l,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as d}from"../CognitiveCompareConstants.js";import{EllipsisVertical as c}from"lucide-react";import h from"react-markdown";import{mixHexColors as p,areMarkdownPropsEqual as g}from"../CognitiveComparehelpers.js";import m from"rehype-raw";import u from"remark-gfm";const f=e=>"function"==typeof e?e:e?.default||e,x=[f(u)],b=[f(m)],y=o.memo(({content:g,overlayContent:m,sxStyles:u,deviationBadges:f=[],highlights:y=[],maintainRelativeOrder:v=!0,highlightBg:w,suppressHighlightBg:E=!1,collisionKey:S})=>{const k=a(null),C=!!m,B=l(()=>f.reduce((e,t)=>({...e,[t.id]:t}),{}),[f]),F=a({badgeMap:B,highlightBg:w,hideHighlightBg:C,suppressHighlightBg:E});F.current={badgeMap:B,highlightBg:w,hideHighlightBg:C,suppressHighlightBg:E};const $=(e,t)=>o.Children.map(e,e=>{if(!o.isValidElement(e))return e;const r=e.props?.children?$(e.props.children,t):e.props.children,n=o.cloneElement(e,{...e.props,children:r});return t(n)}),z=l(()=>({mark:({children:t,...r})=>{const{badgeMap:n,highlightBg:i,hideHighlightBg:o,suppressHighlightBg:a}=F.current,l=r["data-badge-id"],s=l?n[l]:null,d=r["data-highlight-color"]??s?.style?.highlightBg??s?.style?.badgeBg??i,c="true"===r["data-is-suggested-deviation-fix"]||a;return e("span",{style:{...c?{}:{backgroundColor:d},borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px",...o?{color:"transparent"}:{}},children:t})},span:({children:r,...i})=>{const{badgeMap:o}=F.current,a=i["data-badge-id"];if(!a)return e("span",{...i,children:r});const l=o[a];if(!l)return e("span",{...i,children:r});const s="number"==typeof l.stackIndex?l.stackIndex:0,h=`translateY(calc(-20% + ${12*s}px + var(--badge-nudge, 0px)))`;return t(n,{component:"span",sx:{position:"static",display:"inline"},children:[t(n,{ref:l.badgeRef,className:"deviation-badge","data-side":l.side||"right",sx:{fontStyle:"normal",position:"absolute",zIndex:30+s,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:l.style?.badgeBg||"#EEF2FF",color:l.style?.badgeText||d,border:`1px solid ${l.style?.badgeBorder||"#C7D2FE"}`,borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none",..."left"===l.side?{right:"-16px",transform:`${h} translateX(calc(100% + 8px))`}:{left:"-16px",transform:`${h} translateX(calc(-100% - 8px))`},...l.isConnected&&l.style&&{outline:`2px solid ${l.style.badgeBorder}`,outlineOffset:"1px"}},children:[t(n,{onClick:e=>{e.stopPropagation(),l.onSummaryClick&&l.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}},children:[e(n,{component:"span",sx:{fontSize:"10px",fontWeight:700},children:l.label}),("left"===l.side||l.isOrphan)&&e(n,{component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:`1px solid ${l.style?.badgeBorder||"#C7D2FE"}`},children:null!=l.score&&"N/A"!==l.score&&"NA"!==l.score&&0!==l.score?`${l.score}`:"N/A"===l.score||"NA"===l.score?"N/A":"Same"})]}),("left"===l.side||l.isOrphan)&&e(n,{onClick:e=>{e.stopPropagation(),l.onClick&&l.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:`1px solid ${l.style?.badgeBorder||"#C7D2FE"}`,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:e(c,{size:12,color:l.style?.badgeText||"#3730A3"})})]}),r]})},table:({children:t})=>e(n,{sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1},children:e(n,{component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"},children:t})}),thead:({children:t})=>e(n,{component:"thead",children:t}),tbody:({children:t})=>e(n,{component:"tbody",children:t}),tr:({children:t})=>e(n,{component:"tr",sx:{borderBottom:"1px solid #E5E7EB"},children:t}),th:({children:t})=>e(n,{component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:t}),td:({children:t})=>e(n,{component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:t}),code:({children:t})=>e("span",{style:{fontFamily:"inherit",fontSize:"inherit"},children:t}),pre:({children:t})=>e("span",{style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"},children:t}),updated:({children:t})=>e(r,{children:t}),deleted:({children:t})=>{const r=$(t,e=>o.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e("span",{style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"},children:r})},changed:({children:t})=>{const r=$(t,e=>o.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e("span",{style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"},children:r})},ul:({children:t,...r})=>e(n,{component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"},...r,children:t}),ol:({children:t,...r})=>e(n,{component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"},...r,children:t}),li:({children:t,...r})=>e(n,{component:"li",sx:{mb:.5,display:"list-item"},...r,children:t})}),[]),A=e=>{if(!e||"string"!=typeof e)return"";let t=e;t=t.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1"),t=t.replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n"),t=t.replace(/^(\d+\.)(\s{2,})/gm,(e,t,r)=>`${t.slice(0,-1)}\\.${r}`),t=t.replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,(e,t,r,n)=>`${t} ${n}`),t=t.replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2"),t=t.replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2"),t=t.replace(/\n{3,}/g,"\n\n"),t=t.replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,e=>e.replace(/ /g," ").replace(/\t/g," "));const r=t.split(/(\n{2,})/);return t=r.map(e=>/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,(t,r)=>{const n=e.slice(r+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(n)?"\n":" "})).join(""),t.trim()},T=e=>e.replace(/[\.,;:]/g," "),W=l(()=>f.map(e=>({id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size})),[f]),O=l(()=>{let e=A(g||"");const t=E?T(e):e,r=(f||[]).map(e=>({id:e?.id,highlight:A(e?.highlight||""),highlightColor:e?.style?.highlightBg||e?.style?.badgeBg||w})).filter(e=>e.id&&e.highlight),n={};r.forEach(e=>{n[e.highlight]||(n[e.highlight]=[]),n[e.highlight].push(e)});const i=(e,t="",r,n=[])=>{let i=!1;const o=e=>{const o=((e,t="",r)=>{const n=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!n)return e;const i=n[1]??"",o=n[2]??"",a=n[3]??"";return o?i+((e="",t)=>`<mark${e?` data-badge-id="${e}"`:""}${t?` data-highlight-color="${t}"`:""}>`)(t,r)+o+"</mark>"+a:e})(e,t,r);let a=o;if(!i&&n.length>0){i=!0;let e="",t="";n.forEach(r=>{e+=(e=>`<span data-badge-id="${e}">`)(r.id),t="</span>"+t}),a=e+o+t}return""+a};return e.split(/(\n+)/).map(e=>{if(/^\n+$/.test(e))return e;if(!e.trim())return e;return""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(e=>"|"!==e&&e.trim()?o(e):e).join(""):o(e)}).join("")},o=[];Object.entries(n).forEach(([r,n])=>{let i=e.indexOf(r),a=!1;if(-1===i&&E){const e=T(r);i=t.indexOf(e),-1!==i&&(a=!0)}if(-1===i)return;let l=n[0].highlightColor;for(let e=1;e<n.length;e++)l=p(l,n[e].highlightColor||"");o.push({highlight:r,start:i,end:i+r.length,badges:n,color:l,usedLooseMatch:a})});const a=new Set(Object.keys(n));(y||[]).forEach(r=>{if(!r)return;const n=A(r);if(!n||a.has(n))return;let i=e.indexOf(n),l=!1;if(-1===i&&E){const e=T(n);i=t.indexOf(e),-1!==i&&(l=!0)}if(-1===i)return;const s=e.slice(0,i);(s.match(/</g)||[]).length===(s.match(/>/g)||[]).length&&o.push({highlight:n,start:i,end:i+n.length,badges:[],color:w||"",usedLooseMatch:l})}),o.sort((e,t)=>e.start-t.start||t.end-e.end);const l=[],s={};o.forEach((e,t)=>{let r=e.start,n=e.end;for(const i of l){const o=i.start,a=i.end,l=r<a&&n>a&&r>=o,d=r<o&&n>o&&n<=a;if(r>=o&&n<=a){e.orphaned=!0,s[t]=i.matchIdx;break}l&&(r=a),d&&(n=o)}e.trimmedStart=r,e.trimmedEnd=n,!e.orphaned&&r<n&&l.push({start:r,end:n,matchIdx:t})});const d={};Object.entries(s).forEach(([e,t])=>{const r=Number(e);d[t]||(d[t]=[]),d[t].push(r)});return o.map((e,t)=>({...e,idx:t})).filter(e=>!e.orphaned).sort((e,t)=>(t.trimmedStart??t.start)-(e.trimmedStart??e.start)).forEach(t=>{const r=t.trimmedStart??t.start,n=t.trimmedEnd??t.end;if(r>=n)return;const a=e.slice(r,n),l=((e,t,r,n)=>{if(!r.length)return e;const a=r.map(e=>o[e]).sort((e,t)=>e.start-t.start);let l="",s=0;return a.forEach(r=>{const o=Math.max(s,r.start-t),a=Math.max(o,r.end-t);if(o>=a)return;const d=p(n,r.color||"");l+=e.slice(s,o),l+=i(e.slice(o,a),r.badges?.[0]?.id||"",d,r.badges||[]),s=a}),l+=e.slice(s),l})(t.usedLooseMatch||r!==t.start||n!==t.end?a:t.highlight,t.start,d[t.idx]||[],t.color),s=i(l,t.badges?.[0]?.id||"",t.color,t.badges||[]);e=e.slice(0,r)+s+e.slice(n)}),e},[g,f,y,w,E]),I=l(()=>m?A(m||""):"",[m]),M=!!m,j={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},P={...u,...j,position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2,...M?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}},D={...u,...j,position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"};return s(()=>{if(!k.current)return;const e=()=>{const e=Array.from(k.current.querySelectorAll(".deviation-badge"));if(0===e.length)return;e.forEach(e=>{e.style.setProperty("--badge-nudge","0px")});const t=e.filter(e=>"left"===e.dataset.side),r=e.filter(e=>"left"!==e.dataset.side),n=k.current.getBoundingClientRect(),i=n.bottom-4,o=n.top+4,a=e=>{if(0===e.length)return;const t=e.map(e=>{const t=e.getBoundingClientRect();return{el:e,naturalTop:t.top,height:t.height,currentTop:t.top}});t.sort((e,t)=>e.naturalTop-t.naturalTop);const r=[];let n=[];t.forEach(e=>{if(0===n.length)n.push(e);else{const t=n[n.length-1],i=t.currentTop+t.height;e.naturalTop<i+8?(e.currentTop=i+8,n.push(e)):(r.push(n),n=[e])}}),n.length>0&&r.push(n),r.forEach(e=>{const t=e[e.length-1],r=t.currentTop+t.height;if(r>i){const t=r-i,n=e[0].currentTop-o,a=Math.max(0,Math.min(t,n));e.forEach(e=>{e.currentTop-=a})}}),r.flat().forEach(e=>{const t=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge",`${t}px`)})};a(t),a(r)},t=requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})}),r=new ResizeObserver(()=>{requestAnimationFrame(e)});return r.observe(k.current),()=>{r.disconnect(),cancelAnimationFrame(t)}},[O,S,W]),t(n,{ref:k,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0},children:[e(i,{component:"div",sx:{...P,padding:"3px"},children:e(h,{components:z,remarkPlugins:x,rehypePlugins:b,children:O.replace(/#{3}/g,"")})}),M&&e(i,{component:"div",sx:D,children:e(h,{components:z,remarkPlugins:x,rehypePlugins:b,children:I})})]})},g);export{y as MemoizedMarkdown};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{Box as i,Typography as n}from"@mui/material";import o,{useRef as l,useMemo as a,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as d}from"../CognitiveCompareConstants.js";import{EllipsisVertical as c}from"lucide-react";import h from"react-markdown";import{findRedlineTextAnchorRange as p,findTextMatchRange as g,mixHexColors as m,areMarkdownPropsEqual as u}from"../CognitiveComparehelpers.js";import{findTextRangeWithFormatting as f}from"../utils/normalizeInlineMarkdown.js";import b from"rehype-raw";import x from"remark-gfm";import{normalizeRedlineMarkdown as y}from"../utils/normalizeRedlineMarkdown.js";import{normalizeCompactedGfmTables as v}from"../utils/normalizeCompactedGfmTables.js";const S=e=>"function"==typeof e?e:e?.default||e,E=[S(x)],k=[S(b)],C=o.memo(({content:u,overlayContent:b,fallbackContent:x,sxStyles:S,deviationBadges:C=[],highlights:w=[],maintainRelativeOrder:B=!0,highlightBg:F,suppressHighlightBg:$=!1,collisionKey:z})=>{const A=l(null),T=!!b,W=a(()=>C.reduce((e,t)=>({...e,[t.id]:t}),{}),[C]),I=l({badgeMap:W,highlightBg:F,hideHighlightBg:T,suppressHighlightBg:$});I.current={badgeMap:W,highlightBg:F,hideHighlightBg:T,suppressHighlightBg:$};const M=(e,t)=>o.Children.map(e,e=>{if(!o.isValidElement(e))return e;const r=e.props?.children?M(e.props.children,t):e.props.children,i=o.cloneElement(e,{...e.props,children:r});return t(i)}),j=a(()=>({mark:({children:t,...r})=>{const{badgeMap:i,highlightBg:n,hideHighlightBg:o,suppressHighlightBg:l}=I.current,a=r["data-badge-id"],s=a?i[a]:null,d=r["data-highlight-color"]??s?.style?.highlightBg??s?.style?.badgeBg??n,c="true"===r["data-is-suggested-deviation-fix"]||l;return e("span",{style:{...c?{}:{backgroundColor:d},borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px",...o?{color:"transparent"}:{}},children:t})},br:()=>e("br",{}),span:({children:r,...n})=>{const{badgeMap:o}=I.current,l=n["data-badge-id"];if(!l)return e("span",{...n,children:r});const a=o[l];if(!a)return e("span",{...n,children:r});const s="number"==typeof a.stackIndex?a.stackIndex:0,h=`translateY(calc(-20% + ${12*s}px + var(--badge-nudge, 0px)))`;return t(i,{component:"span",sx:{position:"static",display:"inline"},children:[t(i,{ref:a.badgeRef,className:"deviation-badge","data-side":a.side||"right",sx:{fontStyle:"normal",position:"absolute",zIndex:30+s,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:a.style?.badgeBg||"#EEF2FF",color:a.style?.badgeText||d,border:`1px solid ${a.style?.badgeBorder||"#C7D2FE"}`,borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none",..."left"===a.side?{right:"-16px",transform:`${h} translateX(calc(100% + 8px))`}:{left:"-16px",transform:`${h} translateX(calc(-100% - 8px))`},...a.isConnected&&a.style&&{outline:`2px solid ${a.style.badgeBorder}`,outlineOffset:"1px"}},children:[t(i,{onClick:e=>{e.stopPropagation(),a.onSummaryClick&&a.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}},children:[e(i,{component:"span",sx:{fontSize:"10px",fontWeight:700},children:a.label}),("left"===a.side||a.isOrphan)&&e(i,{component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:`1px solid ${a.style?.badgeBorder||"#C7D2FE"}`},children:null!=a.score&&"N/A"!==a.score&&"NA"!==a.score&&0!==a.score?`${a.score}`:"N/A"===a.score||"NA"===a.score?"N/A":"Same"})]}),("left"===a.side||a.isOrphan)&&e(i,{onClick:e=>{e.stopPropagation(),a.onClick&&a.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:`1px solid ${a.style?.badgeBorder||"#C7D2FE"}`,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:e(c,{size:12,color:a.style?.badgeText||"#3730A3"})})]}),r]})},table:({children:t})=>e(i,{sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1},children:e(i,{component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"},children:t})}),thead:({children:t})=>e(i,{component:"thead",children:t}),tbody:({children:t})=>e(i,{component:"tbody",children:t}),tr:({children:t})=>e(i,{component:"tr",sx:{borderBottom:"1px solid #E5E7EB"},children:t}),th:({children:t})=>e(i,{component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:t}),td:({children:t})=>e(i,{component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:t}),code:({children:t})=>e("span",{style:{fontFamily:"inherit",fontSize:"inherit"},children:t}),pre:({children:t})=>e("span",{style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"},children:t}),updated:({children:t})=>e(r,{children:t}),deleted:({children:t})=>{const r=M(t,e=>o.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e("span",{style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"},children:r})},changed:({children:t})=>{const r=M(t,e=>o.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e("span",{style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"},children:r})},ul:({children:t,...r})=>e(i,{component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"},...r,children:t}),ol:({children:t,...r})=>e(i,{component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"},...r,children:t}),li:({children:t,...r})=>e(i,{component:"li",sx:{mb:.5,display:"list-item"},...r,children:t})}),[]),q=e=>{if(!e||"string"!=typeof e)return"";let t=v(e);t=t.replace(/((?:<\/?(?:updated|changed|deleted|manual)\b[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1"),t=t.replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n"),t=t.replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,(e,t,r,i)=>`${t}${r.slice(0,-1)}\\.${i}`),t=t.replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,(e,t,r,i)=>`${t} ${i}`),t=t.replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2"),t=t.replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2"),t=t.replace(/\n{3,}/g,"\n\n"),t=t.replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,e=>e.replace(/ /g," ").replace(/\t/g," "));const r=t.split(/(\n{2,})/);return t=r.map(e=>/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,(t,r)=>{const i=e.slice(r+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})).join(""),t.trim()},H=a(()=>C.map(e=>({id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size})),[C]),O=e=>q(y(e||"")),P=a(()=>{let e=q(y(u||""));const t=x?q(y(x)):"",r=(C||[]).map(e=>({id:e?.id,highlight:O(e?.highlight||""),highlightColor:e?.style?.highlightBg||e?.style?.badgeBg||F})).filter(e=>e.id&&e.highlight);if(t&&r.length>0){const i=(e,t)=>$?p(e,t):g(e,t,!1),n=r.some(({highlight:t})=>!i(e,t)),o=r.every(({highlight:e})=>!!i(t,e));n&&o&&(e=t)}const i={};r.forEach(e=>{i[e.highlight]||(i[e.highlight]=[]),i[e.highlight].push(e)});const n=(e,t="",r,i=[])=>{let n=!1;const o=e=>{const o=((e,t="",r)=>{const i=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!i)return e;const n=i[1]??"",o=i[2]??"",l=i[3]??"";return o?n+((e="",t)=>`<mark${e?` data-badge-id="${e}"`:""}${t?` data-highlight-color="${t}"`:""}>`)(t,r)+o+"</mark>"+l:e})(e,t,r);let l=o;if(!n&&i.length>0){n=!0;let e="",t="";i.forEach(r=>{e+=(e=>`<span data-badge-id="${e}">`)(r.id),t="</span>"+t}),l=e+o+t}return""+l};return e.split(/(\n+)/).map(e=>{if(/^\n+$/.test(e))return e;if(!e.trim())return e;return""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(e=>"|"!==e&&e.trim()?o(e):e).join(""):o(e)}).join("")},o=[];Object.entries(i).forEach(([t,r])=>{let i=$?p(e,t):g(e,t,!1);if(i||$||(i=f(e,t)),!i)return;const n=e.slice(i.start,i.end)!==t;let l=r[0].highlightColor;for(let e=1;e<r.length;e++)l=m(l,r[e].highlightColor||"");o.push({highlight:t,start:i.start,end:i.end,badges:r,color:l,usedLooseMatch:n})});const l=new Set(Object.keys(i));(w||[]).forEach(t=>{if(!t)return;const r=O(t);if(!r||l.has(r))return;const i=$?p(e,r):g(e,r,!1);if(!i)return;const n=e.slice(i.start,i.end)!==r,a=e.slice(0,i.start);(a.match(/</g)||[]).length===(a.match(/>/g)||[]).length&&o.push({highlight:r,start:i.start,end:i.end,badges:[],color:F||"",usedLooseMatch:n})}),o.sort((e,t)=>e.start-t.start||t.end-e.end);const a=[],s={};o.forEach((e,t)=>{let r=e.start,i=e.end;for(const n of a){const o=n.start,l=n.end,a=r<l&&i>l&&r>=o,d=r<o&&i>o&&i<=l;if(r>=o&&i<=l){e.orphaned=!0,s[t]=n.matchIdx;break}a&&(r=l),d&&(i=o)}e.trimmedStart=r,e.trimmedEnd=i,!e.orphaned&&r<i&&a.push({start:r,end:i,matchIdx:t})});const d={};Object.entries(s).forEach(([e,t])=>{const r=Number(e);d[t]||(d[t]=[]),d[t].push(r)});return o.map((e,t)=>({...e,idx:t})).filter(e=>!e.orphaned).sort((e,t)=>(t.trimmedStart??t.start)-(e.trimmedStart??e.start)).forEach(t=>{const r=t.trimmedStart??t.start,i=t.trimmedEnd??t.end;if(r>=i)return;const l=e.slice(r,i),a=((e,t,r,i)=>{if(!r.length)return e;const l=r.map(e=>o[e]).sort((e,t)=>e.start-t.start);let a="",s=0;return l.forEach(r=>{const o=Math.max(s,r.start-t),l=Math.max(o,r.end-t);if(o>=l)return;const d=m(i,r.color||"");a+=e.slice(s,o),a+=n(e.slice(o,l),r.badges?.[0]?.id||"",d,r.badges||[]),s=l}),a+=e.slice(s),a})(t.usedLooseMatch||r!==t.start||i!==t.end?l:t.highlight,t.start,d[t.idx]||[],t.color),s=n(a,t.badges?.[0]?.id||"",t.color,t.badges||[]);e=e.slice(0,r)+s+e.slice(i)}),e},[u,x,C,w,F,$]),R=a(()=>b?q(y(b||"")):"",[b]),D=!!b,N={...S,"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"},position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"},L={...N,zIndex:2,...D?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}},X={...N,zIndex:1,pointerEvents:"auto"};return s(()=>{if(!A.current)return;const e=()=>{const e=Array.from(A.current.querySelectorAll(".deviation-badge"));if(0===e.length)return;e.forEach(e=>{e.style.setProperty("--badge-nudge","0px")});const t=A.current.getBoundingClientRect(),r=t.bottom-4,i=t.top+4,n=A.current.querySelector('div[data-layer="base"]')||A.current.querySelector("div")?.firstElementChild,o=D?A.current.querySelector('div[data-layer="overlay"]')||A.current.querySelector("div")?.lastElementChild:null,l=n?Array.from(n.querySelectorAll(".deviation-badge")):[],a=o?Array.from(o.querySelectorAll(".deviation-badge")):[],s=e.length>0?e.filter(e=>"left"===e.dataset.side):l.filter(e=>"left"===e.dataset.side),d=e.length>0?e.filter(e=>"left"!==e.dataset.side):l.filter(e=>"left"!==e.dataset.side),c=e=>{if(0===e.length)return;const t=e.map(e=>{const t=e.getBoundingClientRect();return{el:e,naturalTop:t.top,height:t.height,currentTop:t.top}});t.sort((e,t)=>e.naturalTop-t.naturalTop);const n=[];let o=[];t.forEach(e=>{if(0===o.length)o.push(e);else{const t=o[o.length-1],r=t.currentTop+t.height;e.naturalTop<r+8?(e.currentTop=r+8,o.push(e)):(n.push(o),o=[e])}}),o.length>0&&n.push(o),n.forEach(e=>{const t=e[e.length-1],n=t.currentTop+t.height;if(n>r){const t=n-r,o=e[0].currentTop-i,l=Math.max(0,Math.min(t,o));e.forEach(e=>{e.currentTop-=l})}}),n.flat().forEach(e=>{const t=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge",`${t}px`)})};if(D&&(l.length>0||a.length>0)){const e=l.filter(e=>"left"===e.dataset.side),t=l.filter(e=>"left"!==e.dataset.side),r=a.filter(e=>"left"===e.dataset.side),i=a.filter(e=>"left"!==e.dataset.side);c(e),c(t),c(r),c(i)}else c(s),c(d)},t=requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})}),r=new ResizeObserver(()=>{requestAnimationFrame(e)});return r.observe(A.current),()=>{r.disconnect(),cancelAnimationFrame(t)}},[P,z,H]),t(i,{ref:A,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0},children:[e(n,{component:"div",sx:L,children:e(h,{components:j,remarkPlugins:E,rehypePlugins:k,children:P.replace(/#{3}/g,"")})}),D&&e(n,{component:"div",sx:X,children:e(h,{components:j,remarkPlugins:E,rehypePlugins:k,children:R})})]})},u);export{C as MemoizedMarkdown};
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|