@viswa-test/test-citation 0.0.320 → 0.0.323
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/README.md +3 -5
- package/dist/cjs/features/CitationRenderer/MarkdownRenderer.module.css.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
- package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfContainer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfStyle.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
- package/dist/cjs/features/PromptemonViewer/PromptemonViewer.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
- package/dist/cjs/hooks/useOnDemandCitationFetch.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/service/onDemandApi.js +1 -1
- package/dist/features/CitationRenderer/MarkdownRenderer.module.css.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitationImageCitation.js +1 -1
- package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
- package/dist/features/PdfViewer/PdfContainer.js +1 -1
- package/dist/features/PdfViewer/PdfStyle.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
- package/dist/features/PromptemonViewer/PromptemonViewer.js +1 -1
- package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
- package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/features/SegmentReviewComponents/helper.js +1 -1
- package/dist/hooks/useOnDemandCitationFetch.js +1 -1
- package/dist/index.js +1 -1
- package/dist/service/onDemandApi.js +1 -1
- package/dist/types/src/PdfViewerTest.d.ts.map +1 -1
- package/dist/types/src/Spbanalysispaneltest.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +12 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +802 -14744
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +1 -0
- package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts +2 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/types.d.ts +11 -0
- package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +2 -0
- package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfContainer.d.ts +3 -5
- package/dist/types/src/features/PdfViewer/PdfContainer.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfStyle.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts +2 -7
- package/dist/types/src/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +2 -26
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/PromptemonBlockViewer/PromptemonBlockViewer.d.ts +2 -15
- package/dist/types/src/features/PromptemonBlockViewer/PromptemonBlockViewer.d.ts.map +1 -1
- package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts +2 -11
- package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts.map +1 -1
- package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts +1 -5
- package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts.map +1 -1
- package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts +1 -80
- package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts.map +1 -1
- package/dist/types/src/features/SPBAnalysisPanel/index.d.ts +1 -1
- package/dist/types/src/features/SPBAnalysisPanel/index.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/SegmentReviewRedirectionTest.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +41 -0
- package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/segmentReviewEdgeCases.test.d.ts +2 -0
- package/dist/types/src/features/SegmentReviewComponents/segmentReviewEdgeCases.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnDemandCitationFetch.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -6
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/service/onDemandApi.d.ts +2 -2
- package/dist/types/src/service/onDemandApi.d.ts.map +1 -1
- package/dist/types/src/types/onDemandApi.types.d.ts +0 -5
- package/dist/types/src/types/onDemandApi.types.d.ts.map +1 -1
- package/package.json +3 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DEVIATION_BADGE_SEPARATOR as e}from"../../CognitiveComparehelpers.js";var i=function(i){var o,l=i.activeIdentifier,
|
|
1
|
+
import{DEVIATION_BADGE_SEPARATOR as e}from"../../CognitiveComparehelpers.js";var i=function(i){var o,l=i.activeIdentifier,t=i.deviationData,r=i.proposedSections,a="",n=null;if("number"==typeof l){var u=r[l],v=(null==u?void 0:u.nodeId)||(null==u?void 0:u.id);a="string"==typeof v?v:""}else if("string"==typeof l){var d=l.split(e);a=d[0]||"",n=d.length>1&&""!==d[1]?d[1]:null}var s=null===(o=null==t?void 0:t[a])||void 0===o?void 0:o.evaluation_result;if(!s||"object"!=typeof s)return{baseNodeId:a,evaluationKey:n,evaluationNodes:[],targetHighlights:[],labelColor:""};var g=null==n?void 0:function(e,i){if(Array.isArray(e)){var o=Number(i);return Number.isInteger(o)?e[o]:void 0}return null==e?void 0:e[i]}(s,n),f=null==n?Object.values(s):g?[g]:[],h=new Set,p=[],c="";return f.forEach(function(e){var i,o,l,t=null===(i=null==e?void 0:e.deviation_highlights)||void 0===i?void 0:i.rulebook_guidelines;if(Array.isArray(t)&&(t.forEach(function(e){if("string"==typeof e&&e.trim()){var i=e.trim().replace(/\s+/g," ").toLocaleLowerCase();h.has(i)||(h.add(i),p.push(e))}}),console.log("LOG: Printing highlights",t,p,h)),!c){var r=null===(l=null===(o=null==e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===l?void 0:l.label_color;"string"==typeof r&&(c=r)}}),{baseNodeId:a,evaluationKey:n,evaluationNodes:f,targetHighlights:p,labelColor:c}};export{i as resolveGuidelineSelection};
|
|
2
2
|
//# sourceMappingURL=resolveGuidelineSelection.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,stripRedlineTags as x,hasSingleMappedLhsSection as m,generateColorPalette as I,getLhsDeviationDisplayIndexes as y,isMissingStr as b,getRhsMappedSectionNumber as w,safeStringify as S,DEVIATION_BADGE_SEPARATOR as R}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as _}from"../CognitiveCompareConstants.js";var F=function(F){var M,k,N,B,C,E,A,O,j,W,T,D,P,K,z,G=F.section,L=F.idx,X=F.columnKey,H=F.colRef,V=F.mb,Y=void 0===V?1:V,q=F.isExpanded,J=F.onToggle,Q=F.navigation,U=F.parentNodeId,Z=void 0===U?"":U,$=p(),nn=$.showOpenNodeRef,en=$.resolvedMarkdownStyles,on=$.maintainRelativeOrder,tn=$.showDeviationBadges,ln=void 0!==tn&&tn,dn=$.renderSubSectionAccordion,rn=$.treeData,an=$.proposedSections,un=$.existingSections,cn=$.deviationNumberRegistry,sn=$.deviationParentRegistry,vn=$.getBadgeRef,fn=$.openSummaryPopup,pn=$.getSectionCompareStyle,hn=$.connectedSections,gn=$.openMoreFunctionsPopup,xn=$.isProposingFix,mn=$.proposingFixNodeId,In=$.isRedlineFlow,yn=$.isSideBySide,bn=$.activeSideBySideSection,wn=$.scrollSyncLocked,Sn=$.unifiedNumbering,Rn=$.toggleScrollSyncLocked,_n=$.summaryPopupAnchorEl,Fn="".concat(yn?"1":"0","-").concat(String(null!=bn?bn:"")),Mn=(null===(M=G.displayTitle)||void 0===M||M)&&h(G.title),kn=!(!xn||!mn||"left"!==X||G.id!==mn&&G.nodeId!==mn),Nn=g(G.content),Bn="boolean"==typeof In?In:Nn,Cn=Nn,En=Bn&&Nn,An=En?x(G.content):G.content,On=En?G.content:void 0,jn=(null===(k=G.displayContent)||void 0===k||k||Nn)&&h(G.content),Wn=!Mn&&!jn,Tn=G.title;Mn||(Tn=jn?"No Title Found":"No Matching Section Found");var Dn="left"===X&&(G.isMultipleMapping||(null!==(B=null===(N=G.refContentIds)||void 0===N?void 0:N.length)&&void 0!==B?B:1)>1),Pn="left"===X&&Tn.length>29?"".concat(Tn.slice(0,29).trimEnd(),"..."):Tn,Kn=G.evaluationResult;if(!Kn&&"right"===X)if(on){var zn=null===(C=G.refIndexes)||void 0===C?void 0:C[0],Gn=an.find(function(n){return n.selfIndex===zn});Kn=null==Gn?void 0:Gn.evaluationResult}else Kn=null===(E=an[L])||void 0===E?void 0:E.evaluationResult;var Ln=null===(A=null==rn?void 0:rn.input_index_map)||void 0===A?void 0:A[0],Xn=null===(O=null==rn?void 0:rn.input_index_map)||void 0===O?void 0:O[1],Hn="left"===X?Xn:Ln,Vn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=Vn(l.subsections,e);if(d)return d}}return null},Yn="left"===X?G:Vn(an,G.id),qn="right"===X?G:Vn(un,G.id),Jn=o.useMemo(function(){if(!on)return 0;var n=1/0,e=function(n){var e=g(n)?x(n):n;return S(e||"").replace(/\\n/g,"\n")},i=function(o,t,l,d){if(o){var r=o.nodeId||o.id;if(d&&"right"===X){var a=an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(r=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var d,a=null===(d=s[i])||void 0===d?void 0:d[Z];if(function(n,i){if("string"!=typeof i||b(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&o.includes(t)}("left"===X?t||o:l||o,a)){var c="".concat(r).concat(R).concat(i),v=null==cn?void 0:cn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(R).concat(i),p=null==cn?void 0:cn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===X?an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(G.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return un.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(G,Yn,qn,!0);return n!==1/0?n-1:0},[G,Yn,qn,X,Z,cn,on,an,un]);if(on)if("left"===X){var Qn=null===(j=G.refIndexes)||void 0===j?void 0:j[0],Un=un.findIndex(function(n){return n.selfIndex===Qn});qn=-1!==Un?un[Un]:Vn(un,G.id)}else{var Zn=null===(W=G.refIndexes)||void 0===W?void 0:W[0],$n=an.findIndex(function(n){return n.selfIndex===Zn});Yn=-1!==$n?an[$n]:Vn(an,G.id)}var ne="left"===X?!qn:!Yn,ee=on&&"right"===X&&m(G,an),ie=Kn||(null==Yn?void 0:Yn.evaluationResult)||(null==qn?void 0:qn.evaluationResult),oe=null!==(P=null===(D=null===(T=null==ie?void 0:ie.evaluation_outputs)||void 0===T?void 0:T.metadata)||void 0===D?void 0:D.label_color)&&void 0!==P?P:_,te=I(oe).highlightBg,le=(null==ie?void 0:ie.deviations)||{},de=o.useMemo(function(){return on&&"right"===X?y(an,Ln,cn):new Map},[on,X,an,Ln,cn]),re=G.nodeId||G.id;if(on&&"left"!==X){var ae=an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(G.selfIndex)});ae.length>0?re=ae[0].nodeId||ae[0].id:(null==Yn?void 0:Yn.id)&&(re=Yn.nodeId||Yn.id)}var ue=o.useMemo(function(){var n,e=new Map;if(!on||"right"!==X)return e;var i=1,o=an.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(G.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return S(n||"").replace(/\\n/g,"\n")},d=function(n,e){var i=e?o[0]:Vn(an,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var r=function(n,e){if(void 0===e&&(e=!1),n){var o=d(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],d=o[Z],r=l(d);if(!!t&&!b(o[Hn])&&r&&c.includes(r)){var a="".concat(u).concat(R).concat(e),s=cn[a];null!=s&&(i=Math.max(i,Math.max(1,s-(Jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return r(n)})}};r(G,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=d(n,o),r=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i=n[0],o=n[1],t=o[Z],d=!r||b(o[Hn]),a=l(t),u=a?v.indexOf(a):-1,s="".concat(c).concat(R).concat(i);return{refId:s,isRenderable:d&&!!a&&!b(t),position:u,registryIndex:null!==(e=cn[s])&&void 0!==e?e:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(G,!0),e},[on,X,G,an,Z,Hn,cn,Jn]),ce=Object.keys(le)[0],se=ce?"".concat(re).concat(R).concat(ce):null,ve=se?null==sn?void 0:sn[se]:null,fe=L+1;if(on&&Sn){var pe="left"===X?Sn.leftNums.get(null==G?void 0:G.id):Sn.rightNums.get(null==G?void 0:G.id);ne&&void 0!==pe?fe=pe:null!=ve&&ve>=0?fe=ve:void 0!==pe&&(fe=pe)}else null!=ve&&ve>=0&&(fe=ve);var he=Object.entries(le).map(function(n){var e=n[0],i=n[1],o="".concat(re).concat(R).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:cn[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});he.sort(function(n,e){return n.currentIndex-e.currentIndex});var ge,xe,me=he.map(function(e){var i,o,t,l,d,r,a=e.deviationKey,u=e.deviationMap,c=e.refId,s=e.currentIndex,v=u[Z],f=b(v);if(f)v="";else if(!v)return null;var p=L,h=L;if(on)if("left"===X){var g=null===(i=G.refIndexes)||void 0===i?void 0:i[0],x=un.findIndex(function(n){return n.selfIndex===g});if(-1!==x)h=x;else{var m=un.findIndex(function(n){return n.id===G.id||n.nodeId===G.nodeId||n.contentId===G.contentId});h=-1!==m?m:L}}else{var y=null===(o=G.refIndexes)||void 0===o?void 0:o[0],S=an.findIndex(function(n){return n.selfIndex===y});if(-1!==S)p=S;else p=-1!==(A=an.findIndex(function(n){return n.id===G.id||n.nodeId===G.nodeId||n.contentId===G.contentId}))?A:L}var _="".concat(re).concat(R).concat(a).concat(R).concat(p).concat(R).concat(h),F=u[Hn],M=ne||b(F),k=ue.get(c),N=de.get(c);on&&"right"===X&&M&&void 0!==k?s=k:on&&"right"===X&&!M&&void 0!==N?s=N:on&&void 0!==Jn&&("right"!==X||M||ee)&&(s-=Jn),s=Math.max(1,s);var B=on&&"right"===X&&M&&Sn?w({section:G,proposedSections:an,leftNums:Sn.leftNums,fallbackNumber:String(fe),firstOnly:!0}):fe,C="".concat(B,".").concat(s),E=L;if("right"===X&&on){var A,O=null===(t=G.refIndexes)||void 0===t?void 0:t[0],j=an.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=an.findIndex(function(n){return n.id===G.id||n.nodeId===G.nodeId||n.contentId===G.contentId}))&&(E=A)}var W=pn?pn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==ie?void 0:ie.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(r=null===(d=null==T?void 0:T.metadata)||void 0===d?void 0:d.label_color)&&void 0!==r?r:oe,K=I(P),z=W?n(n({},W),{badgeBg:K.badgeBg,badgeBorder:K.badgeBorder,badgeText:K.badgeText}):n({},K),H=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==ie?void 0:ie.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==ie?void 0:ie.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==ie?void 0:ie.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==ie?void 0:ie.cognitive_decisioning)}:null,V=0,Y=An||"";if(v&&Y){var q=Y.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(le).filter(function(n){n[0];var e=n[1][Z];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][Z])-q[J].indexOf(e[1][Z])}),U=Q.filter(function(n){n[0];var e=n[1][Z];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(V=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var $=vn(X,c);return{id:c,actionId:_,label:C,highlight:v,side:X,style:z,stackIndex:V,score:D,isConnected:null==hn?void 0:hn.has(_),showScrollLockToggle:(null==hn?void 0:hn.has(_))||yn&&bn===_||!!_n&&_n===$.current,scrollSyncLocked:wn,toggleScrollSyncLocked:Rn,isOrphan:M,isMissingClause:f,badgeRef:$,onClick:function(n){n.stopPropagation(),gn&&gn(n,Yn||{id:"orphan-left",title:"",content:""},M,qn||{id:"orphan-right",title:"",content:""},_,z)},onSummaryClick:function(n){n.stopPropagation(),fn(n,_,M,H)}}}).filter(Boolean),Ie=ln||!Bn&&kn?me:[],ye=me.map(function(n){return n.highlight}).filter(Boolean),be=G.id&&X===(null==Q?void 0:Q.columnKey)?Q:null,we=o.useRef(!1);return t(function(){q||(we.current=!1)},[q]),e(l,n({ref:H,sx:{mb:Y,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[q&&(null==be?void 0:be.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==be?void 0:be.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===X?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===X?{right:"-20px"}:{left:"-20px"})},{children:i(s,{color:(null===(K=null==be?void 0:be.showAboveRef)||void 0===K?void 0:K.current)?window.getComputedStyle(be.showAboveRef.current).color:void 0})}))})),e(d,n({disableGutters:!0,expanded:!Wn&&q,onChange:function(){Wn||(J(),nn.current=G.id)},sx:{boxShadow:"none",border:Wn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Wn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[i(r,n({expandIcon:Wn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Wn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:Mn&&i(a,n({title:Tn,placement:"top"},{children:i(u,n({component:"div",sx:{fontSize:"12px",color:Wn?"#94A3B8":"#19213D",fontWeight:Wn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ge=Pn,xe=Dn,void 0===xe&&(xe=!1),ge?S(ge).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(o,t){return o.startsWith("**")&&o.endsWith("**")?i("strong",{children:o.slice(2,-2)},t):e("div",n({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[i("span",n({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:o})),xe&&i("span",n({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!Wn&&e(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[jn&&i(f,{content:An,overlayContent:On,sxStyles:en,highlights:ye,maintainRelativeOrder:on,highlightBg:te,suppressHighlightBg:Cn,deviationBadges:Ie,collisionKey:Fn}),(G.subsections||[]).map(function(n,e){return dn({section:n,keyPath:"".concat(L,"-").concat(e),depth:0,columnKey:X,parentNodeId:Z,sectionOffset:Jn,rhsOrphanVisualIndexes:ue})})]}))]})),q&&(null==be?void 0:be.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==be?void 0:be.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===X?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===X?{right:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(z=null==be?void 0:be.showBelowRef)||void 0===z?void 0:z.current)?window.getComputedStyle(be.showBelowRef.current).color:void 0})}))}))]}),"".concat(X,"-sec-").concat(L))};export{F as default};
|
|
1
|
+
import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import t,{useEffect as l}from"react";import{Box as r,Accordion as d,AccordionSummary as a,Tooltip as u,Typography as c,AccordionDetails as s}from"@mui/material";import{ChevronUp as v,ChevronDown as f}from"lucide-react";import{MemoizedMarkdown as p}from"../hooks/memoizedMarkdown.js";import{useCompareContext as h}from"../CompareContext.js";import{hasValue as g,hasMeaningfulRedlineTags as m,safeStringify as x,stripRedlineTags as I,hasSingleMappedLhsSection as y,generateColorPalette as b,getLhsDeviationDisplayIndexes as w,DEVIATION_BADGE_SEPARATOR as S,isMissingStr as R,getRhsMappedSectionNumber as M,findTextMatchRange as _}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as F}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as k}from"../utils/normalizeRedlineMarkdown.js";var N=function(N){var B,C,E,A,O,j,W,T,D,P,z,K,G,L,X,H=N.section,V=N.idx,Y=N.columnKey,q=N.colRef,J=N.mb,Q=void 0===J?1:J,U=N.isExpanded,Z=N.onToggle,$=N.navigation,nn=N.parentNodeId,en=void 0===nn?"":nn,on=h(),tn=on.showOpenNodeRef,ln=on.resolvedMarkdownStyles,rn=on.maintainRelativeOrder,dn=on.showDeviationBadges,an=void 0!==dn&&dn,un=on.renderSubSectionAccordion,cn=on.treeData,sn=on.proposedSections,vn=on.existingSections,fn=on.deviationNumberRegistry,pn=on.deviationParentRegistry,hn=on.getBadgeRef,gn=on.openSummaryPopup,mn=on.getSectionCompareStyle,xn=on.connectedSections,In=on.openMoreFunctionsPopup,yn=on.isProposingFix,bn=on.proposingFixNodeId,wn=on.isRedlineFlow,Sn=on.isSideBySide,Rn=on.activeSideBySideSection,Mn=on.scrollSyncLocked,_n=on.unifiedNumbering,Fn=on.toggleScrollSyncLocked,kn=on.summaryPopupAnchorEl,Nn="".concat(Sn?"1":"0","-").concat(String(null!=Rn?Rn:"")),Bn=(null===(B=H.displayTitle)||void 0===B||B)&&g(H.title),Cn=!(!yn||!bn||"left"!==Y||H.id!==bn&&H.nodeId!==bn),En=m(H.content),An="boolean"==typeof wn?wn:En,On=En,jn=An&&En,Wn=t.useMemo(function(){return jn?k(x(H.content)):x(H.content)},[H.content,jn]),Tn=jn?I(Wn):H.content,Dn=jn?Wn:void 0,Pn=(null===(C=H.displayContent)||void 0===C||C||En)&&g(H.content),zn=!Bn&&!Pn,Kn=H.title;Bn||(Kn=Pn?"No Title Found":"No Matching Section Found");var Gn="left"===Y&&(H.isMultipleMapping||(null!==(A=null===(E=H.refContentIds)||void 0===E?void 0:E.length)&&void 0!==A?A:1)>1),Ln="left"===Y&&Kn.length>29?"".concat(Kn.slice(0,29).trimEnd(),"..."):Kn,Xn=H.evaluationResult;if(!Xn&&"right"===Y)if(rn){var Hn=null===(O=H.refIndexes)||void 0===O?void 0:O[0],Vn=sn.find(function(n){return n.selfIndex===Hn});Xn=null==Vn?void 0:Vn.evaluationResult}else Xn=null===(j=sn[V])||void 0===j?void 0:j.evaluationResult;var Yn=null===(W=null==cn?void 0:cn.input_index_map)||void 0===W?void 0:W[0],qn=null===(T=null==cn?void 0:cn.input_index_map)||void 0===T?void 0:T[1],Jn="left"===Y?qn:Yn,Qn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Qn(l.subsections,e);if(r)return r}}return null},Un="left"===Y?H:Qn(sn,H.id),Zn="right"===Y?H:Qn(vn,H.id),$n=t.useMemo(function(){if(!rn)return 0;var n=1/0,e=function(n){var e=x(n||"").replace(/\\n/g,"\n");return m(e)?I(k(e)):e},i=function(o,t,l,r){if(o){var d=o.nodeId||o.id;if(r&&"right"===Y){var a=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(d=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var r,a=null===(r=s[i])||void 0===r?void 0:r[en];if(function(n,i){if("string"!=typeof i||R(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&!!_(o,t)}("left"===Y?t||o:l||o,a)){var c="".concat(d).concat(S).concat(i),v=null==fn?void 0:fn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(S).concat(i),p=null==fn?void 0:fn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===Y?sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return vn.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(H,Un,Zn,!0);return n!==1/0?n-1:0},[H,Un,Zn,Y,en,fn,rn,sn,vn]);if(rn)if("left"===Y){var ne=null===(D=H.refIndexes)||void 0===D?void 0:D[0],ee=vn.findIndex(function(n){return n.selfIndex===ne});Zn=-1!==ee?vn[ee]:Qn(vn,H.id)}else{var ie=null===(P=H.refIndexes)||void 0===P?void 0:P[0],oe=sn.findIndex(function(n){return n.selfIndex===ie});Un=-1!==oe?sn[oe]:Qn(sn,H.id)}var te="left"===Y?!Zn:!Un,le=rn&&"right"===Y&&y(H,sn),re=Xn||(null==Un?void 0:Un.evaluationResult)||(null==Zn?void 0:Zn.evaluationResult),de=null!==(G=null===(K=null===(z=null==re?void 0:re.evaluation_outputs)||void 0===z?void 0:z.metadata)||void 0===K?void 0:K.label_color)&&void 0!==G?G:F,ae=b(de).highlightBg,ue=(null==re?void 0:re.deviations)||{},ce=t.useMemo(function(){return rn&&"right"===Y?w(sn,Yn,fn):new Map},[rn,Y,sn,Yn,fn]),se=H.nodeId||H.id;if(rn&&"left"!==Y){var ve=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)});ve.length>0?se=ve[0].nodeId||ve[0].id:(null==Un?void 0:Un.id)&&(se=Un.nodeId||Un.id)}var fe=t.useMemo(function(){var n,e=new Map;if(!rn||"right"!==Y)return e;var i=1,o=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return x(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?o[0]:Qn(sn,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var d=function(n,e){if(void 0===e&&(e=!1),n){var o=r(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],r=o[en],d=l(r);if(!!t&&!R(o[Jn])&&d&&_(c,d)){var a="".concat(u).concat(S).concat(e),s=fn[a];null!=s&&(i=Math.max(i,Math.max(1,s-($n||0))+1))}}),(n.subsections||[]).forEach(function(n){return d(n)})}};d(H,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=r(n,o),d=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i,o,t=n[0],r=n[1],a=r[en],u=!d||R(r[Jn]),s=l(a),f=s&&null!==(i=null===(e=_(v,s))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(S).concat(t);return{refId:p,isRenderable:u&&!!s&&!R(a),position:f,registryIndex:null!==(o=fn[p])&&void 0!==o?o:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(H,!0),e},[rn,Y,H,sn,en,Jn,fn,$n]),pe=Object.keys(ue)[0],he=pe?"".concat(se).concat(S).concat(pe):null,ge=he?null==pn?void 0:pn[he]:null,me=V+1;if(rn&&_n){var xe="left"===Y?_n.leftNums.get(null==H?void 0:H.id):_n.rightNums.get(null==H?void 0:H.id);te&&void 0!==xe?me=xe:null!=ge&&ge>=0?me=ge:void 0!==xe&&(me=xe)}else null!=ge&&ge>=0&&(me=ge);var Ie=Math.max.apply(Math,n([0],Object.keys(ue).map(function(n){return fn["".concat(se).concat(S).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,ye=Object.entries(ue).map(function(n){var e,i=n[0],o=n[1],t="".concat(se).concat(S).concat(i);return{deviationKey:i,deviationMap:o,refId:t,currentIndex:null!==(e=fn[t])&&void 0!==e?e:Ie++}});ye.sort(function(n,e){return n.currentIndex-e.currentIndex});var be,we,Se=ye.map(function(n){var i,o,t,l,r,d,a=n.deviationKey,u=n.deviationMap,c=n.refId,s=n.currentIndex,v=u[en],f=R(v);if(f)v="";else if(!v)return null;var p=V,h=V;if(rn)if("left"===Y){var g=null===(i=H.refIndexes)||void 0===i?void 0:i[0],m=vn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var x=vn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId});h=-1!==x?x:V}}else{var I=null===(o=H.refIndexes)||void 0===o?void 0:o[0],y=sn.findIndex(function(n){return n.selfIndex===I});if(-1!==y)p=y;else p=-1!==(A=sn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId}))?A:V}var w="".concat(se).concat(S).concat(a).concat(S).concat(p).concat(S).concat(h),_=u[Jn],F=te||R(_),k=fe.get(c),N=ce.get(c);rn&&"right"===Y&&F&&void 0!==k?s=k:rn&&"right"===Y&&!F&&void 0!==N?s=N:rn&&void 0!==$n&&("right"!==Y||F||le)&&(s-=$n),s=Math.max(1,s);var B=rn&&"right"===Y&&F&&_n?M({section:H,proposedSections:sn,leftNums:_n.leftNums,fallbackNumber:String(me),firstOnly:!0}):me,C="".concat(B,".").concat(s),E=V;if("right"===Y&&rn){var A,O=null===(t=H.refIndexes)||void 0===t?void 0:t[0],j=sn.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=sn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId}))&&(E=A)}var W=mn?mn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==re?void 0:re.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(d=null===(r=null==T?void 0:T.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:de,z=b(P),K=W?e(e({},W),{badgeBg:z.badgeBg,badgeBorder:z.badgeBorder,badgeText:z.badgeText}):e({},z),G=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==re?void 0:re.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==re?void 0:re.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==re?void 0:re.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==re?void 0:re.cognitive_decisioning)}:null,L=0,X=Tn||"";if(v&&X){var q=X.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(ue).filter(function(n){n[0];var e=n[1][en];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][en])-q[J].indexOf(e[1][en])}),U=Q.filter(function(n){n[0];var e=n[1][en];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(L=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var Z=hn(Y,c);return{id:c,actionId:w,label:C,highlight:v,side:Y,style:K,stackIndex:L,score:D,isConnected:null==xn?void 0:xn.has(w),showScrollLockToggle:(null==xn?void 0:xn.has(w))||Sn&&Rn===w||!!kn&&kn===Z.current,scrollSyncLocked:Mn,toggleScrollSyncLocked:Fn,isOrphan:F,isMissingClause:f,badgeRef:Z,onClick:function(n){n.stopPropagation(),In&&In(n,Un||{id:"orphan-left",title:"",content:""},F,Zn||{id:"orphan-right",title:"",content:""},w,K)},onSummaryClick:function(n){n.stopPropagation(),gn(n,w,F,G)}}}).filter(Boolean),Re=an||!An&&Cn?Se:[],Me=Se.map(function(n){return n.highlight}).filter(Boolean),_e=H.id&&Y===(null==$?void 0:$.columnKey)?$:null,Fe=t.useRef(!1);return l(function(){U||(Fe.current=!1)},[U]),i(r,e({ref:q,sx:{mb:Q,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[U&&(null==_e?void 0:_e.showAbove)&&o("div",e({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==_e?void 0:_e.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===Y?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===Y?{right:"-20px"}:{left:"-20px"})},{children:o(v,{color:(null===(L=null==_e?void 0:_e.showAboveRef)||void 0===L?void 0:L.current)?window.getComputedStyle(_e.showAboveRef.current).color:void 0})}))})),i(d,e({disableGutters:!0,expanded:!zn&&U,onChange:function(){zn||(Z(),tn.current=H.id)},sx:{boxShadow:"none",border:zn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:zn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[o(a,e({expandIcon:zn?null:o(f,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:zn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:Bn&&o(u,e({title:Kn,placement:"top"},{children:o(c,e({component:"div",sx:{fontSize:"12px",color:zn?"#94A3B8":"#19213D",fontWeight:zn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(be=Ln,we=Gn,void 0===we&&(we=!1),be?x(be).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,t){return n.startsWith("**")&&n.endsWith("**")?o("strong",{children:n.slice(2,-2)},t):i("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[o("span",e({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:n})),we&&o("span",e({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!zn&&i(s,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Pn&&o(p,{content:Tn,overlayContent:Dn,sxStyles:ln,highlights:Me,maintainRelativeOrder:rn,highlightBg:ae,suppressHighlightBg:On,deviationBadges:Re,collisionKey:Nn}),(H.subsections||[]).map(function(n,e){return un({section:n,keyPath:"".concat(V,"-").concat(e),depth:0,columnKey:Y,parentNodeId:en,sectionOffset:$n,rhsOrphanVisualIndexes:fe})})]}))]})),U&&(null==_e?void 0:_e.showBelow)&&o("div",e({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==_e?void 0:_e.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===Y?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===Y?{right:"-20px"}:{left:"-20px"})},{children:o(f,{color:(null===(X=null==_e?void 0:_e.showBelowRef)||void 0===X?void 0:X.current)?window.getComputedStyle(_e.showBelowRef.current).color:void 0})}))}))]}),"".concat(Y,"-sec-").concat(V))};export{N as default};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t,{useMemo as o}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Typography as a,AccordionDetails as u}from"@mui/material";import{ChevronDown as c}from"lucide-react";import{MemoizedMarkdown as s}from"../hooks/memoizedMarkdown.js";import{useCompareContext as v}from"../CompareContext.js";import{hasValue as f,hasMeaningfulRedlineTags as p,stripRedlineTags as h,hasSingleMappedLhsSection as m,getLhsDeviationDisplayIndexes as g,generateColorPalette as x,safeStringify as y,isMissingStr as S,getRhsMappedSectionNumber as I,DEVIATION_BADGE_SEPARATOR as b}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as _}from"../CognitiveCompareConstants.js";var k=t.memo(function(t){var w,C,F,O,P,N,B,M,R,E,j=t.section,A=t.keyPath,K=t.depth,W=void 0===K?0:K,L=t.columnKey,T=void 0===L?"left":L,z=t.parentNodeId,D=void 0===z?"":z,G=t.sectionOffset,H=t.rhsOrphanVisualIndexes,V=v(),X=V.expandedSubSections,U=V.setExpandedSubSections,q=V.maintainRelativeOrder,J=V.showDeviationBadges,Q=void 0!==J&&J,Y=V.proposedSections,Z=V.existingSections,$=V.treeData,nn=V.deviationNumberRegistry,en=V.deviationParentRegistry,tn=V.connectedSections,on=V.activeSideBySideSection,ln=V.isSideBySide,dn=V.scrollSyncLocked,rn=V.toggleScrollSyncLocked,an=V.summaryPopupAnchorEl,un=V.resolvedMarkdownStyles,cn=V.getSubSectionRef,sn=V.getSubSectionCompareStyle,vn=V.getBadgeRef,fn=V.openMoreFunctionsPopup,pn=V.openSummaryPopup,hn=V.resetSideBySide,mn=V.setConnectedSections,gn=V.setConnectedLines,xn=V.cachedConnectedPositions,yn=V.isProposingFix,Sn=V.proposingFixNodeId,In=V.isRedlineFlow,bn=V.unifiedNumbering,_n=null!=on?on:"",kn=(null===(w=j.displayTitle)||void 0===w||w)&&f(j.title),wn=!(!yn||!Sn||"left"!==T||j.id!==Sn&&j.nodeId!==Sn),Cn=p(j.content),Fn="boolean"==typeof In?In:Cn,On=Cn,Pn=Fn&&Cn,Nn=Pn?h(j.content):j.content,Bn=Pn?j.content:void 0,Mn=(null===(C=j.displayContent)||void 0===C||C||Cn)&&f(j.content),Rn=!kn&&!Mn,En=kn?j.title:Mn?"No Title Found":"No Matching Section Found",jn=!!X[A],An=cn(T,A),Kn=A.split("-").map(Number)[0],Wn=Y[Kn],Ln=Z[Kn],Tn=Kn,zn=Kn,Dn=!1,Gn=function(n,i,e){if(!n||!i)return null;if(n.id===i||n.nodeId===i||n.contentId===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i||n.section.nodeId===i||n.section.contentId===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(q)if("left"===T){var Hn=null===(F=null==Wn?void 0:Wn.refIndexes)||void 0===F?void 0:F[0],Vn=Z.findIndex(function(n){return n.selfIndex===Hn});-1!==Vn?(Ln=Z[Vn],zn=Vn):Dn=!0}else{var Xn=null===(O=null==Ln?void 0:Ln.refIndexes)||void 0===O?void 0:O[0],Un=Y.findIndex(function(n){return n.selfIndex===Xn});-1!==Un?(Wn=Y[Un],Tn=Un):Dn=!0}var qn=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Gn(n[e],i,String(e));if(t)return t}return null},Jn=null,Qn=null,Yn="",Zn="";if(q)"left"===T?(Jn=j,Yn=A,($n=Gn(Ln,j.nodeId||j.id,String(zn)))||($n=qn(Z,j.nodeId||j.id)),Qn=(null==$n?void 0:$n.section)||null,Zn=(null==$n?void 0:$n.keyPath)||""):(Qn=j,Zn=A,(ni=Gn(Wn,j.nodeId||j.id,String(Tn)))||(ni=qn(Y,j.nodeId||j.id)),Jn=(null==ni?void 0:ni.section)||null,Yn=(null==ni?void 0:ni.keyPath)||"");else if("left"===T){Jn=j,Yn=A;var $n=qn(Z,j.nodeId||j.id);Qn=(null==$n?void 0:$n.section)||null,Zn=(null==$n?void 0:$n.keyPath)||""}else{Qn=j,Zn=A;var ni=qn(Y,j.nodeId||j.id);Jn=(null==ni?void 0:ni.section)||null,Yn=(null==ni?void 0:ni.keyPath)||""}var ii=(Yn?sn(Yn):null)||sn(A),ei=null===(P=null==$?void 0:$.input_index_map)||void 0===P?void 0:P[0],ti=null===(N=null==$?void 0:$.input_index_map)||void 0===N?void 0:N[1],oi="left"===T?ti:ei,li="left"===T?!Qn:!Jn,di=q&&"right"===T&&m(Ln,Y),ri=j.evaluationResult||(null==Jn?void 0:Jn.evaluationResult)||(null==Qn?void 0:Qn.evaluationResult),ai=(null==ri?void 0:ri.deviations)||{},ui=o(function(){return q&&"right"===T?g(Y,ei,nn):new Map},[q,T,Y,ei,nn]),ci=j.nodeId||j.id||(null==Jn?void 0:Jn.nodeId)||(null==Jn?void 0:Jn.id)||(null==Qn?void 0:Qn.nodeId)||(null==Qn?void 0:Qn.id);q&&"left"!==T&&(null==Jn?void 0:Jn.id)&&(ci=Jn.nodeId||Jn.id);var si=Object.keys(ai)[0],vi=si?"".concat(ci).concat(b).concat(si):null,fi=vi?null==en?void 0:en[vi]:null,pi=Kn+1;if(q&&bn){var hi="left"===T?bn.leftNums.get(null==Wn?void 0:Wn.id):bn.rightNums.get(null==Ln?void 0:Ln.id);Dn&&void 0!==hi?pi=hi:null!=fi&&fi>=0?pi=fi:void 0!==hi&&(pi=hi)}else null!=fi&&fi>=0&&(pi=fi);var mi=null!==(R=null===(M=null===(B=null==ri?void 0:ri.evaluation_outputs)||void 0===B?void 0:B.metadata)||void 0===M?void 0:M.label_color)&&void 0!==R?R:_,gi=x(mi).highlightBg,xi=Object.entries(ai).map(function(n){var i=n[0],e=n[1],t="".concat(ci).concat(b).concat(i);return{deviationKey:i,deviationMap:e,refId:t,currentIndex:nn[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});xi.sort(function(n,i){return n.currentIndex-i.currentIndex});var yi=new Map;if(!H&&q&&"right"===T){var Si=y(Nn||"").replace(/\\n/g,"\n");xi.filter(function(n){var i=n.deviationMap,e=i[D];return(li||S(i[oi]))&&!!e&&!S(e)}).map(function(i){var e=y(i.deviationMap[D]||"").replace(/\\n/g,"\n"),t=e?Si.indexOf(e):-1;return n(n({},i),{position:t})}).sort(function(n,i){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===i.position?Number.MAX_SAFE_INTEGER:i.position)||n.currentIndex-i.currentIndex}).forEach(function(n,i){yi.set(n.refId,i+1)})}var Ii=xi.map(function(i){var e,t,o,l,d=i.deviationKey,r=i.deviationMap,a=i.refId,u=i.currentIndex,c=r[D],s=S(c);if(s)c="";else if(!c)return null;var v=r[oi],f=li||S(v),p=null!==(e=null==H?void 0:H.get(a))&&void 0!==e?e:yi.get(a),h=ui.get(a);q&&"right"===T&&f&&void 0!==p?u=p:q&&"right"===T&&!f&&void 0!==h?u=h:q&&void 0!==G&&("right"!==T||f||di)&&(u-=G),u=Math.max(1,u);var m=q&&"right"===T&&f&&bn?I({section:Ln,proposedSections:Y,leftNums:bn.leftNums,fallbackNumber:String(pi),firstOnly:!0}):pi,g="".concat(m,".").concat(u),y="".concat(ci).concat(b).concat(d).concat(b).concat(Yn).concat(b).concat(Zn),_=(null==r?void 0:r.evaluation_outputs)||(null==ri?void 0:ri.evaluation_outputs),k=null!==(t=null==_?void 0:_.output_value)&&void 0!==t?t:null,w=null!==(l=null===(o=null==_?void 0:_.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:mi,C=x(w),F=n({},C),O=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==ri?void 0:ri.deviation_summary),deviation_title:(null==r?void 0:r.deviation_title)||(null==ri?void 0:ri.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==ri?void 0:ri.deviation_impact),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==ri?void 0:ri.deviation_explanation),evaluation_outputs:_,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==ri?void 0:ri.cognitive_decisioning)}:null,P=0,N=Nn||"";if(c&&N){var B=N.split(/\n{2,}/),M=B.findIndex(function(n){return n.includes(c)});if(-1!==M){var R=Object.entries(ai).filter(function(n){n[0];var i=n[1][D];return i&&B[M].includes(i)}).sort(function(n,i){return B[M].indexOf(n[1][D])-B[M].indexOf(i[1][D])}),E=R.filter(function(n){n[0];var i=n[1][D];return i&&(i.includes(c)||c.includes(i))});E.length>1&&(P=Math.max(0,E.findIndex(function(n){return n[0]===d})))}}var j=vn(T,a);return{id:a,actionId:y,label:g,highlight:c,side:T,style:F,stackIndex:P,score:k,isConnected:tn.has(y),showScrollLockToggle:tn.has(y)||ln&&on===y||!!an&&an===j.current,scrollSyncLocked:dn,toggleScrollSyncLocked:rn,isOrphan:f,isMissingClause:s,badgeRef:j,onClick:function(i){i.stopPropagation();var e=Jn?n(n({},Jn),{title:(null==Wn?void 0:Wn.title)||(null==Jn?void 0:Jn.title)||""}):{id:"orphan-left",title:"",content:""},t=Qn?n(n({},Qn),{title:(null==Ln?void 0:Ln.title)||(null==Qn?void 0:Qn.title)||""}):{id:"orphan-right",title:"",content:""};fn(i,e,f,t,y,F)},onSummaryClick:function(n){n.stopPropagation(),pn(n,y,f,O)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),bi=o(function(){var n=new Set;return Ii.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[Ii]),_i=Q||!Fn&&wn?bi:[],ki=bi.map(function(n){return n.highlight}).filter(Boolean),wi=Ii.find(function(n){return tn.has(n.actionId)}),Ci=!!wi;if(!(kn||Mn||j.subsections&&0!==j.subsections.length))return null;var Fi=(null===(E=null==wi?void 0:wi.style)||void 0===E?void 0:E.badgeBorder)||(null==ii?void 0:ii.badgeBorder),Oi=Ci&&Fi?{borderRadius:"4px",outline:"2px solid ".concat(Fi),outlineOffset:"1px"}:{};return i(l,kn?n({ref:An,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(l,n({sx:n({width:"100%"},Oi)},{children:e(d,n({disableGutters:!0,expanded:!Rn&&jn,onChange:function(){if(!Rn){if(jn){var i=String(on||""),e=i.includes(Yn)||i.includes(Zn);e||tn.forEach(function(n){(String(n).includes(Yn)||String(n).includes(Zn))&&(e=!0)}),e&&(hn(),mn(new Set),gn([]),xn.current=[])}U(function(i){var e;return n(n({},i),((e={})[A]=!i[A],e))})}},sx:{mt:0,boxShadow:"none",border:Rn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(r,n({expandIcon:Rn?null:i(c,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(a,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Rn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:En||"Untitled Subsection"}))})),!Rn&&e(u,n({sx:{pt:0,pb:1,minWidth:0}},{children:[Mn&&i(s,{content:Nn,overlayContent:Bn,sxStyles:un,deviationBadges:_i,maintainRelativeOrder:q,highlightBg:gi,suppressHighlightBg:On,highlights:ki,collisionKey:_n}),(j.subsections||[]).map(function(n,e){return i(k,{section:n,keyPath:"".concat(A,"-").concat(e),depth:W+1,columnKey:T,parentNodeId:D,sectionOffset:G,rhsOrphanVisualIndexes:H},"".concat(A,"-").concat(e))})]}))]}))}))}):n({ref:An,sx:{mt:0===W?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Rn&&e(l,n({sx:n({width:"100%"},Oi)},{children:[Mn&&i(s,{content:Nn,overlayContent:Bn,sxStyles:un,deviationBadges:_i,maintainRelativeOrder:q,highlightBg:gi,suppressHighlightBg:On,highlights:ki,collisionKey:_n}),(j.subsections||[]).map(function(n,e){return i(k,{section:n,keyPath:"".concat(A,"-").concat(e),depth:W+1,columnKey:T,parentNodeId:D,sectionOffset:G,rhsOrphanVisualIndexes:H},"".concat(A,"-").concat(e))})]}))}))});export{k as default};
|
|
1
|
+
import{__spreadArray as n,__assign as i}from"tslib";import{jsx as e,jsxs as t}from"react/jsx-runtime";import o,{useMemo as l}from"react";import{Box as d,Accordion as r,AccordionSummary as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as v}from"../hooks/memoizedMarkdown.js";import{useCompareContext as f}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,safeStringify as m,stripRedlineTags as g,hasSingleMappedLhsSection as x,getLhsDeviationDisplayIndexes as y,generateColorPalette as S,DEVIATION_BADGE_SEPARATOR as I,isMissingStr as b,findTextMatchRange as _,getRhsMappedSectionNumber as k}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as N}from"../utils/normalizeRedlineMarkdown.js";var F=o.memo(function(o){var C,M,O,P,B,R,E,j,A,K,W=o.section,L=o.keyPath,T=o.depth,z=void 0===T?0:T,D=o.columnKey,G=void 0===D?"left":D,H=o.parentNodeId,V=void 0===H?"":H,X=o.sectionOffset,U=o.rhsOrphanVisualIndexes,q=f(),J=q.expandedSubSections,Q=q.setExpandedSubSections,Y=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.proposedSections,en=q.existingSections,tn=q.treeData,on=q.deviationNumberRegistry,ln=q.deviationParentRegistry,dn=q.connectedSections,rn=q.activeSideBySideSection,an=q.isSideBySide,un=q.scrollSyncLocked,cn=q.toggleScrollSyncLocked,sn=q.summaryPopupAnchorEl,vn=q.resolvedMarkdownStyles,fn=q.getSubSectionRef,pn=q.getSubSectionCompareStyle,hn=q.getBadgeRef,mn=q.openMoreFunctionsPopup,gn=q.openSummaryPopup,xn=q.resetSideBySide,yn=q.setConnectedSections,Sn=q.setConnectedLines,In=q.cachedConnectedPositions,bn=q.isProposingFix,_n=q.proposingFixNodeId,kn=q.isRedlineFlow,wn=q.unifiedNumbering,Nn=null!=rn?rn:"",Fn=(null===(C=W.displayTitle)||void 0===C||C)&&p(W.title),Cn=!(!bn||!_n||"left"!==G||W.id!==_n&&W.nodeId!==_n),Mn=h(W.content),On="boolean"==typeof kn?kn:Mn,Pn=Mn,Bn=On&&Mn,Rn=l(function(){return Bn?N(m(W.content)):m(W.content)},[W.content,Bn]),En=Bn?g(Rn):W.content,jn=Bn?Rn:void 0,An=(null===(M=W.displayContent)||void 0===M||M||Mn)&&p(W.content),Kn=!Fn&&!An,Wn=Fn?W.title:An?"No Title Found":"No Matching Section Found",Ln=!!J[L],Tn=fn(G,L),zn=L.split("-").map(Number)[0],Dn=nn[zn],Gn=en[zn],Hn=zn,Vn=zn,Xn=!1,Un=function(n,i,e){if(!n||!i)return null;if(n.id===i||n.nodeId===i||n.contentId===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i||n.section.nodeId===i||n.section.contentId===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(Y)if("left"===G){var qn=null===(O=null==Dn?void 0:Dn.refIndexes)||void 0===O?void 0:O[0],Jn=en.findIndex(function(n){return n.selfIndex===qn});-1!==Jn?(Gn=en[Jn],Vn=Jn):Xn=!0}else{var Qn=null===(P=null==Gn?void 0:Gn.refIndexes)||void 0===P?void 0:P[0],Yn=nn.findIndex(function(n){return n.selfIndex===Qn});-1!==Yn?(Dn=nn[Yn],Hn=Yn):Xn=!0}var Zn=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Un(n[e],i,String(e));if(t)return t}return null},$n=null,ni=null,ii="",ei="";if(Y)"left"===G?($n=W,ii=L,(ti=Un(Gn,W.nodeId||W.id,String(Vn)))||(ti=Zn(en,W.nodeId||W.id)),ni=(null==ti?void 0:ti.section)||null,ei=(null==ti?void 0:ti.keyPath)||""):(ni=W,ei=L,(oi=Un(Dn,W.nodeId||W.id,String(Hn)))||(oi=Zn(nn,W.nodeId||W.id)),$n=(null==oi?void 0:oi.section)||null,ii=(null==oi?void 0:oi.keyPath)||"");else if("left"===G){$n=W,ii=L;var ti=Zn(en,W.nodeId||W.id);ni=(null==ti?void 0:ti.section)||null,ei=(null==ti?void 0:ti.keyPath)||""}else{ni=W,ei=L;var oi=Zn(nn,W.nodeId||W.id);$n=(null==oi?void 0:oi.section)||null,ii=(null==oi?void 0:oi.keyPath)||""}var li=(ii?pn(ii):null)||pn(L),di=null===(B=null==tn?void 0:tn.input_index_map)||void 0===B?void 0:B[0],ri=null===(R=null==tn?void 0:tn.input_index_map)||void 0===R?void 0:R[1],ai="left"===G?ri:di,ui="left"===G?!ni:!$n,ci=Y&&"right"===G&&x(Gn,nn),si=W.evaluationResult||(null==$n?void 0:$n.evaluationResult)||(null==ni?void 0:ni.evaluationResult),vi=(null==si?void 0:si.deviations)||{},fi=l(function(){return Y&&"right"===G?y(nn,di,on):new Map},[Y,G,nn,di,on]),pi=W.nodeId||W.id||(null==$n?void 0:$n.nodeId)||(null==$n?void 0:$n.id)||(null==ni?void 0:ni.nodeId)||(null==ni?void 0:ni.id);Y&&"left"!==G&&(null==$n?void 0:$n.id)&&(pi=$n.nodeId||$n.id);var hi=Object.keys(vi)[0],mi=hi?"".concat(pi).concat(I).concat(hi):null,gi=mi?null==ln?void 0:ln[mi]:null,xi=zn+1;if(Y&&wn){var yi="left"===G?wn.leftNums.get(null==Dn?void 0:Dn.id):wn.rightNums.get(null==Gn?void 0:Gn.id);Xn&&void 0!==yi?xi=yi:null!=gi&&gi>=0?xi=gi:void 0!==yi&&(xi=yi)}else null!=gi&&gi>=0&&(xi=gi);var Si=null!==(A=null===(j=null===(E=null==si?void 0:si.evaluation_outputs)||void 0===E?void 0:E.metadata)||void 0===j?void 0:j.label_color)&&void 0!==A?A:w,Ii=S(Si).highlightBg,bi=Math.max.apply(Math,n([0],Object.keys(vi).map(function(n){return on["".concat(pi).concat(I).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,_i=Object.entries(vi).map(function(n){var i,e=n[0],t=n[1],o="".concat(pi).concat(I).concat(e);return{deviationKey:e,deviationMap:t,refId:o,currentIndex:null!==(i=on[o])&&void 0!==i?i:bi++}});_i.sort(function(n,i){return n.currentIndex-i.currentIndex});var ki=new Map;if(!U&&Y&&"right"===G){var wi=m(En||"").replace(/\\n/g,"\n");_i.filter(function(n){var i=n.deviationMap,e=i[V];return(ui||b(i[ai]))&&!!e&&!b(e)}).map(function(n){var e,t,o=m(n.deviationMap[V]||"").replace(/\\n/g,"\n"),l=o&&null!==(t=null===(e=_(wi,o))||void 0===e?void 0:e.start)&&void 0!==t?t:-1;return i(i({},n),{position:l})}).sort(function(n,i){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===i.position?Number.MAX_SAFE_INTEGER:i.position)||n.currentIndex-i.currentIndex}).forEach(function(n,i){ki.set(n.refId,i+1)})}var Ni=_i.map(function(n){var e,t,o,l,d=n.deviationKey,r=n.deviationMap,a=n.refId,u=n.currentIndex,c=r[V],s=b(c);if(s)c="";else if(!c)return null;var v=r[ai],f=ui||b(v),p=null!==(e=null==U?void 0:U.get(a))&&void 0!==e?e:ki.get(a),h=fi.get(a);Y&&"right"===G&&f&&void 0!==p?u=p:Y&&"right"===G&&!f&&void 0!==h?u=h:Y&&void 0!==X&&("right"!==G||f||ci)&&(u-=X),u=Math.max(1,u);var m=Y&&"right"===G&&f&&wn?k({section:Gn,proposedSections:nn,leftNums:wn.leftNums,fallbackNumber:String(xi),firstOnly:!0}):xi,g="".concat(m,".").concat(u),x="".concat(pi).concat(I).concat(d).concat(I).concat(ii).concat(I).concat(ei),y=(null==r?void 0:r.evaluation_outputs)||(null==si?void 0:si.evaluation_outputs),_=null!==(t=null==y?void 0:y.output_value)&&void 0!==t?t:null,w=null!==(l=null===(o=null==y?void 0:y.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:Si,N=S(w),F=i({},N),C=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==si?void 0:si.deviation_summary),deviation_title:(null==r?void 0:r.deviation_title)||(null==si?void 0:si.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==si?void 0:si.deviation_impact),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==si?void 0:si.deviation_explanation),evaluation_outputs:y,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==si?void 0:si.cognitive_decisioning)}:null,M=0,O=En||"";if(c&&O){var P=O.split(/\n{2,}/),B=P.findIndex(function(n){return n.includes(c)});if(-1!==B){var R=Object.entries(vi).filter(function(n){n[0];var i=n[1][V];return i&&P[B].includes(i)}).sort(function(n,i){return P[B].indexOf(n[1][V])-P[B].indexOf(i[1][V])}),E=R.filter(function(n){n[0];var i=n[1][V];return i&&(i.includes(c)||c.includes(i))});E.length>1&&(M=Math.max(0,E.findIndex(function(n){return n[0]===d})))}}var j=hn(G,a);return{id:a,actionId:x,label:g,highlight:c,side:G,style:F,stackIndex:M,score:_,isConnected:dn.has(x),showScrollLockToggle:dn.has(x)||an&&rn===x||!!sn&&sn===j.current,scrollSyncLocked:un,toggleScrollSyncLocked:cn,isOrphan:f,isMissingClause:s,badgeRef:j,onClick:function(n){n.stopPropagation();var e=ii&&nn[Number(ii.split("-")[0])]||Dn,t=ei&&en[Number(ei.split("-")[0])]||Gn,o=$n?i(i({},$n),{title:(null==e?void 0:e.title)||(null==$n?void 0:$n.title)||""}):{id:"orphan-left",title:"",content:""},l=ni?i(i({},ni),{title:(null==t?void 0:t.title)||(null==ni?void 0:ni.title)||""}):{id:"orphan-right",title:"",content:""};mn(n,o,f,l,x,F)},onSummaryClick:function(n){n.stopPropagation(),gn(n,x,f,C)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),Fi=l(function(){var n=new Set;return Ni.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[Ni]),Ci=$||!On&&Cn?Fi:[],Mi=Fi.map(function(n){return n.highlight}).filter(Boolean),Oi=Ni.find(function(n){return dn.has(n.actionId)}),Pi=!!Oi;if(!(Fn||An||W.subsections&&0!==W.subsections.length))return null;var Bi=(null===(K=null==Oi?void 0:Oi.style)||void 0===K?void 0:K.badgeBorder)||(null==li?void 0:li.badgeBorder),Ri=Pi&&Bi?{borderRadius:"4px",outline:"2px solid ".concat(Bi),outlineOffset:"1px"}:{};return e(d,Fn?i({ref:Tn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e(d,i({sx:i({width:"100%"},Ri)},{children:t(r,i({disableGutters:!0,expanded:!Kn&&Ln,onChange:function(){if(!Kn){if(Ln){var n=String(rn||""),e=n.includes(ii)||n.includes(ei);e||dn.forEach(function(n){(String(n).includes(ii)||String(n).includes(ei))&&(e=!0)}),e&&(xn(),yn(new Set),Sn([]),In.current=[])}Q(function(n){var e;return i(i({},n),((e={})[L]=!n[L],e))})}},sx:{mt:0,boxShadow:"none",border:Kn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e(a,i({expandIcon:Kn?null:e(s,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e(u,i({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Kn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Wn||"Untitled Subsection"}))})),!Kn&&t(c,i({sx:{pt:0,pb:1,minWidth:0}},{children:[An&&e(v,{content:En,overlayContent:jn,sxStyles:vn,deviationBadges:Ci,maintainRelativeOrder:Y,highlightBg:Ii,suppressHighlightBg:Pn,highlights:Mi,collisionKey:Nn}),(W.subsections||[]).map(function(n,i){return e(F,{section:n,keyPath:"".concat(L,"-").concat(i),depth:z+1,columnKey:G,parentNodeId:V,sectionOffset:X,rhsOrphanVisualIndexes:U},"".concat(L,"-").concat(i))})]}))]}))}))}):i({ref:Tn,sx:{mt:0===z?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Kn&&t(d,i({sx:i({width:"100%"},Ri)},{children:[An&&e(v,{content:En,overlayContent:jn,sxStyles:vn,deviationBadges:Ci,maintainRelativeOrder:Y,highlightBg:Ii,suppressHighlightBg:Pn,highlights:Mi,collisionKey:Nn}),(W.subsections||[]).map(function(n,i){return e(F,{section:n,keyPath:"".concat(L,"-").concat(i),depth:z+1,columnKey:G,parentNodeId:V,sectionOffset:X,rhsOrphanVisualIndexes:U},"".concat(L,"-").concat(i))})]}))}))});export{F as default};
|
|
2
2
|
//# sourceMappingURL=SubSectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as d,useMemo as c,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{mixHexColors as g,areMarkdownPropsEqual as f}from"../CognitiveComparehelpers.js";import v from"rehype-raw";import m from"remark-gfm";var b=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},x=[b(m)],y=[b(v)],w=l.memo(function(f){var v=f.content,m=f.overlayContent,b=f.sxStyles,w=f.deviationBadges,E=void 0===w?[]:w,S=f.highlights,k=void 0===S?[]:S;f.maintainRelativeOrder;var C=f.highlightBg,B=f.suppressHighlightBg,F=void 0!==B&&B,z=f.collisionKey,A=d(null),T=!!m,W=c(function(){return E.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[E]),O=d({badgeMap:W,highlightBg:C,hideHighlightBg:T,suppressHighlightBg:F});O.current={badgeMap:W,highlightBg:C,hideHighlightBg:T,suppressHighlightBg:F};var I=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?I(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},M=c(function(){return{mark:function(r){var i,o,a,l,d=r.children,c=e(r,["children"]),s=O.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=c["data-badge-id"],v=f?u[f]:null,m=c["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===c["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:d}))},span:function(i){var a,l,d,c,s,p,g=i.children,f=e(i,["children"]),v=O.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,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:t(o,n({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,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:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=I(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=I(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),$=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},j=function(n){return n.replace(/[\.,;:]/g," ")},P=c(function(){return E.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[E]),D=c(function(){var e=$(v||""),t=F?j(e):e,r=(E||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:$((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||C}}).filter(function(n){return n.id&&n.highlight}),i={};r.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",d=null!==(i=a[2])&&void 0!==i?i:"",c=null!==(o=a[3])&&void 0!==o?o:"";return d?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+d+"</mark>"+c:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",d="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),d="</span>"+d}),a=l+o+d}return""+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},a=[];Object.entries(i).forEach(function(n){var r=n[0],i=n[1],o=e.indexOf(r),l=!1;if(-1===o&&F){var d=j(r);-1!==(o=t.indexOf(d))&&(l=!0)}if(-1!==o){for(var c=i[0].highlightColor,s=1;s<i.length;s++)c=g(c,i[s].highlightColor||"");a.push({highlight:r,start:o,end:o+r.length,badges:i,color:c,usedLooseMatch:l})}});var l=new Set(Object.keys(i));(k||[]).forEach(function(n){if(n){var r=$(n);if(r&&!l.has(r)){var i=e.indexOf(r),o=!1;if(-1===i&&F){var d=j(r);-1!==(i=t.indexOf(d))&&(o=!0)}if(-1!==i){var c=e.slice(0,i);(c.match(/</g)||[]).length===(c.match(/>/g)||[]).length&&a.push({highlight:r,start:i,end:i+r.length,badges:[],color:C||"",usedLooseMatch:o})}}}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var d=[],c={};a.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=d;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=t<s&&r>s&&t>=l,h=t<l&&r>l&&r<=s;if(t>=l&&r<=s){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=s),h&&(r=l)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&d.push({start:t,end:r,matchIdx:e})});var s={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],r=Number(e);s[t]||(s[t]=[]),s[t].push(r)});var u=a.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return u.forEach(function(n){var t,r,i,l,d=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,c=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(d>=c)){var u=e.slice(d,c),h=function(n,e,t,r){if(!t.length)return n;var i=t.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),l="",d=0;return i.forEach(function(t){var i,a,c=Math.max(d,t.start-e),s=Math.max(c,t.end-e);if(!(c>=s)){var u=g(r,t.color||"");l+=n.slice(d,c),l+=o(n.slice(c,s),(null===(a=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),d=s}}),l+=n.slice(d)}(n.usedLooseMatch||d!==n.start||c!==n.end?u:n.highlight,n.start,s[n.idx]||[],n.color),p=o(h,(null===(l=null===(i=n.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,d)+p+e.slice(c)}}),e},[v,E,k,C,F]),H=c(function(){return m?$(m||""):""},[m]),N=!!m,R={"& *":{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"}},L=n(n(n(n({},b),R),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),N?{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"}}:{}),q=n(n(n({},b),R),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return s(function(){if(A.current){var n=function(){var n=Array.from(A.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=A.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(A.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[D,z,P]),r(o,n({ref:A,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,n({component:"div",sx:n(n({},L),{padding:"3px"})},{children:t(p,n({components:M,remarkPlugins:x,rehypePlugins:y},{children:D.replace(/#{3}/g,"")}))})),N&&t(a,n({component:"div",sx:q},{children:t(p,n({components:M,remarkPlugins:x,rehypePlugins:y},{children:H}))}))]}))},f);export{w as MemoizedMarkdown};
|
|
1
|
+
import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as g,findTextMatchRange as f,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import b from"rehype-raw";import x from"remark-gfm";import{normalizeRedlineMarkdown as y}from"../utils/normalizeRedlineMarkdown.js";var w=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},E=[w(x)],S=[w(b)],k=l.memo(function(m){var b=m.content,x=m.overlayContent,w=m.sxStyles,k=m.deviationBadges,C=void 0===k?[]:k,B=m.highlights,F=void 0===B?[]:B;m.maintainRelativeOrder;var z=m.highlightBg,A=m.suppressHighlightBg,T=void 0!==A&&A,W=m.collisionKey,I=c(null),M=!!x,j=d(function(){return C.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[C]),$=c({badgeMap:j,highlightBg:z,hideHighlightBg:M,suppressHighlightBg:T});$.current={badgeMap:j,highlightBg:z,hideHighlightBg:M,suppressHighlightBg:T};var O=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?O(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},P=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=e(r,["children"]),s=$.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g=i.children,f=e(i,["children"]),v=$.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,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:t(o,n({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,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:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=O(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=O(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),R=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(n,e,t,r){return"".concat(e).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},D=d(function(){return C.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[C]),H=function(n){return R(y(n||""))},N=d(function(){var e=R(y(b||"")),t=(C||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:H((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||z}}).filter(function(n){return n.id&&n.highlight}),r={};t.forEach(function(n){r[n.highlight]||(r[n.highlight]=[]),r[n.highlight].push(n)});var i=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+c+"</mark>"+d:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),c="</span>"+c}),a=l+o+c}return""+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},o=[];Object.entries(r).forEach(function(n){var t=n[0],r=n[1],i=T?g(e,t):f(e,t,!1);if(i){for(var a=e.slice(i.start,i.end)!==t,l=r[0].highlightColor,c=1;c<r.length;c++)l=v(l,r[c].highlightColor||"");o.push({highlight:t,start:i.start,end:i.end,badges:r,color:l,usedLooseMatch:a})}});var a=new Set(Object.keys(r));(F||[]).forEach(function(n){if(n){var t=H(n);if(t&&!a.has(t)){var r=T?g(e,t):f(e,t,!1);if(r){var i=e.slice(r.start,r.end)!==t,l=e.slice(0,r.start);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&o.push({highlight:t,start:r.start,end:r.end,badges:[],color:z||"",usedLooseMatch:i})}}}}),o.sort(function(n,e){return n.start-e.start||e.end-n.end});var l=[],c={};o.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=l;i<o.length;i++){var a=o[i],d=a.start,s=a.end,u=t<s&&r>s&&t>=d,h=t<d&&r>d&&r<=s;if(t>=d&&r<=s){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=s),h&&(r=d)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&l.push({start:t,end:r,matchIdx:e})});var d={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],r=Number(e);d[t]||(d[t]=[]),d[t].push(r)});var s=o.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return s.forEach(function(n){var t,r,a,l,c=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,s=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(c>=s)){var u=e.slice(c,s),h=function(n,e,t,r){if(!t.length)return n;var a=t.map(function(n){return o[n]}).sort(function(n,e){return n.start-e.start}),l="",c=0;return a.forEach(function(t){var o,a,d=Math.max(c,t.start-e),s=Math.max(d,t.end-e);if(!(d>=s)){var u=v(r,t.color||"");l+=n.slice(c,d),l+=i(n.slice(d,s),(null===(a=null===(o=t.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),c=s}}),l+=n.slice(c)}(n.usedLooseMatch||c!==n.start||s!==n.end?u:n.highlight,n.start,d[n.idx]||[],n.color),p=i(h,(null===(l=null===(a=n.badges)||void 0===a?void 0:a[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,c)+p+e.slice(s)}}),e},[b,C,F,z,T]),L=d(function(){return x?R(y(x||"")):""},[x]),q=!!x,X={"& *":{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"}},Y=n(n(n(n({},w),X),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),q?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden",margin:"0 !important"},"& p:empty":{display:"none"}}:{}),K=n(n(n({},w),X),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return s(function(){if(I.current){var n=function(){var n=Array.from(I.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=I.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(I.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[N,W,D]),r(o,n({ref:I,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,n({component:"div",sx:n(n({},Y),{padding:"3px"})},{children:t(p,n({components:P,remarkPlugins:E,rehypePlugins:S},{children:N.replace(/#{3}/g,"")}))})),q&&t(a,n({component:"div",sx:K},{children:t(p,n({components:P,remarkPlugins:E,rehypePlugins:S},{children:L}))}))]}))},m);export{k as MemoizedMarkdown};
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{isMissingStr as i,safeStringify as o,getRationale as r,resolveComparisonInputItems as a,getSideData as l,hasValue as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{buildComparisonRows as u}from"../utils/buildComparisonRows.js";var v={id:"",title:"",similarity:0,sections:[]},c=function(c,f,p,I,_,g,h){var m,x;void 0===_&&(_=!0);var b="string"==typeof p?p:JSON.stringify(p||{}),y=null!=h?h:Boolean("string"==typeof g?g.trim():g&&(g.learnings_data||(null===(x=null===(m=g.data)||void 0===m?void 0:m.artifactData)||void 0===x?void 0:x.userStorySnapshot))),R=t(function(){if(!c||0===Object.keys(c).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var t=JSON.parse(b);try{var d=c.nodes||c,s=[],v=[],p=[],I=c.base_root_id,h=c.input_index_map||{0:"left",1:"right"},m=c[I]||d[I];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var x=c.content_mapping||{},R=function(n){return c[n]||d[n]},C=function(e,t,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(_)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),l={},d={},s=null;return a.forEach(function(n){var r,a,u,v,c,f,p=e[n];if(p&&"object"==typeof p){s||(s=p);var I=!(null==p?void 0:p.status)||"pending"===p.status,_=(null==p?void 0:p.deviation_highlight)||(null===(a=null==p?void 0:p.web_search_answer)||void 0===a?void 0:a.deviation_highlight),g=function(n){var e,t=(null===(e=null==p?void 0:p.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==p?void 0:p.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},m=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];if(Array.isArray(r)&&r.some(function(n){return!i(n)}))return r}return[]},x=I?m((null===(u=null==p?void 0:p.deviation_highlights)||void 0===u?void 0:u[t])||(null===(v=null==p?void 0:p.deviation_highlights)||void 0===v?void 0:v[h[0]]),"string"==typeof _?[_]:[],g(t),g(h[0])):[],b=I?m((null===(c=null==p?void 0:p.deviation_highlights)||void 0===c?void 0:c[o])||(null===(f=null==p?void 0:p.deviation_highlights)||void 0===f?void 0:f[h[1]]),g(o),g(h[1])):[];l[n]=((r={})[h[0]]=x[0]||"",r[h[1]]=b[0]||"",r.deviation_summary=(null==p?void 0:p.deviation_summary)||"",r.deviation_title=null==p?void 0:p.deviation_title,r.deviation_impact=null==p?void 0:p.deviation_impact,r.deviation_explanation=null==p?void 0:p.deviation_explanation,r.evaluation_outputs=null==p?void 0:p.evaluation_outputs,r.cognitive_decisioning=null==p?void 0:p.cognitive_decisioning,r.deviation_highlights=null==p?void 0:p.deviation_highlights,r),d[n]=p}}),n(n({},e),{deviation_title:(null==s?void 0:s.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==s?void 0:s.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:l,deviation_entries:d})},E=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var l=e.get(a);l.subsections||(l.subsections=[]),l.subsections.some(function(e){return e.id===n.id})||l.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},l=0,d=n;l<d.length;l++){a(d[l])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},O=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=h[0],i=h[1];return e.length>0&&(t=e.includes(h[0])?h[0]:e[0],i=e.includes(h[1])?h[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},j=function(e,t,i,r){var a=t.attributes||{},l=t.data||{},d=!1!==a.display_title,s=!1!==a.display_content,u=d?o(l.title||""):"",v=s?o(l.content||""):"",c=s?o(l.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),I=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:s,subsections:[]},I?r:{score:void 0,relation:"not_defined"}),{evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},w=function(e,i){var o,l=R(e);if(!l||!1===l.display_node)return[];if(y&&"1"===i)return[];var d=O(l),s=d.nodeLeftId,u=d.nodeRightId,v=r(l),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=C(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,I=a(l,i,h,x).map(function(n){return j(e,n,p,v)});if(l.next){var _=Object.values(l.next).flatMap(function(n){return w(n,i)});I.forEach(function(n){var e=_.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:_})}return I};if(f){var k=function(e,i){var o;void 0===i&&(i=0);var l=[],d=[];if(!e)return{refSections:l,baseSections:d};var s={},u={},v=-1,c=-1,f=function(l){var d=e[l],f=R(d);if(!f||!1===f.display_node)return"continue";var p=O(f),I=p.nodeLeftId,_=p.nodeRightId,g=r(f),m=(null===(o=null==t?void 0:t[d])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,b=C(m,I,_),E=b&&"object"==typeof b?n(n({},b),{nodeId:d}):b,S=k(f.next,i+1),w=S.refSections,D=S.baseSections,P=a(f,"0",h,x).map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=c--),e}),K=[];if(!y){var V=a(f,"1",h,x);K=V.map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=v--),e})}P.forEach(function(n){K.forEach(function(e){var t,i,o,r,a,l,d,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(l=e.refContentIds)||void 0===l||l.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),K.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[t]=s[t]?N(s[t],n):n}),P.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[t]=u[t]?N(u[t],n):n})};for(var p in e)f(p);return l=Object.values(s),d=Object.values(u),l.sort(S),d.sort(S),{refSections:l,baseSections:d}},D=k(m.next),P=D.refSections,K=D.baseSections;y||(v=E(P)),s=K}else m.next&&Object.values(m.next).forEach(function(n){var e=R(n);if(e&&!1!==e.display_node){var t=w(n,"0");if(y)s.push.apply(s,t);else{var i=E(w(n,"1"));p.push.apply(p,u(n,t,i))}}}),y||(s=p.map(function(n){return n.left}),v=p.map(function(n){return n.right}));var V=l(m,"0",h,x),T=l(m,"1",h,x),A={title:V.title||"Uploaded Contract",description:m.decision_scope_description||"",sections:s},G={id:"tree-variant-1",title:y?function(){var n,e;if("string"!=typeof g&&(null==g?void 0:g.learnings_data)&&Object.keys(g.learnings_data).length>0){var t=Object.keys(g.learnings_data)[0];return(null===(n=g.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return"string"!=typeof g&&(null===(e=null==g?void 0:g.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():T.title||"Reference Template",similarity:0,sections:v,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}};return{activeProposed:A,activeVariants:[G],comparisonRows:p,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[c,f,b,_,g,y]),C=R.activeProposed,E=R.activeVariants,O=R.comparisonRows,j=R.parseError,N=(null==E?void 0:E[0])||v,S=t(function(){return(null==C?void 0:C.sections)||[]},[null==C?void 0:C.sections]),w=t(function(){return N.sections||[]},[N.sections]),k=S.length>0||w.length>0,D=t(function(){return I.fields.filter(function(n){var e=n.key;return(!k||"description"!==e)&&(d(null==C?void 0:C[e])||d(N[e]))})},[C,N,k,I.fields]),P=t(function(){var n,e,t={},o={},r={},a=0,l=null===(n=null==c?void 0:c.input_index_map)||void 0===n?void 0:n[0],d=null===(e=null==c?void 0:c.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!f){var t="left"===e?S.indexOf(n):w.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:S.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=S.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var l=a.selfIndex,d=void 0!==l&&l>=0?l+1:S.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:d}}var s=void 0!==r&&r>=0?r+1:w.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},v=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,c,f,I,_){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!i(c[l]),p=!i(c[d]);if(f||p){var I=(null==a?void 0:a.nodeId)||n.nodeId||n.id,_="".concat(I).concat(s).concat(v);void 0===o[_]&&(void 0===r[e]&&(r[e]=1),o[_]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,c,f),e&&!I){var g=(null==_?void 0:_.id)||"fallback_parent_".concat(a++);t[g]||(t[g]=[]),t[g].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=v(null==n?void 0:n.subsections,t),o=v(null==u?void 0:u.subsections,t);p(t,i,o,c,f,!1,e||_)})};S.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(f){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=w.find(function(n){return n.selfIndex===a})}else r=w[S.indexOf(n)];p(n,n,r,i,o,!0,n)}),y||w.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),_=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:I,deviationParentRegistry:_}},[S,w,f,c,y]),K=P.parentDeviationRecord,V=P.registry,T=P.deviationParentRegistry;return{isGuidelineMode:y,activeProposed:C,activeVariants:E,comparisonRows:O,existingRule:N,proposedSections:S,existingSections:w,visibleFields:D,parentDeviationRecord:K,deviationNumberRegistry:V,deviationParentRegistry:T,parseError:j}};export{c as useCognitiveTreeData};
|
|
1
|
+
import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{safeStringify as i,isMissingStr as o,getRationale as r,resolveComparisonInputItems as a,getSideData as l,hasValue as d,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{buildComparisonRows as u}from"../utils/buildComparisonRows.js";var v={id:"",title:"",similarity:0,sections:[]},c=function(c,f,p,_,I,g,h){var m,x;void 0===I&&(I=!0);var b="string"==typeof p?p:JSON.stringify(p||{}),y=null!=h?h:Boolean("string"==typeof g?g.trim():g&&(g.learnings_data||(null===(x=null===(m=g.data)||void 0===m?void 0:m.artifactData)||void 0===x?void 0:x.userStorySnapshot))),R=t(function(){if(!c||0===Object.keys(c).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var t=JSON.parse(b);try{var d=c.nodes||c,s=[],v=[],p=[],_=c.base_root_id,h=c.input_index_map||{0:"left",1:"right"},m=c[_]||d[_];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var x=c.content_mapping||{},R=function(n){return c[n]||d[n]},C=function(e,t,r){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(I)return e;var a=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!a.length)return e;var l=a.sort(function(n,e){return Number(n)-Number(e)}),d={},s={},u=null;return l.forEach(function(n){var a,l,v,c,f,p,_,I=e[n];if(I&&"object"==typeof I){u||(u=I);var g="same"===i(null===(l=null==I?void 0:I.evaluation_outputs)||void 0===l?void 0:l.output_value).trim().toLowerCase(),m=!((null==I?void 0:I.status)&&"pending"!==I.status||g),x=(null==I?void 0:I.deviation_highlight)||(null===(v=null==I?void 0:I.web_search_answer)||void 0===v?void 0:v.deviation_highlight),b=function(n){var e,t=(null===(e=null==I?void 0:I.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==I?void 0:I.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},y=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,i=n;t<i.length;t++){var r=i[t];if(Array.isArray(r)&&r.some(function(n){return!o(n)}))return r}return[]},R=m?y((null===(c=null==I?void 0:I.deviation_highlights)||void 0===c?void 0:c[t])||(null===(f=null==I?void 0:I.deviation_highlights)||void 0===f?void 0:f[h[0]]),"string"==typeof x?[x]:[],b(t),b(h[0])):[],C=m?y((null===(p=null==I?void 0:I.deviation_highlights)||void 0===p?void 0:p[r])||(null===(_=null==I?void 0:I.deviation_highlights)||void 0===_?void 0:_[h[1]]),b(r),b(h[1])):[];d[n]=((a={})[h[0]]=R[0]||"",a[h[1]]=C[0]||"",a.deviation_summary=(null==I?void 0:I.deviation_summary)||"",a.deviation_title=null==I?void 0:I.deviation_title,a.deviation_impact=null==I?void 0:I.deviation_impact,a.deviation_explanation=null==I?void 0:I.deviation_explanation,a.evaluation_outputs=null==I?void 0:I.evaluation_outputs,a.cognitive_decisioning=null==I?void 0:I.cognitive_decisioning,a.deviation_highlights=null==I?void 0:I.deviation_highlights,a),s[n]=I}}),n(n({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:s})},E=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var l=e.get(a);l.subsections||(l.subsections=[]),l.subsections.some(function(e){return e.id===n.id})||l.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},l=0,d=n;l<d.length;l++){a(d[l])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},O=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=h[0],i=h[1];return e.length>0&&(t=e.includes(h[0])?h[0]:e[0],i=e.includes(h[1])?h[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},j=function(e,t,o,r){var a=t.attributes||{},l=t.data||{},d=!1!==a.display_title,s=!1!==a.display_content,u=d?i(l.title||""):"",v=s?i(l.content||""):"",c=s?i(l.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:s,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},w=function(e,i){var o,l=R(e);if(!l||!1===l.display_node)return[];if(y&&"1"===i)return[];var d=O(l),s=d.nodeLeftId,u=d.nodeRightId,v=r(l),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=C(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,_=a(l,i,h,x).map(function(n){return j(e,n,p,v)});if(l.next){var I=Object.values(l.next).flatMap(function(n){return w(n,i)});_.forEach(function(n){var e=I.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:I})}return _};if(f){var k=function(e,i){var o;void 0===i&&(i=0);var l=[],d=[];if(!e)return{refSections:l,baseSections:d};var s={},u={},v=-1,c=-1,f=function(l){var d=e[l],f=R(d);if(!f||!1===f.display_node)return"continue";var p=O(f),_=p.nodeLeftId,I=p.nodeRightId,g=r(f),m=(null===(o=null==t?void 0:t[d])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,b=C(m,_,I),E=b&&"object"==typeof b?n(n({},b),{nodeId:d}):b,S=k(f.next,i+1),w=S.refSections,D=S.baseSections,P=a(f,"0",h,x).map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=c--),e}),K=[];if(!y){var V=a(f,"1",h,x);K=V.map(function(n){var e=j(d,n,E,g);return-1===e.selfIndex&&(e.selfIndex=v--),e})}P.forEach(function(n){K.forEach(function(e){var t,i,o,r,a,l,d,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(l=e.refContentIds)||void 0===l||l.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),K.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[t]=s[t]?N(s[t],n):n}),P.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[t]=u[t]?N(u[t],n):n})};for(var p in e)f(p);return l=Object.values(s),d=Object.values(u),l.sort(S),d.sort(S),{refSections:l,baseSections:d}},D=k(m.next),P=D.refSections,K=D.baseSections;y||(v=E(P)),s=K}else m.next&&Object.values(m.next).forEach(function(n){var e=R(n);if(e&&!1!==e.display_node){var t=w(n,"0");if(y)s.push.apply(s,t);else{var i=E(w(n,"1"));p.push.apply(p,u(n,t,i))}}}),y||(s=p.map(function(n){return n.left}),v=p.map(function(n){return n.right}));var V=l(m,"0",h,x),T=l(m,"1",h,x),A={title:V.title||"Uploaded Contract",description:m.decision_scope_description||"",sections:s},L={id:"tree-variant-1",title:y?function(){var n,e;if("string"!=typeof g&&(null==g?void 0:g.learnings_data)&&Object.keys(g.learnings_data).length>0){var t=Object.keys(g.learnings_data)[0];return(null===(n=g.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return"string"!=typeof g&&(null===(e=null==g?void 0:g.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():T.title||"Reference Template",similarity:0,sections:v,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}};return{activeProposed:A,activeVariants:[L],comparisonRows:p,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[c,f,b,I,g,y]),C=R.activeProposed,E=R.activeVariants,O=R.comparisonRows,j=R.parseError,N=(null==E?void 0:E[0])||v,S=t(function(){return(null==C?void 0:C.sections)||[]},[null==C?void 0:C.sections]),w=t(function(){return N.sections||[]},[N.sections]),k=S.length>0||w.length>0,D=t(function(){return _.fields.filter(function(n){var e=n.key;return(!k||"description"!==e)&&(d(null==C?void 0:C[e])||d(N[e]))})},[C,N,k,_.fields]),P=t(function(){var n,e,t={},i={},r={},a=0,l=null===(n=null==c?void 0:c.input_index_map)||void 0===n?void 0:n[0],d=null===(e=null==c?void 0:c.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!f){var t="left"===e?S.indexOf(n):w.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:S.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=S.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var l=a.selfIndex,d=void 0!==l&&l>=0?l+1:S.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:d}}var s=void 0!==r&&r>=0?r+1:w.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},v=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,c,f,_,I){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!o(c[l]),p=!o(c[d]);if(f||p){var _=(null==a?void 0:a.nodeId)||n.nodeId||n.id,I="".concat(_).concat(s).concat(v);void 0===i[I]&&(void 0===r[e]&&(r[e]=1),i[I]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,c,f),e&&!_){var g=(null==I?void 0:I.id)||"fallback_parent_".concat(a++);t[g]||(t[g]=[]),t[g].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=v(null==n?void 0:n.subsections,t),o=v(null==u?void 0:u.subsections,t);p(t,i,o,c,f,!1,e||I)})};S.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(f){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=w.find(function(n){return n.selfIndex===a})}else r=w[S.indexOf(n)];p(n,n,r,i,o,!0,n)}),y||w.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(i).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(i).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:_,deviationParentRegistry:I}},[S,w,f,c,y]),K=P.parentDeviationRecord,V=P.registry,T=P.deviationParentRegistry;return{isGuidelineMode:y,activeProposed:C,activeVariants:E,comparisonRows:O,existingRule:N,proposedSections:S,existingSections:w,visibleFields:D,parentDeviationRecord:K,deviationNumberRegistry:V,deviationParentRegistry:T,parseError:j}};export{c as useCognitiveTreeData};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as l,jsx as i,Fragment as o}from"react/jsx-runtime";import{useMemo as t,useState as r,useRef as d,useEffect as a}from"react";import{ExternalLink as s,ChevronUp as c,ChevronDown as u}from"lucide-react";import v from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},m=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,l){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?i("strong",e({className:v.boldText},{children:n.slice(2,-2)}),l):n})},g=function(g){var p=g.item,f=g.headerTitle;g.index;var x=g.iconsConfig,y=g.DocumentTitle,b=g.previewCallback,N=g.bodyHeight,C=g.disableMaximize,I=void 0!==C&&C,k=g.splitterCustomStyle,T=void 0!==k&&k,H=g.themeTokens,L=g.classNames,B=g.styles,w=p.dataSource,z=p.confidence_score,S=p.trainingDataTitle,A=null==x?void 0:x.ChevronDownIcon,F=null==x?void 0:x.ChevronUpIcon,_=null==x?void 0:x.MaximizeIcon,D=null==x?void 0:x.CloseIcon,R=t(function(){var e=(w?w.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),l=0,i=e.map(function(n){var e=n.startsWith("<highlight>"),i={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?l:-1};return e&&l++,i}),o=i.filter(function(n){return n.isHighlight}).length,t=[],r=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,o=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((r.length>0||t.length>0)&&t.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:i,highlightIndex:o})})}),r.length>0&&t.push(n([],r,!0)),{processedLines:t.map(function(n){var e=n.map(function(n){return n.text}).join(""),l=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!l,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==l?void 0:l[1])||"",content:(null==l?void 0:l[3])||e}}),totalHighlights:o}},[w]),W=R.processedLines,j=R.totalHighlights,M=r(0),V=M[0],E=M[1],$=d(null),U=d(null),Y=d(null),q=d([]),G=d([]);a(function(){q.current=q.current.slice(0,j),G.current=G.current.slice(0,j)},[j]),a(function(){if(j>0){E(0);var n=setTimeout(function(){var n;null===(n=q.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[j]);var J=function(n,e){setTimeout(function(){var l=e?G.current[n]:q.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},K=function(n){if(void 0===n&&(n=!1),j){var e=V>0?V-1:j-1;E(e),J(e,n)}},O=function(n){if(void 0===n&&(n=!1),j){var e=V<j-1?V+1:0;E(e),J(e,n)}},P=function(n){var o=n?G:q,t=0;return W.map(function(n,r){n.isHeader&&(t=0),n.isListItem&&(t+=1);var d=function(){return n.segments.map(function(l,t){var r=l.isHighlight&&l.highlightIndex===V,d=l.text;return n.isListItem&&0===t&&(d=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?i("span",e({ref:function(n){n&&(o.current[l.highlightIndex]=n)},className:h(v.highlight,r?v.highlightActive:void 0,null==L?void 0:L.highlight,r?null==L?void 0:L.highlightActive:void 0),style:r?e(e({},null==B?void 0:B.highlight),null==B?void 0:B.highlightActive):null==B?void 0:B.highlight},{children:m(d)}),t):i("span",{children:m(d)},t)})};return n.isHeader?i("span",e({className:h(v.headerLine,null==L?void 0:L.headerLine),style:null==B?void 0:B.headerLine},{children:d()}),r):n.isListItem?l("span",e({className:h(v.listItemLine,null==L?void 0:L.listItemLine),style:e({paddingLeft:n.indent?"1rem":"0"},null==B?void 0:B.listItemLine)},{children:[l("span",e({className:h(v.listCounter,null==L?void 0:L.listCounter),style:null==B?void 0:B.listCounter},{children:[t,"."]})),i("span",{children:d()})]}),r):i("span",e({className:h(v.blockLine,null==L?void 0:L.blockLine),style:null==B?void 0:B.blockLine},{children:d()}),r)})},Q=function(n){return j>1?l("div",e({className:h(n?v.modalNavContainer:v.navigationContainer,n?null==L?void 0:L.modalNavContainer:null==L?void 0:L.navigationContainer),style:n?null==B?void 0:B.modalNavContainer:null==B?void 0:B.navigationContainer},{children:[F&&i("button",e({onClick:function(){return K(n)},className:h(n?v.modalNavButton:v.navButton,null==L?void 0:L.navButton),style:null==B?void 0:B.navButton},{children:i(F,{className:h(v.navIcon,null==L?void 0:L.navIcon),style:null==B?void 0:B.navIcon})})),l("span",e({className:h(v.navCounter,null==L?void 0:L.navCounter),style:null==B?void 0:B.navCounter},{children:[V+1,"/",j]})),A&&i("button",e({onClick:function(){return O(n)},className:h(n?v.modalNavButton:v.navButton,null==L?void 0:L.navButton),style:null==B?void 0:B.navButton},{children:i(A,{className:h(v.navIcon,null==L?void 0:L.navIcon),style:null==B?void 0:B.navIcon})}))]})):null},X=null!=z?l("span",e({className:h(v.confidenceBadge,null==L?void 0:L.confidenceBadge),style:null==B?void 0:B.confidenceBadge},{children:[i("span",e({className:v.confidenceStar},{children:"✦"})),l("span",e({className:v.confidenceScore},{children:[z,"%"]}))]})):null,Z=T?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,nn=l(o,{children:[S&&i("div",e({className:h(v.footer,null==L?void 0:L.footer),style:e(e({},Z),null==B?void 0:B.footer)},{children:i("span",e({className:h(v.trainingTitle,null==L?void 0:L.trainingTitle),style:null==B?void 0:B.trainingTitle},{children:S}))})),y&&i("div",e({className:h(v.modalFooterSource,null==L?void 0:L.modalFooterSource),style:e(e({},Z),null==B?void 0:B.modalFooterSource)},{children:l("button",e({type:"button",onClick:function(){return null==b?void 0:b()},className:h(v.trainingTitleLink,null==L?void 0:L.trainingTitleLink),style:null==B?void 0:B.trainingTitleLink},{children:[y,i(s,{size:16,color:"#2563eb"})]}))}))]});return l(o,{children:[l("div",e({className:h(v.expandedContainer,null==L?void 0:L.expandedContainer),style:e(e(e(e({},H),N?{height:"".concat(N),display:"flex",flexDirection:"column"}:void 0),T?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==B?void 0:B.expandedContainer)},{children:[l("div",e({className:h(v.expandedHeader,null==L?void 0:L.expandedHeader),style:e(e({},T?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==B?void 0:B.expandedHeader)},{children:[i("span",e({className:h(v.headerTitle,null==L?void 0:L.headerTitle),style:null==B?void 0:B.headerTitle},{children:f})),l("div",e({className:h(v.headerActions,null==L?void 0:L.headerActions),style:null==B?void 0:B.headerActions},{children:[T?j>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[V+1," / ",j]})),i("button",e({onClick:function(){return K(!0)},disabled:V<=0,style:{padding:"2px 4px",cursor:V<=0?"not-allowed":"pointer",opacity:V<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(c,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return O(!0)},disabled:V>=j-1,style:{padding:"2px 4px",cursor:V>=j-1?"not-allowed":"pointer",opacity:V>=j-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):Q(!1),X,!I&&_&&i("button",e({onClick:function(){var n;return null===(n=Y.current)||void 0===n?void 0:n.showModal()},className:h(v.maximizeButton,null==L?void 0:L.maximizeButton),style:null==B?void 0:B.maximizeButton,title:"View fullscreen"},{children:i(_,{className:v.maximizeIcon})}))]}))]})),i("div",e({ref:$,className:h(v.contentArea,null==L?void 0:L.contentArea),style:e(e(e({},N?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),T?{padding:"1rem 1.5rem"}:void 0),null==B?void 0:B.contentArea)},{children:i("div",e({className:h(v.contentInner,null==L?void 0:L.contentInner),style:null==B?void 0:B.contentInner},{children:P(!1)}))})),nn]})),!I&&i("dialog",e({ref:Y,className:v.modalDialog,onClick:function(n){var e;n.target===Y.current&&(null===(e=Y.current)||void 0===e||e.close())}},{children:l("div",e({className:h(v.modalContainer,null==L?void 0:L.modalContainer),style:null==B?void 0:B.modalContainer},{children:[l("div",e({className:h(v.modalHeader,null==L?void 0:L.modalHeader),style:null==B?void 0:B.modalHeader},{children:[i("span",e({className:h(v.modalHeaderTitle,null==L?void 0:L.modalHeaderTitle),style:null==B?void 0:B.modalHeaderTitle},{children:f})),l("div",e({className:h(v.modalHeaderActions,null==L?void 0:L.modalHeaderActions),style:null==B?void 0:B.modalHeaderActions},{children:[T?j>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[V+1," / ",j]})),i("button",e({onClick:function(){return K(!0)},disabled:V<=0,style:{padding:"2px 4px",cursor:V<=0?"not-allowed":"pointer",opacity:V<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(c,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return O(!0)},disabled:V>=j-1,style:{padding:"2px 4px",cursor:V>=j-1?"not-allowed":"pointer",opacity:V>=j-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):Q(!0),X,D&&i("button",e({onClick:function(){var n;return null===(n=Y.current)||void 0===n?void 0:n.close()},className:h(v.closeButton,null==L?void 0:L.closeButton),style:null==B?void 0:B.closeButton,title:"Close"},{children:i(D,{className:h(v.closeIcon,null==L?void 0:L.closeIcon),style:null==B?void 0:B.closeIcon})}))]}))]})),i("div",e({ref:U,className:h(v.modalContent,null==L?void 0:L.modalContent),style:null==B?void 0:B.modalContent},{children:i("div",e({className:h(v.modalContentInner,null==L?void 0:L.modalContentInner),style:null==B?void 0:B.modalContentInner},{children:P(!0)}))})),S&&i("div",e({className:h(v.modalFooter,null==L?void 0:L.modalFooter),style:null==B?void 0:B.modalFooter},{children:i("span",e({className:h(v.trainingTitle,null==L?void 0:L.trainingTitle),style:null==B?void 0:B.trainingTitle},{children:S}))})),y&&i("div",e({className:h(v.modalFooterSource,null==L?void 0:L.modalFooterSource),style:null==B?void 0:B.modalFooterSource},{children:l("button",e({type:"button",onClick:function(){var n;null==b||b(),null===(n=Y.current)||void 0===n||n.close()},className:h(v.trainingTitleLink,null==L?void 0:L.trainingTitleLink),style:null==B?void 0:B.trainingTitleLink},{children:[y,i(s,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{g as default};
|
|
1
|
+
import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as l,jsx as i,Fragment as o}from"react/jsx-runtime";import{useMemo as t,useState as r,useRef as d,useEffect as a}from"react";import{ExternalLink as c,ChevronUp as s,ChevronDown as u}from"lucide-react";import v from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},m=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,l){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?i("strong",e({className:v.boldText},{children:n.slice(2,-2)}),l):n})},g=function(g){var p=g.item,f=g.headerTitle;g.index;var x=g.iconsConfig,y=g.DocumentTitle,b=g.previewCallback,C=g.bodyHeight,N=g.disableMaximize,I=void 0!==N&&N,k=g.onFullscreenChange,T=g.splitterCustomStyle,H=void 0!==T&&T,L=g.themeTokens,B=g.classNames,w=g.styles,z=p.dataSource,S=p.confidence_score,A=p.trainingDataTitle,F=null==x?void 0:x.ChevronDownIcon,_=null==x?void 0:x.ChevronUpIcon,D=null==x?void 0:x.MaximizeIcon,R=null==x?void 0:x.CloseIcon,W=t(function(){var e=(z?z.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),l=0,i=e.map(function(n){var e=n.startsWith("<highlight>"),i={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?l:-1};return e&&l++,i}),o=i.filter(function(n){return n.isHighlight}).length,t=[],r=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,o=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((r.length>0||t.length>0)&&t.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:i,highlightIndex:o})})}),r.length>0&&t.push(n([],r,!0)),{processedLines:t.map(function(n){var e=n.map(function(n){return n.text}).join(""),l=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!l,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==l?void 0:l[1])||"",content:(null==l?void 0:l[3])||e}}),totalHighlights:o}},[z]),j=W.processedLines,M=W.totalHighlights,V=r(0),E=V[0],$=V[1],U=d(null),Y=d(null),q=d(null),G=d([]),J=d([]);a(function(){G.current=G.current.slice(0,M),J.current=J.current.slice(0,M)},[M]),a(function(){if(M>0){$(0);var n=setTimeout(function(){var n;null===(n=G.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[M]),a(function(){return function(){var n;(null===(n=q.current)||void 0===n?void 0:n.open)&&(null==k||k(!1))}},[k]);var K=function(n,e){setTimeout(function(){var l=e?J.current[n]:G.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},O=function(n){if(void 0===n&&(n=!1),M){var e=E>0?E-1:M-1;$(e),K(e,n)}},P=function(n){if(void 0===n&&(n=!1),M){var e=E<M-1?E+1:0;$(e),K(e,n)}},Q=function(n){var o=n?J:G,t=0;return j.map(function(n,r){n.isHeader&&(t=0),n.isListItem&&(t+=1);var d=function(){return n.segments.map(function(l,t){var r=l.isHighlight&&l.highlightIndex===E,d=l.text;return n.isListItem&&0===t&&(d=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?i("span",e({ref:function(n){n&&(o.current[l.highlightIndex]=n)},className:h(v.highlight,r?v.highlightActive:void 0,null==B?void 0:B.highlight,r?null==B?void 0:B.highlightActive:void 0),style:r?e(e({},null==w?void 0:w.highlight),null==w?void 0:w.highlightActive):null==w?void 0:w.highlight},{children:m(d)}),t):i("span",{children:m(d)},t)})};return n.isHeader?i("span",e({className:h(v.headerLine,null==B?void 0:B.headerLine),style:null==w?void 0:w.headerLine},{children:d()}),r):n.isListItem?l("span",e({className:h(v.listItemLine,null==B?void 0:B.listItemLine),style:e({paddingLeft:n.indent?"1rem":"0"},null==w?void 0:w.listItemLine)},{children:[l("span",e({className:h(v.listCounter,null==B?void 0:B.listCounter),style:null==w?void 0:w.listCounter},{children:[t,"."]})),i("span",{children:d()})]}),r):i("span",e({className:h(v.blockLine,null==B?void 0:B.blockLine),style:null==w?void 0:w.blockLine},{children:d()}),r)})},X=function(n){return M>1?l("div",e({className:h(n?v.modalNavContainer:v.navigationContainer,n?null==B?void 0:B.modalNavContainer:null==B?void 0:B.navigationContainer),style:n?null==w?void 0:w.modalNavContainer:null==w?void 0:w.navigationContainer},{children:[_&&i("button",e({onClick:function(){return O(n)},className:h(n?v.modalNavButton:v.navButton,null==B?void 0:B.navButton),style:null==w?void 0:w.navButton},{children:i(_,{className:h(v.navIcon,null==B?void 0:B.navIcon),style:null==w?void 0:w.navIcon})})),l("span",e({className:h(v.navCounter,null==B?void 0:B.navCounter),style:null==w?void 0:w.navCounter},{children:[E+1,"/",M]})),F&&i("button",e({onClick:function(){return P(n)},className:h(n?v.modalNavButton:v.navButton,null==B?void 0:B.navButton),style:null==w?void 0:w.navButton},{children:i(F,{className:h(v.navIcon,null==B?void 0:B.navIcon),style:null==w?void 0:w.navIcon})}))]})):null},Z=null!=S?l("span",e({className:h(v.confidenceBadge,null==B?void 0:B.confidenceBadge),style:null==w?void 0:w.confidenceBadge},{children:[i("span",e({className:v.confidenceStar},{children:"✦"})),l("span",e({className:v.confidenceScore},{children:[S,"%"]}))]})):null,nn=H?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,en=l(o,{children:[A&&i("div",e({className:h(v.footer,null==B?void 0:B.footer),style:e(e({},nn),null==w?void 0:w.footer)},{children:i("span",e({className:h(v.trainingTitle,null==B?void 0:B.trainingTitle),style:null==w?void 0:w.trainingTitle},{children:A}))})),y&&i("div",e({className:h(v.modalFooterSource,null==B?void 0:B.modalFooterSource),style:e(e({},nn),null==w?void 0:w.modalFooterSource)},{children:l("button",e({type:"button",onClick:function(){return null==b?void 0:b()},className:h(v.trainingTitleLink,null==B?void 0:B.trainingTitleLink),style:null==w?void 0:w.trainingTitleLink},{children:[y,i(c,{size:16,color:"#2563eb"})]}))}))]});return l(o,{children:[l("div",e({className:h(v.expandedContainer,null==B?void 0:B.expandedContainer),style:e(e(e(e({},L),C?{height:"".concat(C),display:"flex",flexDirection:"column"}:void 0),H?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==w?void 0:w.expandedContainer)},{children:[l("div",e({className:h(v.expandedHeader,null==B?void 0:B.expandedHeader),style:e(e({},H?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==w?void 0:w.expandedHeader)},{children:[i("span",e({className:h(v.headerTitle,null==B?void 0:B.headerTitle),style:null==w?void 0:w.headerTitle},{children:f})),l("div",e({className:h(v.headerActions,null==B?void 0:B.headerActions),style:null==w?void 0:w.headerActions},{children:[H?M>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[E+1," / ",M]})),i("button",e({onClick:function(){return O(!0)},disabled:E<=0,style:{padding:"2px 4px",cursor:E<=0?"not-allowed":"pointer",opacity:E<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(s,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return P(!0)},disabled:E>=M-1,style:{padding:"2px 4px",cursor:E>=M-1?"not-allowed":"pointer",opacity:E>=M-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):X(!1),Z,!I&&D&&i("button",e({onClick:function(){var n;null==k||k(!0),null===(n=q.current)||void 0===n||n.showModal()},className:h(v.maximizeButton,null==B?void 0:B.maximizeButton),style:null==w?void 0:w.maximizeButton,title:"View fullscreen"},{children:i(D,{className:v.maximizeIcon})}))]}))]})),i("div",e({ref:U,className:h(v.contentArea,null==B?void 0:B.contentArea),style:e(e(e({},C?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),H?{padding:"1rem 1.5rem"}:void 0),null==w?void 0:w.contentArea)},{children:i("div",e({className:h(v.contentInner,null==B?void 0:B.contentInner),style:null==w?void 0:w.contentInner},{children:Q(!1)}))})),en]})),!I&&i("dialog",e({ref:q,className:v.modalDialog,onClose:function(){return null==k?void 0:k(!1)},onClick:function(n){var e;n.target===q.current&&(null===(e=q.current)||void 0===e||e.close())}},{children:l("div",e({className:h(v.modalContainer,null==B?void 0:B.modalContainer),style:null==w?void 0:w.modalContainer},{children:[l("div",e({className:h(v.modalHeader,null==B?void 0:B.modalHeader),style:null==w?void 0:w.modalHeader},{children:[i("span",e({className:h(v.modalHeaderTitle,null==B?void 0:B.modalHeaderTitle),style:null==w?void 0:w.modalHeaderTitle},{children:f})),l("div",e({className:h(v.modalHeaderActions,null==B?void 0:B.modalHeaderActions),style:null==w?void 0:w.modalHeaderActions},{children:[H?M>1&&l(o,{children:[l("span",e({style:{fontSize:"12px",color:"#888"}},{children:[E+1," / ",M]})),i("button",e({onClick:function(){return O(!0)},disabled:E<=0,style:{padding:"2px 4px",cursor:E<=0?"not-allowed":"pointer",opacity:E<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(s,{size:14,color:"#64748b"})})),i("button",e({onClick:function(){return P(!0)},disabled:E>=M-1,style:{padding:"2px 4px",cursor:E>=M-1?"not-allowed":"pointer",opacity:E>=M-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:i(u,{size:14,color:"#64748b"})}))]}):X(!0),Z,R&&i("button",e({onClick:function(){var n;return null===(n=q.current)||void 0===n?void 0:n.close()},className:h(v.closeButton,null==B?void 0:B.closeButton),style:null==w?void 0:w.closeButton,title:"Close"},{children:i(R,{className:h(v.closeIcon,null==B?void 0:B.closeIcon),style:null==w?void 0:w.closeIcon})}))]}))]})),i("div",e({ref:Y,className:h(v.modalContent,null==B?void 0:B.modalContent),style:null==w?void 0:w.modalContent},{children:i("div",e({className:h(v.modalContentInner,null==B?void 0:B.modalContentInner),style:null==w?void 0:w.modalContentInner},{children:Q(!0)}))})),A&&i("div",e({className:h(v.modalFooter,null==B?void 0:B.modalFooter),style:null==w?void 0:w.modalFooter},{children:i("span",e({className:h(v.trainingTitle,null==B?void 0:B.trainingTitle),style:null==w?void 0:w.trainingTitle},{children:A}))})),y&&i("div",e({className:h(v.modalFooterSource,null==B?void 0:B.modalFooterSource),style:null==w?void 0:w.modalFooterSource},{children:l("button",e({type:"button",onClick:function(){var n;null==b||b(),null===(n=q.current)||void 0===n||n.close()},className:h(v.trainingTitleLink,null==B?void 0:B.trainingTitleLink),style:null==w?void 0:w.trainingTitleLink},{children:[y,i(c,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{g as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveInternalgptCoreComponent.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useMemo as o,useState as l,useCallback as a}from"react";import{Sparkles as r,Globe as s}from"lucide-react";import d from"../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js";import u from"./GptWebCitationImageCitation.js";import c from"./GptWebCitationSkeleton.js";import{allowsGptCitationView as v,allowsWebCitationView as
|
|
1
|
+
import{__assign as i}from"tslib";import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useMemo as o,useState as l,useCallback as a}from"react";import{Sparkles as r,Globe as s}from"lucide-react";import d from"../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js";import u from"./GptWebCitationImageCitation.js";import c from"./GptWebCitationSkeleton.js";import{allowsGptCitationView as v,allowsWebCitationView as g,showsCitationViewToggle as p,CitationType as m}from"./types.js";import{mapCitationDataToDisplay as b,resolveSkeletonVisitUrl as C,getWebCitationImageUrl as w}from"./utils/citationData.utils.js";import{resolveWebCitationVisitLinkStyles as h}from"./utils/styleOverrides.utils.js";import{resolveFixedHeightLayout as f,getFixedPanelStyle as k,getParentHeightPanelStyle as y,getParentHeightGptBodyHeight as x,getFixedWebContentStyle as F}from"./utils/fixedHeight.utils.js";import I from"./GptWebCitation.module.css.js";import B from"../../assests/svg/NeuralNetworkIcon.js";var S=function(o){var l=o.variant,a=o.disabled,r=o.onClick,d=o.title,u=o.style;return t("button",i({type:"button",className:I.webCitationButton,onClick:r,disabled:a,title:d,style:u},{children:e(n,"gpt"===l?{children:[t(B,{className:I.webCitationButtonIcon}),"View GPT Citation"]}:{children:[t(s,{size:24,className:I.webCitationButtonIcon}),"View Web Citation"]})}))},H=function(n){var s,B,H,L,N=n.gptCitation,W=n.defaultCitationUrl,j=n.citationType,T=n.webCitationData,E=n.topic,V=n.sourceLabel,z=n.relevanceScore,G=n.learnedFrom,A=n.webCitationStatus,M=n.onGenerateWebCitation,P=n.showWebCitation,U=n.onToggleCitationView,D=n.showExpandImageButton,O=void 0===D||D,R=n.onFullscreenChange,q=n.showGptMaximizeButton,J=n.iconsConfig,K=n.isFixedHeight,Q=void 0!==K&&K,X=n.useParentHeight,Y=void 0!==X&&X,Z=n.styles,$=o(function(){return function(t){var e,n,o,l,a,r,s,d,u,c,v;return{container:null==t?void 0:t.container,gptWrapper:i(i({},null===(e=null==t?void 0:t.gptCitation)||void 0===e?void 0:e.wrapper),null==t?void 0:t.gptCitationWrapper),gptFooterAction:i(i({},null===(n=null==t?void 0:t.gptCitation)||void 0===n?void 0:n.footerAction),null==t?void 0:t.footerAction),gptToggleButton:i(i({},null===(o=null==t?void 0:t.gptCitation)||void 0===o?void 0:o.toggleButton),null==t?void 0:t.webCitationButton),webPanel:i(i({},null==t?void 0:t.container),null===(l=null==t?void 0:t.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==t?void 0:t.webCitation)||void 0===a?void 0:a.header,webContent:null===(r=null==t?void 0:t.webCitation)||void 0===r?void 0:r.content,webFooter:null===(s=null==t?void 0:t.webCitation)||void 0===s?void 0:s.footer,webToggleButton:i(i({},null===(d=null==t?void 0:t.webCitation)||void 0===d?void 0:d.toggleButton),null==t?void 0:t.webCitationButton),webLearnedFrom:null===(u=null==t?void 0:t.webCitation)||void 0===u?void 0:u.learnedFrom,webImage:null===(c=null==t?void 0:t.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==t?void 0:t.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:h(null==t?void 0:t.webCitation,"image"),webSkeletonVisitLink:h(null==t?void 0:t.webCitation,"skeleton")}}(Z)},[Z]),_=v(j),ii=g(j),ti=p(j),ei=Q||Y,ni=o(function(){return Q?f(N.bodyHeight,ti):null},[Q,N.bodyHeight,ti]),oi=o(function(){return ni?k(ni.panelHeight):void 0},[ni]),li=o(function(){return Y?y():void 0},[Y]),ai=null!=li?li:oi,ri=o(function(){var i,t;return{MaximizeIcon:null!==(i=null==J?void 0:J.MaximizeIcon)&&void 0!==i?i:null===(t=N.iconsConfig)||void 0===t?void 0:t.MaximizeIcon,ExternalLinkIcon:null==J?void 0:J.ExternalLinkIcon}},[J,null===(s=N.iconsConfig)||void 0===s?void 0:s.MaximizeIcon]),si=o(function(){var t=Y?{bodyHeight:x(ti)}:Q&&ni?{bodyHeight:ni.gptBodyHeight}:{};return i(i(i(i({},N),t),{disableMaximize:void 0!==q?!q:N.disableMaximize}),ti||j===m.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[N,q,ti,j,Y,Q,ni]),di=l(j!==m.GPT),ui=di[0],ci=di[1],vi=j!==m.GPT&&(j===m.WEB||(null!=P?P:ui)),gi=void 0!==P,pi=o(function(){return T?b(T):null},[T]),mi=null!==(B=null!=E?E:null==pi?void 0:pi.topic)&&void 0!==B?B:"Web Citation",bi=null!==(H=null!=z?z:null==pi?void 0:pi.relevanceScore)&&void 0!==H?H:0,Ci=null!=G?G:null==pi?void 0:pi.learnedFrom,wi=C(null==pi?void 0:pi.highlightedUrl,null!==(L=null==pi?void 0:pi.citationUrl)&&void 0!==L?L:W),hi=w(T),fi=o(function(){return function(i,t,e){return e?"success":i||(t?"error":"pending")}(A,T,hi)},[A,T,hi]),ki=a(function(){U?U():gi||ci(!1)},[U,gi]),yi=a(function(){U?U():gi||ci(!0),hi||"success"===fi||null==M||M()},[U,gi,hi,fi,M]),xi=null!=V?V:"Source: Web Citation > ".concat(mi),Fi=function(n){var o=!!si.DocumentTitle,l=[I.gptCitationWrapper,o?I.gptCitationWrapperWithSource:"",ei?I.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return e("div",i({className:l,style:i(i({},$.gptWrapper),ai)},{children:[t(d,i({},si,{splitterCustomStyle:!0,onFullscreenChange:R})),n&&t("div",i(o?{className:I.gptCitationFooterAction,style:$.gptFooterAction}:{className:[I.gptCitationToggleFooter,ei?I.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:$.gptFooterAction},{children:n}))]}))};return _&&!vi?t("div",i({className:I.overlay,style:i(i({},$.container),li)},{children:Fi(ti?t(S,{variant:"web",onClick:yi,title:"View web-based citation for this source.",style:$.gptToggleButton}):void 0)})):ii?e("div",i({className:[I.panel,ei?I.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:i(i({},$.webPanel),ai)},{children:[e("div",i({className:I.panelHeader,style:$.webHeader},{children:[t("span",i({className:I.panelSource},{children:xi})),t("div",i({className:I.panelHeaderActions},{children:bi>0&&e("div",i({className:I.confidenceBadge,title:"Decision strength"},{children:[t(r,{size:14}),bi,"%"]}))}))]})),t("div",i({className:[I.panelContent,I.panelContentExpanded,ei?I.panelContentFixedHeight:""].filter(Boolean).join(" "),style:i(i({},$.webContent),ei?F():void 0)},{children:"pending"===fi?t(c,{status:"pending",citationUrl:wi,ExternalLinkIcon:ri.ExternalLinkIcon,styles:$.webSkeleton,visitLinkStyles:$.webSkeletonVisitLink,isFixedHeight:ei}):"success"===fi&&hi?t(u,{citationImage:hi,citationUrl:wi,showExpandImageButton:O,iconsConfig:ri,styles:$.webImage,visitLinkStyles:$.webImageVisitLink,skeletonStyles:$.webSkeleton,skeletonVisitLinkStyles:$.webSkeletonVisitLink,isFixedHeight:ei,onFullscreenChange:R}):t(c,{status:"error",citationUrl:wi,ExternalLinkIcon:ri.ExternalLinkIcon,styles:$.webSkeleton,visitLinkStyles:$.webSkeletonVisitLink,isFixedHeight:ei})})),e("div",i({className:I.panelFooter,style:$.webFooter},{children:[ti?t(S,{variant:"gpt",onClick:ki,style:$.webToggleButton}):null,Ci&&e("span",i({className:I.learnedFrom,style:$.webLearnedFrom},{children:["Learned From ",Ci]}))]}))]})):t("div",i({className:I.overlay,style:i(i({},$.container),li)},{children:Fi()}))};export{H as default};
|
|
2
2
|
//# sourceMappingURL=GptWebCitation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsxs as e,jsx as
|
|
1
|
+
import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import{useState as t,useRef as l,useEffect as o}from"react";import{Maximize2 as r,ExternalLink as a}from"lucide-react";import s from"./GptWebCitationImageFullScreenView.js";import c from"./GptWebCitationSkeleton.js";import{sanitizeExternalUrl as d}from"./utils/citationData.utils.js";import u from"./GptWebCitation.module.css.js";var m=function(m){var v,g,p=m.citationImage,f=m.citationUrl,C=m.skeletonVisitUrl,h=m.showExpandImageButton,k=void 0===h||h,y=m.iconsConfig,x=m.styles,w=m.visitLinkStyles,I=m.skeletonStyles,b=m.skeletonVisitLinkStyles,j=m.isFixedHeight,L=void 0!==j&&j,N=m.onFullscreenChange,S=null!==(v=null==y?void 0:y.MaximizeIcon)&&void 0!==v?v:r,B=null!==(g=null==y?void 0:y.ExternalLinkIcon)&&void 0!==g?g:a,F=t(!1),H=F[0],V=F[1],W=t("loading"),E=W[0],z=W[1],G=l(!1);o(function(){var i=!0;G.current&&(G.current=!1,null==N||N(!1)),z("loading"),V(!1);var e=new Image;return e.onload=function(){i&&z("loaded")},e.onerror=function(){i&&z("error")},e.src=p,function(){i=!1,e.onload=null,e.onerror=null}},[p,N]),o(function(){return function(){G.current&&(G.current=!1,null==N||N(!1))}},[N]);var U="loaded"===E,D=d(f);return e("div",i({className:[u.imageCitationWrapper,L?u.imageCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.wrapper},{children:[n("div",i({className:[u.imageCitationCenter,L?u.imageCitationCenterFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.center},{children:U?e("div",i({className:[u.imageCitationViewport,L?u.imageCitationViewportFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.viewport},{children:[n("div",i({className:[u.imageCitationScrollContainer,L?u.imageCitationScrollContainerFixedHeight:""].filter(Boolean).join(" "),style:null==x?void 0:x.scrollContainer},{children:n("img",{src:p,alt:"Web citation snapshot",className:[u.citationImage,L?u.citationImageContained:""].filter(Boolean).join(" "),style:null==x?void 0:x.image})})),k&&n("button",i({type:"button",onClick:function(i){i.stopPropagation(),G.current=!0,null==N||N(!0),V(!0)},className:u.expandImageButton,style:null==x?void 0:x.expandButton,"aria-label":"View citation image in full screen",title:"Expand image"},{children:n(S,{size:16,strokeWidth:2})}))]})):n(c,{status:"error"===E?"error":"pending",citationUrl:null!=C?C:f,ExternalLinkIcon:null==y?void 0:y.ExternalLinkIcon,styles:I,visitLinkStyles:b,isFixedHeight:L})})),D&&U&&e("div",i({className:u.visitLinkRow,style:null==w?void 0:w.row},{children:[n("span",i({className:u.visitLinkHint,style:null==w?void 0:w.hint},{children:"Open link in new tab to read in detail"})),e("a",i({href:D,target:"_blank",rel:"noreferrer",className:u.visitLink,style:null==w?void 0:w.link},{children:["Visit Link",n(B,{size:16})]}))]})),H&&U&&n(s,{src:p,onClose:function(){G.current=!1,null==N||N(!1),V(!1)},styles:null==x?void 0:x.fullScreen})]}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=GptWebCitationImageCitation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e="520px",
|
|
1
|
+
var e="520px",n="3.25rem",t=function(t,i){if(void 0===i&&(i=!0),!i){var o=null!=t?t:e;return{contentHeight:o,gptBodyHeight:o,panelHeight:o}}if(t)return{contentHeight:t,gptBodyHeight:t,panelHeight:"calc(".concat(t," + ").concat(n,")")};var c="calc(".concat(e," - ").concat(n,")");return{contentHeight:c,gptBodyHeight:c,panelHeight:e}},i=function(e){return{height:e,minHeight:e,maxHeight:e,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},o=function(){return{height:"100%",minHeight:0,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},c=function(e){return void 0===e&&(e=!0),e?"calc(100% - ".concat(n,")"):"100%"},r=function(){return{flex:1,minHeight:0,maxHeight:"none",overflow:"hidden",display:"flex",flexDirection:"column"}};export{i as getFixedPanelStyle,r as getFixedWebContentStyle,c as getParentHeightGptBodyHeight,o as getParentHeightPanelStyle,t as resolveFixedHeightLayout};
|
|
2
2
|
//# sourceMappingURL=fixedHeight.utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as r}from"tslib";import{jsx as e}from"react/jsx-runtime";import{Worker as o,Viewer as t}from"@react-pdf-viewer/core";import{pdfStyles as n}from"./PdfStyle.js";var i="https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js",l=function(l){var a=l.pdfUrl,d=l.plugins,f=l.onLoad,p=l.customStyles,m=l.onPageChange,s=l.defaultScale;return e("div",r({style:r(r({},n.pdfConatiner),null==p?void 0:p.pdfContainer)},{children:e(o,r({workerUrl:i},{children:e(t,{fileUrl:a,defaultScale:s,plugins:d,onDocumentLoad:f,onPageChange:m})}))}))};export{l as default,i as pdfWorker};
|
|
2
2
|
//# sourceMappingURL=PdfContainer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},header:{display:"flex",
|
|
1
|
+
var e={pdfViewer:{borderRadius:"12px",padding:"16px",width:"100%",height:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},card:{border:"2px solid #E5E7EB",backgroundColor:"#FFFFFF",borderRadius:"12px",width:"100%",minWidth:0,boxSizing:"border-box",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative",width:"100%",minWidth:0,boxSizing:"border-box"},title:{fontSize:"14px",fontWeight:600,color:"#60A3F8",fontFamily:'Roboto, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif'},toolbar:{display:"flex",alignItems:"center",gap:"8px",position:"relative"},button:{border:"1px solid #DFE5EC",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",cursor:"pointer",backgroundColor:"#FFFFFF"},buttonDisabled:{opacity:.4,cursor:"not-allowed"},counter:{fontSize:"13px",color:"#64748B",margin:"0 6px"},viewerWrapper:{height:"30rem",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center",border:"1px solid #DEE4EB",borderRadius:"8px"},emptyState:{fontSize:"14px",color:"#EF4444"},pdfConatiner:{height:"100%",overflow:"auto",display:"flex",justifyContent:"center",alignItems:"center"}};export{e as pdfStyles};
|
|
2
2
|
//# sourceMappingURL=PdfStyle.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as n,jsx as t}from"react/jsx-runtime";import{pdfStyles as i}from"./PdfStyle.js";import{DefaultPdfIcon as o,DefaultFullScreenIcon as l,DefaultDownloadIcon as r,DefaultCloseIcon as d}from"../../assests/svg/PdfViewerIcons.js";import{Tooltip as s}from"@mui/material";var c=function(c){c.highlightIndex;var a=c.totalHighlights,p=c.controls,h=c.currentPosition,u=c.pdfName,f=c.onClose,x=c.pdfUrl,g=c.viewerRef,m=c.customStyles,v=c.customClasses,y=c.customIcons,w=c.headerAction,b=c.isZoomEnabled,k=void 0===b||b,I=c.showHighlightsAction,C=void 0===I||I,S=c.showFullScreenAction,F=void 0===S||S,D=p.ZoomInButton,j=p.ZoomOutButton,L=p.ZoomPopover,W=p.goToPrevious,B=p.goToNext,A={padding:"4px",borderRadius:"6px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",flexShrink:0};return n("div",e({style:e(e({display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px",background:"#FAFAFA",borderBottom:"1px solid #F3F4F6",borderTopLeftRadius:"12px",borderTopRightRadius:"12px"},i.header),null==m?void 0:m.header)},{children:[n("div",e({style:{display:"flex",alignItems:"center",gap:"12px",flex:1,minWidth:0,overflow:"hidden"}},{children:[t("div",e({style:e(e(e({},{borderRadius:"21px",border:"6px solid #E8F3FF",background:"#D5E8FF",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",boxSizing:"content-box"}),null==m?void 0:m.pdfIconWrapper),{flexShrink:0})},{children:(null==y?void 0:y.pdfIcon)||t(o,{})})),t(s,e({title:u||"",arrow:!0,placement:"top"},{children:t("div",e({style:{flex:1,minWidth:0,overflow:"hidden"}},{children:t("span",e({style:e({display:"block",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:500,cursor:"default"},null==m?void 0:m.pdfName),className:null==v?void 0:v.pdfName},{children:u}))}))}))]})),n("div",e({style:{display:"flex",alignItems:"center",gap:C?"16px":"2px",color:"#4B5563",flexShrink:0,whiteSpace:"nowrap",minWidth:"fit-content"}},{children:[k&&n("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[t(j,{}),t("div",e({style:{fontSize:"14px",fontWeight:500,width:"56px",textAlign:"center"}},{children:t(L,{})})),t(D,{})]})),!!a&&C&&n("div",e({style:{display:"flex",alignItems:"center",gap:"4px"}},{children:[n("span",e({style:{fontSize:"14px",color:"#475467",fontWeight:500,lineHeight:1}},{children:[h," of ",a]})),t("button",e({style:{background:"none",border:"none",cursor:h<=1?"not-allowed":"pointer",padding:"2px 4px",color:h<=1?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:W,disabled:h<=1},{children:t("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:t("path",{d:"M2 8L6 4L10 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))})),t("button",e({style:{background:"none",border:"none",cursor:h===a?"not-allowed":"pointer",padding:"2px 4px",color:h===a?"#D0D5DD":"#475467",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,height:"20px",width:"20px"},onClick:B,disabled:h===a},{children:t("svg",e({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none"},{children:t("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}))}))]})),t("div",{style:{width:"1px",height:"20px",background:"#D1D5DB",margin:"0 4px",flexShrink:0}}),n("div",e({style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,whiteSpace:"nowrap"}},{children:[!1!==F&&((null==w?void 0:w.icon)&&(null==w?void 0:w.onClick)?t(s,e({title:(null==w?void 0:w.tooltip)||"",arrow:!0,placement:"top"},{children:t("div",e({onClick:w.onClick,style:e({display:"flex",alignItems:"center",cursor:"pointer"},A)},{children:w.icon}))})):t("button",e({onClick:function(){var e=null==g?void 0:g.current;e&&(document.fullscreenElement?document.exitFullscreen():e.requestFullscreen().catch(function(e){console.error("Error attempting to enable fullscreen: ".concat(e.message))}))},style:A,title:"Full Screen"},{children:(null==y?void 0:y.fullScreenIcon)||t(l,{})}))),x&&t("a",e({href:x,target:"_blank",rel:"noopener noreferrer",style:A,title:"Open in new tab"},{children:(null==y?void 0:y.downloadIcon)||t(r,{})})),f&&t("button",e({onClick:f,style:A,title:"Close"},{children:(null==y?void 0:y.closeIcon)||t(d,{})}))]}))]}))]}))};export{c as default};
|
|
2
2
|
//# sourceMappingURL=PdfToolbar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,w=m.highlightColor,T=void 0===w?"yellow":w,S=m.activeHighlightColor,y=void 0===S?"#f7dc51":S,A=m.jumpToPageValue,b=void 0===A?0:A,H=m.pdfName,I=m.onClose,j=m.customStyles,F=m.customClasses,z=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=m.showFullScreenAction,G=void 0===L||L,M=u(null),Q=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[P,C,N]),X=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Y=c(X,N?{}:C,M,Q,N,N?P:[],T,y),$=Y.highlightIndex,ee=Y.cursorIndex,te=Y.setCursorIndex,ie=Y.orderedKeys,oe=Y.totalHighlights,ne=Y.getValidPosition,re=Y.tryJump,ae=Y.jumpToPage,le=Y.zoomTo,se=Y.plugins,ce=Y.controls,ue=Y.hideNonTargetHighlights,de=Y.deduplicateHighlights,ge=ne(ee);g(function(){void 0!==R&&R!==ee&&te(R)},[R]);var fe=e(e({},ce),{goToNext:function(){ee>=oe-1||(ce.goToNext(),V&&V(ee+1))},goToPrevious:function(){ee<=0||(ce.goToPrevious(),V&&V(ee-1))}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:M,className:(null==F?void 0:F.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:$,totalHighlights:oe,controls:fe,currentPosition:ge,pdfName:H,onClose:I,pdfUrl:p,viewerRef:M,customStyles:j,customClasses:F,customIcons:z,headerAction:W,isZoomEnabled:D,showHighlightsAction:B,showFullScreenAction:G}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:se,customStyles:j,onLoad:function(){var e=!N&&!Z&&b<=0;if(le(r.ActualSize),b>0&&!Z){var o=b-1,n=ie[o],a=C[n],l=P[o];te(o),console.log(l,"cordinateTargetHighlight"),N&&l.pageIndex>0&&ae(l.pageIndex),a>0&&(setTimeout(function(){ue(Q),de(a-1)},1e3),N||ae(a-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,o,n,r;return i(this,function(i){switch(i.label){case 0:e=K[0],t=K[1],o=e,i.label=1;case 1:return o<=t?(ae(n=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(i.sent(),ue(Q),(r=de(n))&&r>0)return[3,4];i.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!N&&C){var s=ie.find(function(e){return C[e]>0});if(void 0!==s){var c=C[s]-1;ae(c),setTimeout(function(){ue(Q),de(c)},1e3)}}requestAnimationFrame(function(){e&&re(),!N&&b>0&&!Z&&function(){if(M.current){var e=b-1,t=ie[e],i=C[t],o=i>0?i-1:0,n={};ie.forEach(function(e,t){var i=C[e];i>0&&(n[i]||(n[i]=[]),n[i].push(t))});var r=(n[i]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var i=null===(e=M.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var n=null===(t=M.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(n){var s=i.getBoundingClientRect(),c=n.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=n.querySelectorAll(".rpv-search__highlight")[r];if(u){var d=u.getBoundingClientRect(),g=i.scrollTop+(d.top-s.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;Q.has(t)?(de(t),ue(Q)):ue(Q)}})]}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|