@viswa-test/test-citation 0.0.372 → 0.0.374
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/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/components/WebGptPanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.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/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.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/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/helper.js +1 -1
- package/dist/cjs/index.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/components/WebGptPanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.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/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.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/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
- package/dist/features/SegmentReviewComponents/helper.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
- 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/components/WebGptPanel.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
- package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.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 +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +0 -1
- 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 +1 -2
- package/dist/types/src/features/GptWebCitation/GptWebCitationImageCitation.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/types.d.ts +0 -11
- package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +0 -2
- package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfContainer.d.ts +4 -2
- 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.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +18 -2
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +3 -11
- package/dist/types/src/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/helper.d.ts +4 -1
- package/dist/types/src/features/SegmentReviewComponents/helper.d.ts.map +1 -1
- package/dist/types/src/features/SegmentReviewComponents/index.d.ts +0 -2
- package/dist/types/src/features/SegmentReviewComponents/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js"),s=require("../utils/normalizeRedlineMarkdown.js");function u(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var c=u(i);exports.default=function(u){var v,f,g,p,h,x,I,m,_,y,R,b,S,A,E,w=u.section,M=u.idx,O=u.columnKey,T=u.colRef,N=u.mb,D=void 0===N?1:N,j=u.isExpanded,B=u.onToggle,k=u.navigation,F=u.parentNodeId,C=void 0===F?"":F,P=r.useCompareContext(),V=P.showOpenNodeRef,G=P.resolvedMarkdownStyles,W=P.maintainRelativeOrder,q=P.showDeviationBadges,z=void 0!==q&&q,L=P.renderSubSectionAccordion,K=P.treeData,X=P.proposedSections,H=P.existingSections,U=P.deviationNumberRegistry,Y=P.deviationParentRegistry,J=P.getBadgeRef,Q=P.openSummaryPopup,Z=P.getSectionCompareStyle,$=P.connectedSections,nn=P.openMoreFunctionsPopup,en=P.isProposingFix,tn=P.proposingFixNodeId,on=P.isRedlineFlow,ln=P.isSideBySide,rn=P.activeSideBySideSection,dn=P.scrollSyncLocked,an=P.unifiedNumbering,sn=P.toggleScrollSyncLocked,un=P.summaryPopupAnchorEl,cn="".concat(ln?"1":"0","-").concat(String(null!=rn?rn:"")),vn=(null===(v=w.displayTitle)||void 0===v||v)&&d.hasValue(w.title),fn=!(!en||!tn||"left"!==O||w.id!==tn&&w.nodeId!==tn),gn=d.hasMeaningfulRedlineTags(w.content),pn="boolean"==typeof on?on:gn,hn=gn,xn=pn&&gn,In=c.default.useMemo(function(){return xn?s.normalizeRedlineMarkdown(d.safeStringify(w.content)):d.safeStringify(w.content)},[w.content,xn]),mn=xn?d.stripRedlineTags(In):w.content,_n=xn?In:void 0,yn=(null===(f=w.displayContent)||void 0===f||f||gn)&&d.hasValue(w.content),Rn=!vn&&!yn,bn=w.title;vn||(bn=yn?"No Title Found":"No Matching Section Found");var Sn="left"===O&&(w.isMultipleMapping||(null!==(p=null===(g=w.refContentIds)||void 0===g?void 0:g.length)&&void 0!==p?p:1)>1),An="left"===O&&bn.length>29?"".concat(bn.slice(0,29).trimEnd(),"..."):bn,En=w.evaluationResult;if(!En&&"right"===O)if(W){var wn=null===(h=w.refIndexes)||void 0===h?void 0:h[0],Mn=X.find(function(n){return n.selfIndex===wn});En=null==Mn?void 0:Mn.evaluationResult}else En=null===(x=X[M])||void 0===x?void 0:x.evaluationResult;var On=null===(I=null==K?void 0:K.input_index_map)||void 0===I?void 0:I[0],Tn=null===(m=null==K?void 0:K.input_index_map)||void 0===m?void 0:m[1],Nn="left"===O?Tn:On,Dn=function(n,e){var i;if(!e||!n)return null;for(var t=0,o=n;t<o.length;t++){var l=o[t];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=Dn(l.subsections,e);if(r)return r}}return null},jn="left"===O?w:Dn(X,w.id),Bn="right"===O?w:Dn(H,w.id),kn=c.default.useMemo(function(){if(!W)return 0;var n=1/0,e=function(n){var e=d.safeStringify(n||"").replace(/\\n/g,"\n");return d.hasMeaningfulRedlineTags(e)?d.stripRedlineTags(s.normalizeRedlineMarkdown(e)):e},i=function(t,o,l,r){if(t){var a=t.nodeId||t.id;if(r&&"right"===O){var s=X.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(t.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=t.nodeId||t.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=t.evaluationResult||(null==o?void 0:o.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var r,s=null===(r=v[i])||void 0===r?void 0:r[C];if(function(n,i){if("string"!=typeof i||d.isMissingStr(i))return!1;var t=e(null==n?void 0:n.content),o=e(i);return!!o&&!!d.findTextMatchRange(t,o)}("left"===O?o||t:l||t,s)){var c="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==U?void 0:U[c];null!=f&&f<n&&(n=f);var g="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),p=null==U?void 0:U[g];null!=p&&p<n&&(n=p)}});for(var f=t.subsections||[],g=(null==o?void 0:o.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(f.length,g.length,p.length),x=0;x<h;x++)i(f[x],g[x],p[x],!1)}},t="right"===O?X.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(w.selfIndex)}):[];if(1===t.length){var o=t[0];(o.refIndexes||[]).map(function(n){return H.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,o,n,!0)})}else i(w,jn,Bn,!0);return n!==1/0?n-1:0},[w,jn,Bn,O,C,U,W,X,H]);if(W)if("left"===O){var Fn=null===(_=w.refIndexes)||void 0===_?void 0:_[0],Cn=H.findIndex(function(n){return n.selfIndex===Fn});Bn=-1!==Cn?H[Cn]:Dn(H,w.id)}else{var Pn=null===(y=w.refIndexes)||void 0===y?void 0:y[0],Vn=X.findIndex(function(n){return n.selfIndex===Pn});jn=-1!==Vn?X[Vn]:Dn(X,w.id)}var Gn="left"===O?!Bn:!jn,Wn=W&&"right"===O&&d.hasSingleMappedLhsSection(w,X),qn=En||(null==jn?void 0:jn.evaluationResult)||(null==Bn?void 0:Bn.evaluationResult),zn=null!==(S=null===(b=null===(R=null==qn?void 0:qn.evaluation_outputs)||void 0===R?void 0:R.metadata)||void 0===b?void 0:b.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,Ln=d.generateColorPalette(zn).highlightBg,Kn=(null==qn?void 0:qn.deviations)||{},Xn=c.default.useMemo(function(){return W&&"right"===O?d.getLhsDeviationDisplayIndexes(X,On,U):new Map},[W,O,X,On,U]),Hn=w.nodeId||w.id;if(W&&"left"!==O){var Un=X.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(w.selfIndex)});Un.length>0?Hn=Un[0].nodeId||Un[0].id:(null==jn?void 0:jn.id)&&(Hn=jn.nodeId||jn.id)}var Yn=c.default.useMemo(function(){var n,e=new Map;if(!W||"right"!==O)return e;var i=1,t=X.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(w.selfIndex)}),o=1===t.length&&1===(null===(n=t[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return d.safeStringify(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?t[0]:Dn(X,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(o){var a=function(n,e){if(void 0===e&&(e=!1),n){var t=r(n,e),o=t.lhsNode,s=t.evalResult,u=t.registryNodeId,c=l(n.content);Object.entries((null==s?void 0:s.deviations)||{}).forEach(function(n){var e=n[0],t=n[1],r=t[C],a=l(r);if(!!o&&!d.isMissingStr(t[Nn])&&a&&d.findTextMatchRange(c,a)){var s="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),v=U[s];null!=v&&(i=Math.max(i,Math.max(1,v-(kn||0))+1))}}),(n.subsections||[]).forEach(function(n){return a(n)})}};a(w,!0)}var s=function(n,t){if(void 0===t&&(t=!1),n){var o=r(n,t),a=o.lhsNode,u=o.evalResult,c=o.registryNodeId,v=(null==u?void 0:u.deviations)||{},f=l(n.content);Object.entries(v).map(function(n){var e,i,t,o=n[0],r=n[1],s=r[C],u=!a||d.isMissingStr(r[Nn]),v=l(s),g=v&&null!==(i=null===(e=d.findTextMatchRange(f,v))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(d.DEVIATION_BADGE_SEPARATOR).concat(o);return{refId:p,isRenderable:u&&!!v&&!d.isMissingStr(s),position:g,registryIndex:null!==(t=U[p])&&void 0!==t?t: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 s(n)})}};return s(w,!0),e},[W,O,w,X,C,Nn,U,kn]),Jn=Object.keys(Kn)[0],Qn=Jn?"".concat(Hn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Jn):null,Zn=Qn?null==Y?void 0:Y[Qn]:null,$n=M+1;if(W&&an){var ne="left"===O?an.leftNums.get(null==w?void 0:w.id):an.rightNums.get(null==w?void 0:w.id);Gn&&void 0!==ne?$n=ne:null!=Zn&&Zn>=0?$n=Zn:void 0!==ne&&($n=ne)}else null!=Zn&&Zn>=0&&($n=Zn);var ee=Math.max.apply(Math,n.__spreadArray([0],Object.keys(Kn).map(function(n){return U["".concat(Hn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,ie=Object.entries(Kn).map(function(n){var e,i=n[0],t=n[1],o="".concat(Hn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i);return{deviationKey:i,deviationMap:t,refId:o,currentIndex:null!==(e=U[o])&&void 0!==e?e:ee++}});ie.sort(function(n,e){return n.currentIndex-e.currentIndex});var te,oe,le=ie.map(function(e){var i,t,o,l,r,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex,f=u[C],g=d.isMissingStr(f);if(g)f="";else if(!f)return null;var p=M,h=M;if(W)if("left"===O){var x=null===(i=w.refIndexes)||void 0===i?void 0:i[0],I=H.findIndex(function(n){return n.selfIndex===x});if(-1!==I)h=I;else{var m=H.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId});h=-1!==m?m:M}}else{var _=null===(t=w.refIndexes)||void 0===t?void 0:t[0],y=X.findIndex(function(n){return n.selfIndex===_});if(-1!==y)p=y;else p=-1!==(j=X.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))?j:M}var R="".concat(Hn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(p).concat(d.DEVIATION_BADGE_SEPARATOR).concat(h),b=u[Nn],S=Gn||d.isMissingStr(b),A=Yn.get(c),E=Xn.get(c);W&&"right"===O&&S&&void 0!==A?v=A:W&&"right"===O&&!S&&void 0!==E?v=E:W&&void 0!==kn&&("right"!==O||S||Wn)&&(v-=kn),v=Math.max(1,v);var T=W&&"right"===O&&S&&an?d.getRhsMappedSectionNumber({section:w,proposedSections:X,leftNums:an.leftNums,fallbackNumber:String($n),firstOnly:!0}):$n,N="".concat(T,".").concat(v),D=M;if("right"===O&&W){var j,B=null===(o=w.refIndexes)||void 0===o?void 0:o[0],k=X.findIndex(function(n){return n.selfIndex===B});if(-1!==k)D=k;else-1!==(j=X.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))&&(D=j)}var F=Z?Z(D):null,P=(null==u?void 0:u.evaluation_outputs)||(null==qn?void 0:qn.evaluation_outputs),V=null!==(l=null==P?void 0:P.output_value)&&void 0!==l?l:null,G=null!==(a=null===(r=null==P?void 0:P.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:zn,q=d.generateColorPalette(G),z=F?n.__assign(n.__assign({},F),{badgeBg:q.badgeBg,badgeBorder:q.badgeBorder,badgeText:q.badgeText}):n.__assign({},q),L=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==qn?void 0:qn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==qn?void 0:qn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==qn?void 0:qn.deviation_explanation),evaluation_outputs:P,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==qn?void 0:qn.cognitive_decisioning)}:null,K=0,U=mn||"";if(f&&U){var Y=U.split(/\n{2,}/),en=Y.findIndex(function(n){return n.includes(f)});if(-1!==en){var tn=Object.entries(Kn).filter(function(n){n[0];var e=n[1][C];return e&&Y[en].includes(e)}).sort(function(n,e){return Y[en].indexOf(n[1][C])-Y[en].indexOf(e[1][C])}),on=tn.filter(function(n){n[0];var e=n[1][C];return e&&(e.includes(f)||f.includes(e))});on.length>1&&(K=Math.max(0,on.findIndex(function(n){return n[0]===s})))}}var cn=J(O,c);return{id:c,actionId:R,label:N,highlight:f,side:O,style:z,stackIndex:K,score:V,isConnected:null==$?void 0:$.has(R),showScrollLockToggle:(null==$?void 0:$.has(R))||ln&&rn===R||!!un&&un===cn.current,scrollSyncLocked:dn,toggleScrollSyncLocked:sn,isOrphan:S,isMissingClause:g,badgeRef:cn,onClick:function(n){n.stopPropagation(),nn&&nn(n,jn||{id:"orphan-left",title:"",content:""},S,Bn||{id:"orphan-right",title:"",content:""},R,z)},onSummaryClick:function(n){n.stopPropagation(),Q(n,R,S,L)}}}).filter(Boolean),re=z||!pn&&fn?le:[],de=le.map(function(n){return n.highlight}).filter(Boolean),ae=w.id&&O===(null==k?void 0:k.columnKey)?k:null,se=c.default.useRef(!1);return i.useEffect(function(){j||(se.current=!1)},[j]),e.jsxs(t.Box,n.__assign({ref:T,sx:{mb:D,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[j&&(null==ae?void 0:ae.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ae?void 0:ae.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===O?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===O?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronUp,{color:(null===(A=null==ae?void 0:ae.showAboveRef)||void 0===A?void 0:A.current)?window.getComputedStyle(ae.showAboveRef.current).color:void 0})}))})),e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!Rn&&j,onChange:function(){Rn||(B(),V.current=w.id)},sx:{boxShadow:"none",border:Rn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Rn?"#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:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:Rn?null:e.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Rn?"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:vn&&e.jsx(t.Tooltip,n.__assign({title:bn,placement:"top"},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:Rn?"#94A3B8":"#19213D",fontWeight:Rn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(te=An,oe=Sn,void 0===oe&&(oe=!1),te?d.safeStringify(te).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,t){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},t):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",n.__assign({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:i})),oe&&e.jsx("span",n.__assign({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)}))}))})),!Rn&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[yn&&e.jsx(l.MemoizedMarkdown,{content:mn,overlayContent:_n,sxStyles:G,highlights:de,maintainRelativeOrder:W,highlightBg:Ln,suppressHighlightBg:hn,deviationBadges:re,collisionKey:cn}),(w.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(M,"-").concat(e),depth:0,columnKey:O,parentNodeId:C,sectionOffset:kn,rhsOrphanVisualIndexes:Yn})})]}))]})),j&&(null==ae?void 0:ae.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ae?void 0:ae.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===O?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===O?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronDown,{color:(null===(E=null==ae?void 0:ae.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(ae.showBelowRef.current).color:void 0})}))}))]}),"".concat(O,"-sec-").concat(M))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,g,p,h,x,I,m,_,y,b,S,A,R,E=s.section,w=s.idx,M=s.columnKey,O=s.colRef,N=s.mb,T=void 0===N?1:N,D=s.isExpanded,j=s.onToggle,B=s.navigation,C=s.parentNodeId,F=void 0===C?"":C,k=r.useCompareContext(),P=k.showOpenNodeRef,V=k.resolvedMarkdownStyles,G=k.maintainRelativeOrder,W=k.showDeviationBadges,q=void 0!==W&&W,L=k.renderSubSectionAccordion,z=k.treeData,K=k.proposedSections,X=k.existingSections,H=k.deviationNumberRegistry,U=k.deviationParentRegistry,Y=k.getBadgeRef,J=k.openSummaryPopup,Q=k.getSectionCompareStyle,Z=k.connectedSections,$=k.openMoreFunctionsPopup,nn=k.isProposingFix,en=k.proposingFixNodeId,tn=k.isRedlineFlow,on=k.isSideBySide,ln=k.activeSideBySideSection,rn=k.scrollSyncLocked,dn=k.unifiedNumbering,an=k.toggleScrollSyncLocked,sn=k.summaryPopupAnchorEl,un="".concat(on?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=E.displayTitle)||void 0===c||c)&&d.hasValue(E.title),vn=!(!nn||!en||"left"!==M||E.id!==en&&E.nodeId!==en),fn=d.hasMeaningfulRedlineTags(E.content),gn="boolean"==typeof tn?tn:fn,pn=fn,hn=gn&&fn,xn=hn?d.stripRedlineTags(E.content):E.content,In=hn?E.content:void 0,mn=(null===(v=E.displayContent)||void 0===v||v||fn)&&d.hasValue(E.content),_n=!cn&&!mn,yn=E.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn="left"===M&&(E.isMultipleMapping||(null!==(g=null===(f=E.refContentIds)||void 0===f?void 0:f.length)&&void 0!==g?g:1)>1),Sn="left"===M&&yn.length>29?"".concat(yn.slice(0,29).trimEnd(),"..."):yn,An=E.evaluationResult;if(!An&&"right"===M)if(G){var Rn=null===(p=E.refIndexes)||void 0===p?void 0:p[0],En=K.find(function(n){return n.selfIndex===Rn});An=null==En?void 0:En.evaluationResult}else An=null===(h=K[w])||void 0===h?void 0:h.evaluationResult;var wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[0],Mn=null===(I=null==z?void 0:z.input_index_map)||void 0===I?void 0:I[1],On="left"===M?Mn:wn,Nn=function(n,e){var i;if(!e||!n)return null;for(var t=0,o=n;t<o.length;t++){var l=o[t];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=Nn(l.subsections,e);if(r)return r}}return null},Tn="left"===M?E:Nn(K,E.id),Dn="right"===M?E:Nn(X,E.id),jn=u.default.useMemo(function(){if(!G)return 0;var n=1/0,e=function(n){var e=d.hasMeaningfulRedlineTags(n)?d.stripRedlineTags(n):n;return d.safeStringify(e||"").replace(/\\n/g,"\n")},i=function(t,o,l,r){if(t){var a=t.nodeId||t.id;if(r&&"right"===M){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(t.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=t.nodeId||t.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=t.evaluationResult||(null==o?void 0:o.evaluationResult)||(null==l?void 0:l.evaluationResult),v=(null==c?void 0:c.deviations)||{};Object.keys(v).forEach(function(i){var r,s=null===(r=v[i])||void 0===r?void 0:r[F];if(function(n,i){if("string"!=typeof i||d.isMissingStr(i))return!1;var t=e(null==n?void 0:n.content),o=e(i);return!!o&&t.includes(o)}("left"===M?o||t:l||t,s)){var c="".concat(a).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),f=null==H?void 0:H[c];null!=f&&f<n&&(n=f);var g="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i),p=null==H?void 0:H[g];null!=p&&p<n&&(n=p)}});for(var f=t.subsections||[],g=(null==o?void 0:o.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(f.length,g.length,p.length),x=0;x<h;x++)i(f[x],g[x],p[x],!1)}},t="right"===M?K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}):[];if(1===t.length){var o=t[0];(o.refIndexes||[]).map(function(n){return X.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,o,n,!0)})}else i(E,Tn,Dn,!0);return n!==1/0?n-1:0},[E,Tn,Dn,M,F,H,G,K,X]);if(G)if("left"===M){var Bn=null===(m=E.refIndexes)||void 0===m?void 0:m[0],Cn=X.findIndex(function(n){return n.selfIndex===Bn});Dn=-1!==Cn?X[Cn]:Nn(X,E.id)}else{var Fn=null===(_=E.refIndexes)||void 0===_?void 0:_[0],kn=K.findIndex(function(n){return n.selfIndex===Fn});Tn=-1!==kn?K[kn]:Nn(K,E.id)}var Pn="left"===M?!Dn:!Tn,Vn=G&&"right"===M&&d.hasSingleMappedLhsSection(E,K),Gn=An||(null==Tn?void 0:Tn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Wn=null!==(S=null===(b=null===(y=null==Gn?void 0:Gn.evaluation_outputs)||void 0===y?void 0:y.metadata)||void 0===b?void 0:b.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,qn=d.generateColorPalette(Wn).highlightBg,Ln=(null==Gn?void 0:Gn.deviations)||{},zn=u.default.useMemo(function(){return G&&"right"===M?d.getLhsDeviationDisplayIndexes(K,wn,H):new Map},[G,M,K,wn,H]),Kn=E.nodeId||E.id;if(G&&"left"!==M){var Xn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)});Xn.length>0?Kn=Xn[0].nodeId||Xn[0].id:(null==Tn?void 0:Tn.id)&&(Kn=Tn.nodeId||Tn.id)}var Hn=u.default.useMemo(function(){var n,e=new Map;if(!G||"right"!==M)return e;var i=1,t=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)}),o=1===t.length&&1===(null===(n=t[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return d.safeStringify(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?t[0]:Nn(K,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(o){var a=function(n,e){if(void 0===e&&(e=!1),n){var t=r(n,e),o=t.lhsNode,s=t.evalResult,u=t.registryNodeId,c=l(n.content);Object.entries((null==s?void 0:s.deviations)||{}).forEach(function(n){var e=n[0],t=n[1],r=t[F],a=l(r);if(!!o&&!d.isMissingStr(t[On])&&a&&c.includes(a)){var s="".concat(u).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e),v=H[s];null!=v&&(i=Math.max(i,Math.max(1,v-(jn||0))+1))}}),(n.subsections||[]).forEach(function(n){return a(n)})}};a(E,!0)}var s=function(n,t){if(void 0===t&&(t=!1),n){var o=r(n,t),a=o.lhsNode,u=o.evalResult,c=o.registryNodeId,v=(null==u?void 0:u.deviations)||{},f=l(n.content);Object.entries(v).map(function(n){var e,i=n[0],t=n[1],o=t[F],r=!a||d.isMissingStr(t[On]),s=l(o),u=s?f.indexOf(s):-1,v="".concat(c).concat(d.DEVIATION_BADGE_SEPARATOR).concat(i);return{refId:v,isRenderable:r&&!!s&&!d.isMissingStr(o),position:u,registryIndex:null!==(e=H[v])&&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 s(n)})}};return s(E,!0),e},[G,M,E,K,F,On,H,jn]),Un=Object.keys(Ln)[0],Yn=Un?"".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(Un):null,Jn=Yn?null==U?void 0:U[Yn]:null,Qn=w+1;if(G&&dn){var Zn="left"===M?dn.leftNums.get(null==E?void 0:E.id):dn.rightNums.get(null==E?void 0:E.id);Pn&&void 0!==Zn?Qn=Zn:null!=Jn&&Jn>=0?Qn=Jn:void 0!==Zn&&(Qn=Zn)}else null!=Jn&&Jn>=0&&(Qn=Jn);var $n=Object.entries(Ln).map(function(n){var e=n[0],i=n[1],t="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:H[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});$n.sort(function(n,e){return n.currentIndex-e.currentIndex});var ne,ee,ie=$n.map(function(e){var i,t,o,l,r,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex,f=u[F],g=d.isMissingStr(f);if(g)f="";else if(!f)return null;var p=w,h=w;if(G)if("left"===M){var x=null===(i=E.refIndexes)||void 0===i?void 0:i[0],I=X.findIndex(function(n){return n.selfIndex===x});if(-1!==I)h=I;else{var m=X.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId});h=-1!==m?m:w}}else{var _=null===(t=E.refIndexes)||void 0===t?void 0:t[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)p=y;else p=-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))?j:w}var b="".concat(Kn).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(p).concat(d.DEVIATION_BADGE_SEPARATOR).concat(h),S=u[On],A=Pn||d.isMissingStr(S),R=Hn.get(c),O=zn.get(c);G&&"right"===M&&A&&void 0!==R?v=R:G&&"right"===M&&!A&&void 0!==O?v=O:G&&void 0!==jn&&("right"!==M||A||Vn)&&(v-=jn),v=Math.max(1,v);var N=G&&"right"===M&&A&&dn?d.getRhsMappedSectionNumber({section:E,proposedSections:K,leftNums:dn.leftNums,fallbackNumber:String(Qn),firstOnly:!0}):Qn,T="".concat(N,".").concat(v),D=w;if("right"===M&&G){var j,B=null===(o=E.refIndexes)||void 0===o?void 0:o[0],C=K.findIndex(function(n){return n.selfIndex===B});if(-1!==C)D=C;else-1!==(j=K.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))&&(D=j)}var k=Q?Q(D):null,P=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),V=null!==(l=null==P?void 0:P.output_value)&&void 0!==l?l:null,W=null!==(a=null===(r=null==P?void 0:P.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Wn,q=d.generateColorPalette(W),L=k?n.__assign(n.__assign({},k),{badgeBg:q.badgeBg,badgeBorder:q.badgeBorder,badgeText:q.badgeText}):n.__assign({},q),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:P,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,H=0,U=xn||"";if(f&&U){var nn=U.split(/\n{2,}/),en=nn.findIndex(function(n){return n.includes(f)});if(-1!==en){var tn=Object.entries(Ln).filter(function(n){n[0];var e=n[1][F];return e&&nn[en].includes(e)}).sort(function(n,e){return nn[en].indexOf(n[1][F])-nn[en].indexOf(e[1][F])}),un=tn.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});un.length>1&&(H=Math.max(0,un.findIndex(function(n){return n[0]===s})))}}var cn=Y(M,c);return{id:c,actionId:b,label:T,highlight:f,side:M,style:L,stackIndex:H,score:V,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||on&&ln===b||!!sn&&sn===cn.current,scrollSyncLocked:rn,toggleScrollSyncLocked:an,isOrphan:A,isMissingClause:g,badgeRef:cn,onClick:function(n){n.stopPropagation(),$&&$(n,Tn||{id:"orphan-left",title:"",content:""},A,Dn||{id:"orphan-right",title:"",content:""},b,L)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,A,z)}}}).filter(Boolean),te=q||!gn&&vn?ie:[],oe=ie.map(function(n){return n.highlight}).filter(Boolean),le=E.id&&M===(null==B?void 0:B.columnKey)?B:null,re=u.default.useRef(!1);return i.useEffect(function(){D||(re.current=!1)},[D]),e.jsxs(t.Box,n.__assign({ref:O,sx:{mb:T,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==le?void 0:le.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronUp,{color:(null===(A=null==le?void 0:le.showAboveRef)||void 0===A?void 0:A.current)?window.getComputedStyle(le.showAboveRef.current).color:void 0})}))})),e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(j(),P.current=E.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#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:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"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:cn&&e.jsx(t.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ne=Sn,ee=bn,void 0===ee&&(ee=!1),ne?d.safeStringify(ne).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,t){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},t):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",n.__assign({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:i})),ee&&e.jsx("span",n.__assign({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)}))}))})),!_n&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:xn,overlayContent:In,sxStyles:V,highlights:oe,maintainRelativeOrder:G,highlightBg:qn,suppressHighlightBg:pn,deviationBadges:te,collisionKey:un}),(E.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(w,"-").concat(e),depth:0,columnKey:M,parentNodeId:F,sectionOffset:jn,rhsOrphanVisualIndexes:Hn})})]}))]})),D&&(null==le?void 0:le.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==le?void 0:le.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===M?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===M?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(o.ChevronDown,{color:(null===(R=null==le?void 0:le.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(le.showBelowRef.current).color:void 0})}))}))]}),"".concat(M,"-sec-").concat(w))};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CompareContext.js"),a=require("../CognitiveComparehelpers.js"),d=require("../CognitiveCompareConstants.js"),s=require("../utils/normalizeRedlineMarkdown.js");function u(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var c=u(i).default.memo(function(u){var v,f,p,g,h,m,_,x,S,y,I=u.section,b=u.keyPath,A=u.depth,M=void 0===A?0:A,E=u.columnKey,O=void 0===E?"left":E,R=u.parentNodeId,k=void 0===R?"":R,N=u.sectionOffset,P=u.rhsOrphanVisualIndexes,B=r.useCompareContext(),j=B.expandedSubSections,w=B.setExpandedSubSections,C=B.maintainRelativeOrder,T=B.showDeviationBadges,D=void 0!==T&&T,F=B.proposedSections,V=B.existingSections,q=B.treeData,L=B.deviationNumberRegistry,G=B.deviationParentRegistry,z=B.connectedSections,K=B.activeSideBySideSection,W=B.isSideBySide,H=B.scrollSyncLocked,U=B.toggleScrollSyncLocked,X=B.summaryPopupAnchorEl,J=B.resolvedMarkdownStyles,Q=B.getSubSectionRef,Y=B.getSubSectionCompareStyle,Z=B.getBadgeRef,$=B.openMoreFunctionsPopup,nn=B.openSummaryPopup,en=B.resetSideBySide,tn=B.setConnectedSections,on=B.setConnectedLines,ln=B.cachedConnectedPositions,rn=B.isProposingFix,an=B.proposingFixNodeId,dn=B.isRedlineFlow,sn=B.unifiedNumbering,un=null!=K?K:"",cn=(null===(v=I.displayTitle)||void 0===v||v)&&a.hasValue(I.title),vn=!(!rn||!an||"left"!==O||I.id!==an&&I.nodeId!==an),fn=a.hasMeaningfulRedlineTags(I.content),pn="boolean"==typeof dn?dn:fn,gn=fn,hn=pn&&fn,mn=i.useMemo(function(){return hn?s.normalizeRedlineMarkdown(a.safeStringify(I.content)):a.safeStringify(I.content)},[I.content,hn]),_n=hn?a.stripRedlineTags(mn):I.content,xn=hn?mn:void 0,Sn=(null===(f=I.displayContent)||void 0===f||f||fn)&&a.hasValue(I.content),yn=!cn&&!Sn,In=cn?I.title:Sn?"No Title Found":"No Matching Section Found",bn=!!j[b],An=Q(O,b),Mn=b.split("-").map(Number)[0],En=F[Mn],On=V[Mn],Rn=Mn,kn=Mn,Nn=!1,Pn=function(n,e,i){if(!n||!e)return null;if(n.id===e||n.nodeId===e||n.contentId===e)return{section:n,keyPath:i};for(var t=(n.subsections||[]).map(function(n,e){return{section:n,keyPath:"".concat(i,"-").concat(e)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===e||n.section.nodeId===e||n.section.contentId===e?{value:n}:void(n.section.subsections||[]).forEach(function(e,i){t.push({section:e,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(C)if("left"===O){var Bn=null===(p=null==En?void 0:En.refIndexes)||void 0===p?void 0:p[0],jn=V.findIndex(function(n){return n.selfIndex===Bn});-1!==jn?(On=V[jn],kn=jn):Nn=!0}else{var wn=null===(g=null==On?void 0:On.refIndexes)||void 0===g?void 0:g[0],Cn=F.findIndex(function(n){return n.selfIndex===wn});-1!==Cn?(En=F[Cn],Rn=Cn):Nn=!0}var Tn=function(n,e){if(!e||!n)return null;for(var i=0;i<n.length;i++){var t=Pn(n[i],e,String(i));if(t)return t}return null},Dn=null,Fn=null,Vn="",qn="";if(C)"left"===O?(Dn=I,Vn=b,(Ln=Pn(On,I.nodeId||I.id,String(kn)))||(Ln=Tn(V,I.nodeId||I.id)),Fn=(null==Ln?void 0:Ln.section)||null,qn=(null==Ln?void 0:Ln.keyPath)||""):(Fn=I,qn=b,(Gn=Pn(En,I.nodeId||I.id,String(Rn)))||(Gn=Tn(F,I.nodeId||I.id)),Dn=(null==Gn?void 0:Gn.section)||null,Vn=(null==Gn?void 0:Gn.keyPath)||"");else if("left"===O){Dn=I,Vn=b;var Ln=Tn(V,I.nodeId||I.id);Fn=(null==Ln?void 0:Ln.section)||null,qn=(null==Ln?void 0:Ln.keyPath)||""}else{Fn=I,qn=b;var Gn=Tn(F,I.nodeId||I.id);Dn=(null==Gn?void 0:Gn.section)||null,Vn=(null==Gn?void 0:Gn.keyPath)||""}var zn=(Vn?Y(Vn):null)||Y(b),Kn=null===(h=null==q?void 0:q.input_index_map)||void 0===h?void 0:h[0],Wn=null===(m=null==q?void 0:q.input_index_map)||void 0===m?void 0:m[1],Hn="left"===O?Wn:Kn,Un="left"===O?!Fn:!Dn,Xn=C&&"right"===O&&a.hasSingleMappedLhsSection(On,F),Jn=I.evaluationResult||(null==Dn?void 0:Dn.evaluationResult)||(null==Fn?void 0:Fn.evaluationResult),Qn=(null==Jn?void 0:Jn.deviations)||{},Yn=i.useMemo(function(){return C&&"right"===O?a.getLhsDeviationDisplayIndexes(F,Kn,L):new Map},[C,O,F,Kn,L]),Zn=I.nodeId||I.id||(null==Dn?void 0:Dn.nodeId)||(null==Dn?void 0:Dn.id)||(null==Fn?void 0:Fn.nodeId)||(null==Fn?void 0:Fn.id);C&&"left"!==O&&(null==Dn?void 0:Dn.id)&&(Zn=Dn.nodeId||Dn.id);var $n=Object.keys(Qn)[0],ne=$n?"".concat(Zn).concat(a.DEVIATION_BADGE_SEPARATOR).concat($n):null,ee=ne?null==G?void 0:G[ne]:null,ie=Mn+1;if(C&&sn){var te="left"===O?sn.leftNums.get(null==En?void 0:En.id):sn.rightNums.get(null==On?void 0:On.id);Nn&&void 0!==te?ie=te:null!=ee&&ee>=0?ie=ee:void 0!==te&&(ie=te)}else null!=ee&&ee>=0&&(ie=ee);var oe=null!==(S=null===(x=null===(_=null==Jn?void 0:Jn.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===x?void 0:x.label_color)&&void 0!==S?S:d.DEFAULT_DEVIAION_COLOR,le=a.generateColorPalette(oe).highlightBg,re=Math.max.apply(Math,n.__spreadArray([0],Object.keys(Qn).map(function(n){return L["".concat(Zn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,ae=Object.entries(Qn).map(function(n){var e,i=n[0],t=n[1],o="".concat(Zn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(i);return{deviationKey:i,deviationMap:t,refId:o,currentIndex:null!==(e=L[o])&&void 0!==e?e:re++}});ae.sort(function(n,e){return n.currentIndex-e.currentIndex});var de=new Map;if(!P&&C&&"right"===O){var se=a.safeStringify(_n||"").replace(/\\n/g,"\n");ae.filter(function(n){var e=n.deviationMap,i=e[k];return(Un||a.isMissingStr(e[Hn]))&&!!i&&!a.isMissingStr(i)}).map(function(e){var i,t,o=a.safeStringify(e.deviationMap[k]||"").replace(/\\n/g,"\n"),l=o&&null!==(t=null===(i=a.findTextMatchRange(se,o))||void 0===i?void 0:i.start)&&void 0!==t?t:-1;return n.__assign(n.__assign({},e),{position:l})}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.currentIndex-e.currentIndex}).forEach(function(n,e){de.set(n.refId,e+1)})}var ue=ae.map(function(e){var i,t,o,l,r=e.deviationKey,d=e.deviationMap,s=e.refId,u=e.currentIndex,c=d[k],v=a.isMissingStr(c);if(v)c="";else if(!c)return null;var f=d[Hn],p=Un||a.isMissingStr(f),g=null!==(i=null==P?void 0:P.get(s))&&void 0!==i?i:de.get(s),h=Yn.get(s);C&&"right"===O&&p&&void 0!==g?u=g:C&&"right"===O&&!p&&void 0!==h?u=h:C&&void 0!==N&&("right"!==O||p||Xn)&&(u-=N),u=Math.max(1,u);var m=C&&"right"===O&&p&&sn?a.getRhsMappedSectionNumber({section:On,proposedSections:F,leftNums:sn.leftNums,fallbackNumber:String(ie),firstOnly:!0}):ie,_="".concat(m,".").concat(u),x="".concat(Zn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(r).concat(a.DEVIATION_BADGE_SEPARATOR).concat(Vn).concat(a.DEVIATION_BADGE_SEPARATOR).concat(qn),S=(null==d?void 0:d.evaluation_outputs)||(null==Jn?void 0:Jn.evaluation_outputs),y=null!==(t=null==S?void 0:S.output_value)&&void 0!==t?t:null,I=null!==(l=null===(o=null==S?void 0:S.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:oe,b=a.generateColorPalette(I),A=n.__assign({},b),M=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null==Jn?void 0:Jn.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==Jn?void 0:Jn.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==Jn?void 0:Jn.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==Jn?void 0:Jn.deviation_explanation),evaluation_outputs:S,cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==Jn?void 0:Jn.cognitive_decisioning)}:null,E=0,R=_n||"";if(c&&R){var B=R.split(/\n{2,}/),j=B.findIndex(function(n){return n.includes(c)});if(-1!==j){var w=Object.entries(Qn).filter(function(n){n[0];var e=n[1][k];return e&&B[j].includes(e)}).sort(function(n,e){return B[j].indexOf(n[1][k])-B[j].indexOf(e[1][k])}),T=w.filter(function(n){n[0];var e=n[1][k];return e&&(e.includes(c)||c.includes(e))});T.length>1&&(E=Math.max(0,T.findIndex(function(n){return n[0]===r})))}}var D=Z(O,s);return{id:s,actionId:x,label:_,highlight:c,side:O,style:A,stackIndex:E,score:y,isConnected:z.has(x),showScrollLockToggle:z.has(x)||W&&K===x||!!X&&X===D.current,scrollSyncLocked:H,toggleScrollSyncLocked:U,isOrphan:p,isMissingClause:v,badgeRef:D,onClick:function(e){e.stopPropagation();var i=Vn&&F[Number(Vn.split("-")[0])]||En,t=qn&&V[Number(qn.split("-")[0])]||On,o=Dn?n.__assign(n.__assign({},Dn),{title:(null==i?void 0:i.title)||(null==Dn?void 0:Dn.title)||""}):{id:"orphan-left",title:"",content:""},l=Fn?n.__assign(n.__assign({},Fn),{title:(null==t?void 0:t.title)||(null==Fn?void 0:Fn.title)||""}):{id:"orphan-right",title:"",content:""};$(e,o,p,l,x,A)},onSummaryClick:function(n){n.stopPropagation(),nn(n,x,p,M)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),ce=i.useMemo(function(){var n=new Set;return ue.filter(function(e){return!n.has(e.id)&&(n.add(e.id),!0)})},[ue]),ve=D||!pn&&vn?ce:[],fe=ce.map(function(n){return n.highlight}).filter(Boolean),pe=ue.find(function(n){return z.has(n.actionId)}),ge=!!pe;if(!(cn||Sn||I.subsections&&0!==I.subsections.length))return null;var he=(null===(y=null==pe?void 0:pe.style)||void 0===y?void 0:y.badgeBorder)||(null==zn?void 0:zn.badgeBorder),me=ge&&he?{borderRadius:"4px",outline:"2px solid ".concat(he),outlineOffset:"1px"}:{};return cn?e.jsx(t.Box,n.__assign({ref:An,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},me)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!yn&&bn,onChange:function(){if(!yn){if(bn){var e=String(K||""),i=e.includes(Vn)||e.includes(qn);i||z.forEach(function(n){(String(n).includes(Vn)||String(n).includes(qn))&&(i=!0)}),i&&(en(),tn(new Set),on([]),ln.current=[])}w(function(e){var i;return n.__assign(n.__assign({},e),((i={})[b]=!e[b],i))})}},sx:{mt:0,boxShadow:"none",border:yn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:yn?null:e.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:yn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:In||"Untitled Subsection"}))})),!yn&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[Sn&&e.jsx(l.MemoizedMarkdown,{content:_n,overlayContent:xn,sxStyles:J,deviationBadges:ve,maintainRelativeOrder:C,highlightBg:le,suppressHighlightBg:gn,highlights:fe,collisionKey:un}),(I.subsections||[]).map(function(n,i){return e.jsx(c,{section:n,keyPath:"".concat(b,"-").concat(i),depth:M+1,columnKey:O,parentNodeId:k,sectionOffset:N,rhsOrphanVisualIndexes:P},"".concat(b,"-").concat(i))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:An,sx:{mt:0===M?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!yn&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},me)},{children:[Sn&&e.jsx(l.MemoizedMarkdown,{content:_n,overlayContent:xn,sxStyles:J,deviationBadges:ve,maintainRelativeOrder:C,highlightBg:le,suppressHighlightBg:gn,highlights:fe,collisionKey:un}),(I.subsections||[]).map(function(n,i){return e.jsx(c,{section:n,keyPath:"".concat(b,"-").concat(i),depth:M+1,columnKey:O,parentNodeId:k,sectionOffset:N,rhsOrphanVisualIndexes:P},"".concat(b,"-").concat(i))})]}))}))});exports.default=c;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i).default.memo(function(s){var c,v,f,g,p,h,_,m,x,S,I=s.section,y=s.keyPath,b=s.depth,O=void 0===b?0:b,A=s.columnKey,E=void 0===A?"left":A,M=s.parentNodeId,R=void 0===M?"":M,P=s.sectionOffset,k=s.rhsOrphanVisualIndexes,B=d.useCompareContext(),C=B.expandedSubSections,N=B.setExpandedSubSections,j=B.maintainRelativeOrder,w=B.showDeviationBadges,F=void 0!==w&&w,D=B.proposedSections,T=B.existingSections,V=B.treeData,L=B.deviationNumberRegistry,q=B.deviationParentRegistry,G=B.connectedSections,K=B.activeSideBySideSection,W=B.isSideBySide,z=B.scrollSyncLocked,H=B.toggleScrollSyncLocked,U=B.summaryPopupAnchorEl,X=B.resolvedMarkdownStyles,J=B.getSubSectionRef,Q=B.getSubSectionCompareStyle,Y=B.getBadgeRef,Z=B.openMoreFunctionsPopup,$=B.openSummaryPopup,nn=B.resetSideBySide,en=B.setConnectedSections,tn=B.setConnectedLines,on=B.cachedConnectedPositions,ln=B.isProposingFix,dn=B.proposingFixNodeId,rn=B.isRedlineFlow,an=B.unifiedNumbering,sn=null!=K?K:"",un=(null===(c=I.displayTitle)||void 0===c||c)&&r.hasValue(I.title),cn=!(!ln||!dn||"left"!==E||I.id!==dn&&I.nodeId!==dn),vn=r.hasMeaningfulRedlineTags(I.content),fn="boolean"==typeof rn?rn:vn,gn=vn,pn=fn&&vn,hn=pn?r.stripRedlineTags(I.content):I.content,_n=pn?I.content:void 0,mn=(null===(v=I.displayContent)||void 0===v||v||vn)&&r.hasValue(I.content),xn=!un&&!mn,Sn=un?I.title:mn?"No Title Found":"No Matching Section Found",In=!!C[y],yn=J(E,y),bn=y.split("-").map(Number)[0],On=D[bn],An=T[bn],En=bn,Mn=bn,Rn=!1,Pn=function(n,e,i){if(!n||!e)return null;if(n.id===e||n.nodeId===e||n.contentId===e)return{section:n,keyPath:i};for(var t=(n.subsections||[]).map(function(n,e){return{section:n,keyPath:"".concat(i,"-").concat(e)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===e||n.section.nodeId===e||n.section.contentId===e?{value:n}:void(n.section.subsections||[]).forEach(function(e,i){t.push({section:e,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(j)if("left"===E){var kn=null===(f=null==On?void 0:On.refIndexes)||void 0===f?void 0:f[0],Bn=T.findIndex(function(n){return n.selfIndex===kn});-1!==Bn?(An=T[Bn],Mn=Bn):Rn=!0}else{var Cn=null===(g=null==An?void 0:An.refIndexes)||void 0===g?void 0:g[0],Nn=D.findIndex(function(n){return n.selfIndex===Cn});-1!==Nn?(On=D[Nn],En=Nn):Rn=!0}var jn=function(n,e){if(!e||!n)return null;for(var i=0;i<n.length;i++){var t=Pn(n[i],e,String(i));if(t)return t}return null},wn=null,Fn=null,Dn="",Tn="";if(j)"left"===E?(wn=I,Dn=y,(Vn=Pn(An,I.nodeId||I.id,String(Mn)))||(Vn=jn(T,I.nodeId||I.id)),Fn=(null==Vn?void 0:Vn.section)||null,Tn=(null==Vn?void 0:Vn.keyPath)||""):(Fn=I,Tn=y,(Ln=Pn(On,I.nodeId||I.id,String(En)))||(Ln=jn(D,I.nodeId||I.id)),wn=(null==Ln?void 0:Ln.section)||null,Dn=(null==Ln?void 0:Ln.keyPath)||"");else if("left"===E){wn=I,Dn=y;var Vn=jn(T,I.nodeId||I.id);Fn=(null==Vn?void 0:Vn.section)||null,Tn=(null==Vn?void 0:Vn.keyPath)||""}else{Fn=I,Tn=y;var Ln=jn(D,I.nodeId||I.id);wn=(null==Ln?void 0:Ln.section)||null,Dn=(null==Ln?void 0:Ln.keyPath)||""}var qn=(Dn?Q(Dn):null)||Q(y),Gn=null===(p=null==V?void 0:V.input_index_map)||void 0===p?void 0:p[0],Kn=null===(h=null==V?void 0:V.input_index_map)||void 0===h?void 0:h[1],Wn="left"===E?Kn:Gn,zn="left"===E?!Fn:!wn,Hn=j&&"right"===E&&r.hasSingleMappedLhsSection(An,D),Un=I.evaluationResult||(null==wn?void 0:wn.evaluationResult)||(null==Fn?void 0:Fn.evaluationResult),Xn=(null==Un?void 0:Un.deviations)||{},Jn=i.useMemo(function(){return j&&"right"===E?r.getLhsDeviationDisplayIndexes(D,Gn,L):new Map},[j,E,D,Gn,L]),Qn=I.nodeId||I.id||(null==wn?void 0:wn.nodeId)||(null==wn?void 0:wn.id)||(null==Fn?void 0:Fn.nodeId)||(null==Fn?void 0:Fn.id);j&&"left"!==E&&(null==wn?void 0:wn.id)&&(Qn=wn.nodeId||wn.id);var Yn=Object.keys(Xn)[0],Zn=Yn?"".concat(Qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(Yn):null,$n=Zn?null==q?void 0:q[Zn]:null,ne=bn+1;if(j&&an){var ee="left"===E?an.leftNums.get(null==On?void 0:On.id):an.rightNums.get(null==An?void 0:An.id);Rn&&void 0!==ee?ne=ee:null!=$n&&$n>=0?ne=$n:void 0!==ee&&(ne=ee)}else null!=$n&&$n>=0&&(ne=$n);var ie=null!==(x=null===(m=null===(_=null==Un?void 0:Un.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===m?void 0:m.label_color)&&void 0!==x?x:a.DEFAULT_DEVIAION_COLOR,te=r.generateColorPalette(ie).highlightBg,oe=Object.entries(Xn).map(function(n){var e=n[0],i=n[1],t="".concat(Qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:L[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});oe.sort(function(n,e){return n.currentIndex-e.currentIndex});var le=new Map;if(!k&&j&&"right"===E){var de=r.safeStringify(hn||"").replace(/\\n/g,"\n");oe.filter(function(n){var e=n.deviationMap,i=e[R];return(zn||r.isMissingStr(e[Wn]))&&!!i&&!r.isMissingStr(i)}).map(function(e){var i=r.safeStringify(e.deviationMap[R]||"").replace(/\\n/g,"\n"),t=i?de.indexOf(i):-1;return n.__assign(n.__assign({},e),{position:t})}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.currentIndex-e.currentIndex}).forEach(function(n,e){le.set(n.refId,e+1)})}var re=oe.map(function(e){var i,t,o,l,d=e.deviationKey,a=e.deviationMap,s=e.refId,u=e.currentIndex,c=a[R],v=r.isMissingStr(c);if(v)c="";else if(!c)return null;var f=a[Wn],g=zn||r.isMissingStr(f),p=null!==(i=null==k?void 0:k.get(s))&&void 0!==i?i:le.get(s),h=Jn.get(s);j&&"right"===E&&g&&void 0!==p?u=p:j&&"right"===E&&!g&&void 0!==h?u=h:j&&void 0!==P&&("right"!==E||g||Hn)&&(u-=P),u=Math.max(1,u);var _=j&&"right"===E&&g&&an?r.getRhsMappedSectionNumber({section:An,proposedSections:D,leftNums:an.leftNums,fallbackNumber:String(ne),firstOnly:!0}):ne,m="".concat(_,".").concat(u),x="".concat(Qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(d).concat(r.DEVIATION_BADGE_SEPARATOR).concat(Dn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(Tn),S=(null==a?void 0:a.evaluation_outputs)||(null==Un?void 0:Un.evaluation_outputs),I=null!==(t=null==S?void 0:S.output_value)&&void 0!==t?t:null,y=null!==(l=null===(o=null==S?void 0:S.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:ie,b=r.generateColorPalette(y),O=n.__assign({},b),A=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary||(null==Un?void 0:Un.deviation_summary),deviation_title:(null==a?void 0:a.deviation_title)||(null==Un?void 0:Un.deviation_title),deviation_impact:(null==a?void 0:a.deviation_impact)||(null==Un?void 0:Un.deviation_impact),deviation_explanation:(null==a?void 0:a.deviation_explanation)||(null==Un?void 0:Un.deviation_explanation),evaluation_outputs:S,cognitive_decisioning:(null==a?void 0:a.cognitive_decisioning)||(null==Un?void 0:Un.cognitive_decisioning)}:null,M=0,B=hn||"";if(c&&B){var C=B.split(/\n{2,}/),N=C.findIndex(function(n){return n.includes(c)});if(-1!==N){var w=Object.entries(Xn).filter(function(n){n[0];var e=n[1][R];return e&&C[N].includes(e)}).sort(function(n,e){return C[N].indexOf(n[1][R])-C[N].indexOf(e[1][R])}),F=w.filter(function(n){n[0];var e=n[1][R];return e&&(e.includes(c)||c.includes(e))});F.length>1&&(M=Math.max(0,F.findIndex(function(n){return n[0]===d})))}}var T=Y(E,s);return{id:s,actionId:x,label:m,highlight:c,side:E,style:O,stackIndex:M,score:I,isConnected:G.has(x),showScrollLockToggle:G.has(x)||W&&K===x||!!U&&U===T.current,scrollSyncLocked:z,toggleScrollSyncLocked:H,isOrphan:g,isMissingClause:v,badgeRef:T,onClick:function(e){e.stopPropagation();var i=wn?n.__assign(n.__assign({},wn),{title:(null==On?void 0:On.title)||(null==wn?void 0:wn.title)||""}):{id:"orphan-left",title:"",content:""},t=Fn?n.__assign(n.__assign({},Fn),{title:(null==An?void 0:An.title)||(null==Fn?void 0:Fn.title)||""}):{id:"orphan-right",title:"",content:""};Z(e,i,g,t,x,O)},onSummaryClick:function(n){n.stopPropagation(),$(n,x,g,A)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),ae=i.useMemo(function(){var n=new Set;return re.filter(function(e){return!n.has(e.id)&&(n.add(e.id),!0)})},[re]),se=F||!fn&&cn?ae:[],ue=ae.map(function(n){return n.highlight}).filter(Boolean),ce=re.find(function(n){return G.has(n.actionId)}),ve=!!ce;if(!(un||mn||I.subsections&&0!==I.subsections.length))return null;var fe=(null===(S=null==ce?void 0:ce.style)||void 0===S?void 0:S.badgeBorder)||(null==qn?void 0:qn.badgeBorder),ge=ve&&fe?{borderRadius:"4px",outline:"2px solid ".concat(fe),outlineOffset:"1px"}:{};return un?e.jsx(t.Box,n.__assign({ref:yn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},ge)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!xn&&In,onChange:function(){if(!xn){if(In){var e=String(K||""),i=e.includes(Dn)||e.includes(Tn);i||G.forEach(function(n){(String(n).includes(Dn)||String(n).includes(Tn))&&(i=!0)}),i&&(nn(),en(new Set),tn([]),on.current=[])}N(function(e){var i;return n.__assign(n.__assign({},e),((i={})[y]=!e[y],i))})}},sx:{mt:0,boxShadow:"none",border:xn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:xn?null:e.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:xn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Sn||"Untitled Subsection"}))})),!xn&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:hn,overlayContent:_n,sxStyles:X,deviationBadges:se,maintainRelativeOrder:j,highlightBg:te,suppressHighlightBg:gn,highlights:ue,collisionKey:sn}),(I.subsections||[]).map(function(n,i){return e.jsx(u,{section:n,keyPath:"".concat(y,"-").concat(i),depth:O+1,columnKey:E,parentNodeId:R,sectionOffset:P,rhsOrphanVisualIndexes:k},"".concat(y,"-").concat(i))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:yn,sx:{mt:0===O?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!xn&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},ge)},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:hn,overlayContent:_n,sxStyles:X,deviationBadges:se,maintainRelativeOrder:j,highlightBg:te,suppressHighlightBg:gn,highlights:ue,collisionKey:sn}),(I.subsections||[]).map(function(n,i){return e.jsx(u,{section:n,keyPath:"".concat(y,"-").concat(i),depth:O+1,columnKey:E,parentNodeId:R,sectionOffset:P,rhsOrphanVisualIndexes:k},"".concat(y,"-").concat(i))})]}))}))});exports.default=u;
|
|
2
2
|
//# sourceMappingURL=SubSectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),r=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),l=require("../CognitiveComparehelpers.js"),s=require("rehype-raw"),d=require("remark-gfm"),c=require("../utils/normalizeRedlineMarkdown.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=u(i),g=u(a),p=u(s),f=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},v=[f(u(d).default)],x=[f(p.default)],m=h.default.memo(function(a){var s=a.content,d=a.overlayContent,u=a.sxStyles,p=a.deviationBadges,f=void 0===p?[]:p,m=a.highlights,_=void 0===m?[]:m;a.maintainRelativeOrder;var b=a.highlightBg,y=a.suppressHighlightBg,B=void 0!==y&&y,E=a.collisionKey,S=i.useRef(null),j=!!d,k=i.useMemo(function(){return f.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[f]),w=i.useRef({badgeMap:k,highlightBg:b,hideHighlightBg:j,suppressHighlightBg:B});w.current={badgeMap:k,highlightBg:b,hideHighlightBg:j,suppressHighlightBg:B};var C=function(n,t){return h.default.Children.map(n,function(n){var i;if(!h.default.isValidElement(n))return n;var r=(null===(i=n.props)||void 0===i?void 0:i.children)?C(n.props.children,t):n.props.children,o=h.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:r}));return t(o)})},F=i.useMemo(function(){return{mark:function(t){var i,r,o,a,l=t.children,s=e.__rest(t,["children"]),d=w.current,c=d.badgeMap,u=d.highlightBg,h=d.hideHighlightBg,g=d.suppressHighlightBg,p=s["data-badge-id"],f=p?c[p]:null,v=s["data-highlight-color"],x=null!==(a=null!==(r=null!=v?v:null===(i=null==f?void 0:f.style)||void 0===i?void 0:i.highlightBg)&&void 0!==r?r:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m="true"===s["data-is-suggested-deviation-fix"]||g;return n.jsx("span",e.__assign({style:e.__assign(e.__assign(e.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:l}))},span:function(i){var a,l,s,d,c,u,h=i.children,g=e.__rest(i,["children"]),p=w.current.badgeMap,f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:h}));var v=p[f];if(!v)return n.jsx("span",e.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return n.jsxs(t.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(t.Box,e.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=v.style)||void 0===l?void 0:l.badgeText)||r.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(s=v.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onClick&&v.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({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:n.jsx(t.Box,e.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"thead"},{children:r}))},tbody:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"tbody"},{children:r}))},tr:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(i){var r=i.children;return n.jsx(t.Box,e.__assign({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(i){var r=i.children;return n.jsx(t.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:i}))},pre:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:i}))},updated:function(e){var t=e.children;return n.jsx(n.Fragment,{children:t})},deleted:function(t){var i=t.children,r=C(i,function(e){return h.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(t){var i=t.children,r=C(i,function(e){return h.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},o,{children:r}))},ol:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},o,{children:r}))},li:function(i){var r=i.children,o=e.__rest(i,["children"]);return n.jsx(t.Box,e.__assign({component:"li",sx:{mb:.5,display:"list-item"}},o,{children:r}))}}},[]),M=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.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(e,n,t,i){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(i)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,i){return"".concat(n," ").concat(i)})).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(e){return e.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var i=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})}).join("")).trim()},A=i.useMemo(function(){return f.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[f]),z=function(e){return M(c.normalizeRedlineMarkdown(e||""))},T=i.useMemo(function(){var n=M(c.normalizeRedlineMarkdown(s||"")),t=(f||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:z((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||b}}).filter(function(e){return e.id&&e.highlight}),i={};t.forEach(function(e){i[e.highlight]||(i[e.highlight]=[]),i[e.highlight].push(e)});var r=function(e,n,t,i){void 0===n&&(n=""),void 0===i&&(i=[]);var r=!1,o=function(e){var o=function(e,n,t){var i,r,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(i=a[1])&&void 0!==i?i:"",s=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return s?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",i=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(i).concat(t,">")}(n,t)+s+"</mark>"+d:e}(e,n,t),a=o;if(!r&&i.length>0){r=!0;var l="",s="";i.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),s="</span>"+s}),a=l+o+s}return""+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},o=[];Object.entries(i).forEach(function(e){var t=e[0],i=e[1],r=B?l.findRedlineTextAnchorRange(n,t):l.findTextMatchRange(n,t,!1);if(r){for(var a=n.slice(r.start,r.end)!==t,s=i[0].highlightColor,d=1;d<i.length;d++)s=l.mixHexColors(s,i[d].highlightColor||"");o.push({highlight:t,start:r.start,end:r.end,badges:i,color:s,usedLooseMatch:a})}});var a=new Set(Object.keys(i));(_||[]).forEach(function(e){if(e){var t=z(e);if(t&&!a.has(t)){var i=B?l.findRedlineTextAnchorRange(n,t):l.findTextMatchRange(n,t,!1);if(i){var r=n.slice(i.start,i.end)!==t,s=n.slice(0,i.start);(s.match(/</g)||[]).length===(s.match(/>/g)||[]).length&&o.push({highlight:t,start:i.start,end:i.end,badges:[],color:b||"",usedLooseMatch:r})}}}}),o.sort(function(e,n){return e.start-n.start||n.end-e.end});var d=[],u={};o.forEach(function(e,n){for(var t=e.start,i=e.end,r=0,o=d;r<o.length;r++){var a=o[r],l=a.start,s=a.end,c=t<s&&i>s&&t>=l,h=t<l&&i>l&&i<=s;if(t>=l&&i<=s){e.orphaned=!0,u[n]=a.matchIdx;break}c&&(t=s),h&&(i=l)}e.trimmedStart=t,e.trimmedEnd=i,!e.orphaned&&t<i&&d.push({start:t,end:i,matchIdx:n})});var h={};Object.entries(u).forEach(function(e){var n=e[0],t=e[1],i=Number(n);h[t]||(h[t]=[]),h[t].push(i)});var g=o.map(function(n,t){return e.__assign(e.__assign({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,i;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(i=e.trimmedStart)&&void 0!==i?i:e.start)});return g.forEach(function(e){var t,i,a,s,d=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,c=null!==(i=e.trimmedEnd)&&void 0!==i?i:e.end;if(!(d>=c)){var u=n.slice(d,c),g=function(e,n,t,i){if(!t.length)return e;var a=t.map(function(e){return o[e]}).sort(function(e,n){return e.start-n.start}),s="",d=0;return a.forEach(function(t){var o,a,c=Math.max(d,t.start-n),u=Math.max(c,t.end-n);if(!(c>=u)){var h=l.mixHexColors(i,t.color||"");s+=e.slice(d,c),s+=r(e.slice(c,u),(null===(a=null===(o=t.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",h,t.badges||[]),d=u}}),s+=e.slice(d)}(e.usedLooseMatch||d!==e.start||c!==e.end?u:e.highlight,e.start,h[e.idx]||[],e.color),p=r(g,(null===(s=null===(a=e.badges)||void 0===a?void 0:a[0])||void 0===s?void 0:s.id)||"",e.color,e.badges||[]);n=n.slice(0,d)+p+n.slice(c)}}),n},[s,f,_,b,B]),q=i.useMemo(function(){return d?M(c.normalizeRedlineMarkdown(d||"")):""},[d]),R=!!d,W=e.__assign(e.__assign(e.__assign({},u),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),I=e.__assign(e.__assign(e.__assign({},W),{zIndex:2}),R?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),O=e.__assign(e.__assign({},W),{zIndex:1,pointerEvents:"auto"});return i.useLayoutEffect(function(){if(S.current){var e=function(){var e,n,t=Array.from(S.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var i=S.current.getBoundingClientRect(),r=i.bottom-4,o=i.top+4,a=S.current.querySelector('div[data-layer="base"]')||(null===(e=S.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=R?S.current.querySelector('div[data-layer="overlay"]')||(null===(n=S.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,s=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],c=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):s.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):s.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],i=[];n.forEach(function(e){if(0===i.length)i.push(e);else{var n=i[i.length-1],r=n.currentTop+n.height;e.naturalTop<r+8?(e.currentTop=r+8,i.push(e)):(t.push(i),i=[e])}}),i.length>0&&t.push(i),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>r){var i=t-r,a=e[0].currentTop-o,l=Math.max(0,Math.min(i,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(R&&(s.length>0||d.length>0)){var g=s.filter(function(e){return"left"===e.dataset.side}),p=s.filter(function(e){return"left"!==e.dataset.side}),f=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(g),h(p),h(f),h(v)}else h(c),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(S.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[T,E,A]),n.jsxs(t.Box,e.__assign({ref:S,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:I},{children:n.jsx(g.default,e.__assign({components:F,remarkPlugins:v,rehypePlugins:x},{children:T.replace(/#{3}/g,"")}))})),R&&n.jsx(t.Typography,e.__assign({component:"div",sx:O},{children:n.jsx(g.default,e.__assign({components:F,remarkPlugins:v,rehypePlugins:x},{children:q}))}))]}))},l.areMarkdownPropsEqual);exports.MemoizedMarkdown=m;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),r=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw"),d=require("remark-gfm");function c(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=c(i),h=c(a),g=c(l),p=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},f=[p(c(d).default)],v=[p(g.default)],x=u.default.memo(function(a){var l=a.content,d=a.overlayContent,c=a.sxStyles,g=a.deviationBadges,p=void 0===g?[]:g,x=a.highlights,m=void 0===x?[]:x;a.maintainRelativeOrder;var _=a.highlightBg,b=a.suppressHighlightBg,y=void 0!==b&&b,B=a.collisionKey,E=i.useRef(null),j=!!d,w=i.useMemo(function(){return p.reduce(function(e,t){var i;return n.__assign(n.__assign({},e),((i={})[t.id]=t,i))},{})},[p]),k=i.useRef({badgeMap:w,highlightBg:_,hideHighlightBg:j,suppressHighlightBg:y});k.current={badgeMap:w,highlightBg:_,hideHighlightBg:j,suppressHighlightBg:y};var C=function(e,t){return u.default.Children.map(e,function(e){var i;if(!u.default.isValidElement(e))return e;var r=(null===(i=e.props)||void 0===i?void 0:i.children)?C(e.props.children,t):e.props.children,o=u.default.cloneElement(e,n.__assign(n.__assign({},e.props),{children:r}));return t(o)})},S=i.useMemo(function(){return{mark:function(t){var i,r,o,a,s=t.children,l=n.__rest(t,["children"]),d=k.current,c=d.badgeMap,u=d.highlightBg,h=d.hideHighlightBg,g=d.suppressHighlightBg,p=l["data-badge-id"],f=p?c[p]:null,v=l["data-highlight-color"],x=null!==(a=null!==(r=null!=v?v:null===(i=null==f?void 0:f.style)||void 0===i?void 0:i.highlightBg)&&void 0!==r?r:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m="true"===l["data-is-suggested-deviation-fix"]||g;return e.jsx("span",n.__assign({style:n.__assign(n.__assign(n.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:s}))},span:function(i){var a,s,l,d,c,u,h=i.children,g=n.__rest(i,["children"]),p=k.current.badgeMap,f=g["data-badge-id"];if(!f)return e.jsx("span",n.__assign({},g,{children:h}));var v=p[f];if(!v)return e.jsx("span",n.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return e.jsxs(t.Box,n.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[e.jsxs(t.Box,n.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:n.__assign(n.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=v.style)||void 0===s?void 0:s.badgeText)||r.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=v.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[e.jsxs(t.Box,n.__assign({onClick:function(n){n.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[e.jsx(t.Box,n.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&e.jsx(t.Box,n.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&e.jsx(t.Box,n.__assign({onClick:function(n){n.stopPropagation(),v.onClick&&v.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:e.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:e.jsx(t.Box,n.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"thead"},{children:r}))},tbody:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"tbody"},{children:r}))},tr:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({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(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(t){var i=t.children;return e.jsx("span",n.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:i}))},pre:function(t){var i=t.children;return e.jsx("span",n.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:i}))},updated:function(n){var t=n.children;return e.jsx(e.Fragment,{children:t})},deleted:function(t){var i=t.children,r=C(i,function(n){return u.default.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return e.jsx("span",n.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(t){var i=t.children,r=C(i,function(n){return u.default.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return e.jsx("span",n.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},o,{children:r}))},ol:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},o,{children:r}))},li:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"li",sx:{mb:.5,display:"list-item"}},o,{children:r}))}}},[]),F=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,i){return"".concat(e," ").concat(i)})).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 i=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})}).join("")).trim()},z=function(n){return n.replace(/[\.,;:]/g," ")},A=i.useMemo(function(){return p.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[p]),M=i.useMemo(function(){var e=F(l||""),t=y?z(e):e,i=(p||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:F((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)||_}}).filter(function(n){return n.id&&n.highlight}),r={};i.forEach(function(n){r[n.highlight]||(r[n.highlight]=[]),r[n.highlight].push(n)});var o=function(n,e,t,i){void 0===e&&(e=""),void 0===i&&(i=[]);var r=!1,o=function(n){var o=function(n,e,t){var i,r,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var s=null!==(i=a[1])&&void 0!==i?i:"",l=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return l?s+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",i=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(i).concat(t,">")}(e,t)+l+"</mark>"+d:n}(n,e,t),a=o;if(!r&&i.length>0){r=!0;var s="",l="";i.forEach(function(n){s+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),l="</span>"+l}),a=s+o+l}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(r).forEach(function(n){var i=n[0],r=n[1],o=e.indexOf(i),l=!1;if(-1===o&&y){var d=z(i);-1!==(o=t.indexOf(d))&&(l=!0)}if(-1!==o){for(var c=r[0].highlightColor,u=1;u<r.length;u++)c=s.mixHexColors(c,r[u].highlightColor||"");a.push({highlight:i,start:o,end:o+i.length,badges:r,color:c,usedLooseMatch:l})}});var d=new Set(Object.keys(r));(m||[]).forEach(function(n){if(n){var i=F(n);if(i&&!d.has(i)){var r=e.indexOf(i),o=!1;if(-1===r&&y){var s=z(i);-1!==(r=t.indexOf(s))&&(o=!0)}if(-1!==r){var l=e.slice(0,r);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&a.push({highlight:i,start:r,end:r+i.length,badges:[],color:_||"",usedLooseMatch:o})}}}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],u={};a.forEach(function(n,e){for(var t=n.start,i=n.end,r=0,o=c;r<o.length;r++){var a=o[r],s=a.start,l=a.end,d=t<l&&i>l&&t>=s,h=t<s&&i>s&&i<=l;if(t>=s&&i<=l){n.orphaned=!0,u[e]=a.matchIdx;break}d&&(t=l),h&&(i=s)}n.trimmedStart=t,n.trimmedEnd=i,!n.orphaned&&t<i&&c.push({start:t,end:i,matchIdx:e})});var h={};Object.entries(u).forEach(function(n){var e=n[0],t=n[1],i=Number(e);h[t]||(h[t]=[]),h[t].push(i)});var g=a.map(function(e,t){return n.__assign(n.__assign({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,i;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(i=n.trimmedStart)&&void 0!==i?i:n.start)});return g.forEach(function(n){var t,i,r,l,d=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,c=null!==(i=n.trimmedEnd)&&void 0!==i?i:n.end;if(!(d>=c)){var u=e.slice(d,c),g=function(n,e,t,i){if(!t.length)return n;var r=t.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),l="",d=0;return r.forEach(function(t){var r,a,c=Math.max(d,t.start-e),u=Math.max(c,t.end-e);if(!(c>=u)){var h=s.mixHexColors(i,t.color||"");l+=n.slice(d,c),l+=o(n.slice(c,u),(null===(a=null===(r=t.badges)||void 0===r?void 0:r[0])||void 0===a?void 0:a.id)||"",h,t.badges||[]),d=u}}),l+=n.slice(d)}(n.usedLooseMatch||d!==n.start||c!==n.end?u:n.highlight,n.start,h[n.idx]||[],n.color),p=o(g,(null===(l=null===(r=n.badges)||void 0===r?void 0:r[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,d)+p+e.slice(c)}}),e},[l,p,m,_,y]),T=i.useMemo(function(){return d?F(d||""):""},[d]),O=!!d,W={"& *":{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"}},q=n.__assign(n.__assign(n.__assign(n.__assign({},c),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),O?{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"}}:{}),I=n.__assign(n.__assign(n.__assign({},c),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return i.useLayoutEffect(function(){if(E.current){var n=function(){var n=Array.from(E.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}),i=E.current.getBoundingClientRect(),r=i.bottom-4,o=i.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=[],i=[];e.forEach(function(n){if(0===i.length)i.push(n);else{var e=i[i.length-1],r=e.currentTop+e.height;n.naturalTop<r+8?(n.currentTop=r+8,i.push(n)):(t.push(i),i=[n])}}),i.length>0&&t.push(i),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>r){var i=t-r,a=n[0].currentTop-o,s=Math.max(0,Math.min(i,a));n.forEach(function(n){n.currentTop-=s})}}),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(E.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[M,B,A]),e.jsxs(t.Box,n.__assign({ref:E,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[e.jsx(t.Typography,n.__assign({component:"div",sx:n.__assign(n.__assign({},q),{padding:"3px"})},{children:e.jsx(h.default,n.__assign({components:S,remarkPlugins:f,rehypePlugins:v},{children:M.replace(/#{3}/g,"")}))})),O&&e.jsx(t.Typography,n.__assign({component:"div",sx:I},{children:e.jsx(h.default,n.__assign({components:S,remarkPlugins:f,rehypePlugins:v},{children:T}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=x;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i=require("../utils/buildComparisonRows.js"),o={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(r,a,s,l,d,u,v){var c,f;void 0===d&&(d=!0);var p="string"==typeof s?s:JSON.stringify(s||{}),_=null!=v?v:Boolean("string"==typeof u?u.trim():u&&(u.learnings_data||(null===(f=null===(c=u.data)||void 0===c?void 0:c.artifactData)||void 0===f?void 0:f.userStorySnapshot))),g=e.useMemo(function(){if(!r||0===Object.keys(r).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var e=JSON.parse(p);try{var o=r.nodes||r,s=[],l=[],v=[],c=r.base_root_id,f=r.input_index_map||{0:"left",1:"right"},g=r[c]||o[c];if(!g||!1===g.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var I=r.content_mapping||{},h=function(n){return r[n]||o[n]},m=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)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)}),s={},l={},u=null;return a.forEach(function(n){var r,a,d,v,c,p,_,g=e[n];if(g&&"object"==typeof g){u||(u=g);var I="same"===t.safeStringify(null===(a=null==g?void 0:g.evaluation_outputs)||void 0===a?void 0:a.output_value).trim().toLowerCase(),h=!((null==g?void 0:g.status)&&"pending"!==g.status||I),m=(null==g?void 0:g.deviation_highlight)||(null===(d=null==g?void 0:g.web_search_answer)||void 0===d?void 0:d.deviation_highlight),y=function(n){var e,t=(null===(e=null==g?void 0:g.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==g?void 0:g.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})},b=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},x=h?b((null===(v=null==g?void 0:g.deviation_highlights)||void 0===v?void 0:v[i])||(null===(c=null==g?void 0:g.deviation_highlights)||void 0===c?void 0:c[f[0]]),"string"==typeof m?[m]:[],y(i),y(f[0])):[],R=h?b((null===(p=null==g?void 0:g.deviation_highlights)||void 0===p?void 0:p[o])||(null===(_=null==g?void 0:g.deviation_highlights)||void 0===_?void 0:_[f[1]]),y(o),y(f[1])):[];s[n]=((r={})[f[0]]=x[0]||"",r[f[1]]=R[0]||"",r.deviation_summary=(null==g?void 0:g.deviation_summary)||"",r.deviation_title=null==g?void 0:g.deviation_title,r.deviation_impact=null==g?void 0:g.deviation_impact,r.deviation_explanation=null==g?void 0:g.deviation_explanation,r.evaluation_outputs=null==g?void 0:g.evaluation_outputs,r.cognitive_decisioning=null==g?void 0:g.cognitive_decisioning,r.deviation_highlights=null==g?void 0:g.deviation_highlights,r),l[n]=g}}),n.__assign(n.__assign({},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:s,deviation_entries:l})},y=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 s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,l=n;s<l.length;s++){a(l[s])}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},b=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=f[0],i=f[1];return e.length>0&&(t=e.includes(f[0])?f[0]:e[0],i=e.includes(f[1])?f[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},l=!1!==a.display_title,d=!1!==a.display_content,u=l?t.safeStringify(s.title||""):"",v=d?t.safeStringify(s.content||""):"",c=d?t.safeStringify(s.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.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:l,displayContent:d,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},R=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.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)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.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)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},C=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},S=function(i,o){var r,a=h(i);if(!a||!1===a.display_node)return[];if(_&&"1"===o)return[];var s=b(a),l=s.nodeLeftId,d=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==e?void 0:e[i])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=m(v,l,d),p=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:i}):c,g=t.resolveComparisonInputItems(a,o,f,I).map(function(n){return x(i,n,p,u)});if(a.next){var y=Object.values(a.next).flatMap(function(n){return S(n,o)});g.forEach(function(n){var e=y.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:y})}return g};if(a){var E=function(i,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!i)return{refSections:a,baseSections:s};var l={},d={},u=-1,v=-1,c=function(a){var s=i[a],c=h(s);if(!c||!1===c.display_node)return"continue";var p=b(c),g=p.nodeLeftId,y=p.nodeRightId,C=t.getRationale(c),S=(null===(r=null==e?void 0:e[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=m(S,g,y),j=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,N=E(c.next,o+1),w=N.refSections,A=N.baseSections,D=t.resolveComparisonInputItems(c,"0",f,I).map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),k=[];if(!_){var M=t.resolveComparisonInputItems(c,"1",f,I);k=M.map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}D.forEach(function(n){k.forEach(function(e){var t,i,o,r,a,s,l,d;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===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(l=n.refContentIds)||void 0===l?void 0:l.includes(e.contentId))&&(null===(d=n.refContentIds)||void 0===d||d.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===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?R(l[t],n):n}),D.forEach(function(n){var e=A.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===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?R(d[t],n):n})};for(var p in i)c(p);return a=Object.values(l),s=Object.values(d),a.sort(C),s.sort(C),{refSections:a,baseSections:s}},O=E(g.next),j=O.refSections,N=O.baseSections;_||(l=y(j)),s=N}else g.next&&Object.values(g.next).forEach(function(n){var e=h(n);if(e&&!1!==e.display_node){var t=S(n,"0");if(_)s.push.apply(s,t);else{var o=y(S(n,"1"));v.push.apply(v,i.buildComparisonRows(n,t,o))}}}),_||(s=v.map(function(n){return n.left}),l=v.map(function(n){return n.right}));var w=t.getSideData(g,"0",f,I),A=t.getSideData(g,"1",f,I),D={title:w.title||"Uploaded Contract",description:g.decision_scope_description||"",sections:s},k={id:"tree-variant-1",title:_?function(){var n,e;if("string"!=typeof u&&(null==u?void 0:u.learnings_data)&&Object.keys(u.learnings_data).length>0){var t=Object.keys(u.learnings_data)[0];return(null===(n=u.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return"string"!=typeof u&&(null===(e=null==u?void 0:u.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():A.title||"Reference Template",similarity:0,sections:l,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}};return{activeProposed:D,activeVariants:[k],comparisonRows:v,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[r,a,p,d,u,_]),I=g.activeProposed,h=g.activeVariants,m=g.comparisonRows,y=g.parseError,b=(null==h?void 0:h[0])||o,x=e.useMemo(function(){return(null==I?void 0:I.sections)||[]},[null==I?void 0:I.sections]),R=e.useMemo(function(){return b.sections||[]},[b.sections]),C=x.length>0||R.length>0,S=e.useMemo(function(){return l.fields.filter(function(n){var e=n.key;return(!C||"description"!==e)&&(t.hasValue(null==I?void 0:I[e])||t.hasValue(b[e]))})},[I,b,C,l.fields]),E=e.useMemo(function(){var n,e,i={},o={},s={},l=0,d=null===(n=null==r?void 0:r.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==r?void 0:r.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!a){var t="left"===e?x.indexOf(n):R.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:x.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,s=x.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(s){var l=s.selfIndex,d=void 0!==l&&l>=0?l+1:x.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:d}}var u=void 0!==r&&r>=0?r+1:R.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=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},f=function(n,e,r,a,v,p,_){if(e&&function(n,e,i){var r;((null===(r=null==n?void 0:n.evaluationResults)||void 0===r?void 0:r.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(r){var a=(null==r?void 0:r.deviations)||{};Object.keys(a).sort().forEach(function(l){var v=a[l];if(v){var c=!t.isMissingStr(v[d]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==r?void 0:r.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(l);void 0===o[_]&&(void 0===s[e]&&(s[e]=1),o[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,a,v),e&&!p){var g=(null==_?void 0:_.id)||"fallback_parent_".concat(l++);i[g]||(i[g]=[]),i[g].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==r?void 0:r.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),o=c(null==r?void 0:r.subsections,t);f(t,i,o,a,v,!1,e||_)})};x.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(a){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=R.find(function(n){return n.selfIndex===s})}else r=R[x.indexOf(n)];f(n,n,r,i,o,!0,n)}),_||R.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&f(n,null,n,t,i,!0,n)});var p=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),g=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:p,deviationParentRegistry:g}},[x,R,a,r,_]),O=E.parentDeviationRecord,j=E.registry,N=E.deviationParentRegistry;return{isGuidelineMode:_,activeProposed:I,activeVariants:h,comparisonRows:m,existingRule:b,proposedSections:x,existingSections:R,visibleFields:S,parentDeviationRecord:O,deviationNumberRegistry:j,deviationParentRegistry:N,parseError:y}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i=require("../utils/buildComparisonRows.js"),o={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(r,a,s,d,l,u){var v,c;void 0===l&&(l=!0);var f="string"==typeof s?s:JSON.stringify(s||{}),p=Boolean(u&&(u.learnings_data||(null===(c=null===(v=u.data)||void 0===v?void 0:v.artifactData)||void 0===c?void 0:c.userStorySnapshot))),_=e.useMemo(function(){if(!r||0===Object.keys(r).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var e=JSON.parse(f);try{var o=r.nodes||r,s=[],d=[],v=[],c=r.base_root_id,_=r.input_index_map||{0:"left",1:"right"},I=r[c]||o[c];if(!I||!1===I.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var g=r.content_mapping||{},h=function(n){return r[n]||o[n]},m=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(l)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)}),s={},d={},u=null;return a.forEach(function(n){var r,a,l,v,c,f,p=e[n];if(p&&"object"==typeof p){u||(u=p);var I=!(null==p?void 0:p.status)||"pending"===p.status,g=(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),h=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 i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},y=I?m((null===(l=null==p?void 0:p.deviation_highlights)||void 0===l?void 0:l[i])||(null===(v=null==p?void 0:p.deviation_highlights)||void 0===v?void 0:v[_[0]]),"string"==typeof g?[g]:[],h(i),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[_[1]]),h(o),h(_[1])):[];s[n]=((r={})[_[0]]=y[0]||"",r[_[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.__assign(n.__assign({},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:s,deviation_entries:d})},y=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 s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,d=n;s<d.length;s++){a(d[s])}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},b=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=_[0],i=_[1];return e.length>0&&(t=e.includes(_[0])?_[0]:e[0],i=e.includes(_[1])?_[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},d=!1!==a.display_title,l=!1!==a.display_content,u=d?t.safeStringify(s.title||""):"",v=l?t.safeStringify(s.content||""):"",c=l?t.safeStringify(s.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.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:l,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},R=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.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)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.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)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},C=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},S=function(i,o){var r,a=h(i);if(!a||!1===a.display_node)return[];if(p&&"1"===o)return[];var s=b(a),d=s.nodeLeftId,l=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==e?void 0:e[i])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=m(v,d,l),f=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:i}):c,I=t.resolveComparisonInputItems(a,o,_,g).map(function(n){return x(i,n,f,u)});if(a.next){var y=Object.values(a.next).flatMap(function(n){return S(n,o)});I.forEach(function(n){var e=y.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:y})}return I};if(a){var E=function(i,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!i)return{refSections:a,baseSections:s};var d={},l={},u=-1,v=-1,c=function(a){var s=i[a],c=h(s);if(!c||!1===c.display_node)return"continue";var f=b(c),I=f.nodeLeftId,y=f.nodeRightId,C=t.getRationale(c),S=(null===(r=null==e?void 0:e[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=m(S,I,y),j=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,N=E(c.next,o+1),w=N.refSections,A=N.baseSections,D=t.resolveComparisonInputItems(c,"0",_,g).map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),k=[];if(!p){var M=t.resolveComparisonInputItems(c,"1",_,g);k=M.map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}D.forEach(function(n){k.forEach(function(e){var t,i,o,r,a,s,d,l;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===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(l=n.refContentIds)||void 0===l||l.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===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?R(d[t],n):n}),D.forEach(function(n){var e=A.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===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?R(l[t],n):n})};for(var f in i)c(f);return a=Object.values(d),s=Object.values(l),a.sort(C),s.sort(C),{refSections:a,baseSections:s}},O=E(I.next),j=O.refSections,N=O.baseSections;p||(d=y(j)),s=N}else I.next&&Object.values(I.next).forEach(function(n){var e=h(n);if(e&&!1!==e.display_node){var t=S(n,"0");if(p)s.push.apply(s,t);else{var o=y(S(n,"1"));v.push.apply(v,i.buildComparisonRows(n,t,o))}}}),p||(s=v.map(function(n){return n.left}),d=v.map(function(n){return n.right}));var w=t.getSideData(I,"0",_,g),A=t.getSideData(I,"1",_,g),D={title:w.title||"Uploaded Contract",description:I.decision_scope_description||"",sections:s},k={id:"tree-variant-1",title:p?function(){var n,e;if((null==u?void 0:u.learnings_data)&&Object.keys(u.learnings_data).length>0){var t=Object.keys(u.learnings_data)[0];return(null===(n=u.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return(null===(e=null==u?void 0:u.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():A.title||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:I.decision_scope_description||""},fields:{}}}};return{activeProposed:D,activeVariants:[k],comparisonRows:v,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[r,a,f,l,u]),I=_.activeProposed,g=_.activeVariants,h=_.comparisonRows,m=_.parseError,y=(null==g?void 0:g[0])||o,b=e.useMemo(function(){return(null==I?void 0:I.sections)||[]},[null==I?void 0:I.sections]),x=e.useMemo(function(){return y.sections||[]},[y.sections]),R=b.length>0||x.length>0,C=e.useMemo(function(){return d.fields.filter(function(n){var e=n.key;return(!R||"description"!==e)&&(t.hasValue(null==I?void 0:I[e])||t.hasValue(y[e]))})},[I,y,R,d.fields]),S=e.useMemo(function(){var n,e,i={},o={},s={},d=0,l=null===(n=null==r?void 0:r.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==r?void 0:r.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!a){var t="left"===e?b.indexOf(n):x.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:b.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,s=b.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(s){var d=s.selfIndex,l=void 0!==d&&d>=0?d+1:b.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:l}}var u=void 0!==r&&r>=0?r+1:x.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=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},f=function(n,e,r,a,v,p,_){if(e&&function(n,e,i){var r;((null===(r=null==n?void 0:n.evaluationResults)||void 0===r?void 0:r.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(r){var a=(null==r?void 0:r.deviations)||{};Object.keys(a).sort().forEach(function(d){var v=a[d];if(v){var c=!t.isMissingStr(v[l]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==r?void 0:r.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(d);void 0===o[_]&&(void 0===s[e]&&(s[e]=1),o[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,a,v),e&&!p){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==r?void 0:r.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),o=c(null==r?void 0:r.subsections,t);f(t,i,o,a,v,!1,e||_)})};b.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(a){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=x.find(function(n){return n.selfIndex===s})}else r=x[b.indexOf(n)];f(n,n,r,i,o,!0,n)}),p||x.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&f(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:_,deviationParentRegistry:I}},[b,x,a,r,p]),E=S.parentDeviationRecord,O=S.registry,j=S.deviationParentRegistry;return{isGuidelineMode:p,activeProposed:I,activeVariants:g,comparisonRows:h,existingRule:y,proposedSections:b,existingSections:x,visibleFields:C,parentDeviationRecord:E,deviationNumberRegistry:O,deviationParentRegistry:j,parseError:m}};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js"),n=require("../Guidelines/utils/guidelineTargets.js");exports.useLinesCalculator=function(i){var r=i.containerRef,c=i.leftContainerRef,l=i.rightContainerRef;i.svgContainerRef;var o=i.pathRefs,u=i.leftHeaderRef,a=i.rightHeaderRef,d=i.proposedSections,s=i.existingSections,v=i.visibleFields,g=i.leftRefs,h=i.rightRefs,f=i.sectionLeftRefs,p=i.sectionRightRefs,b=i.subSectionLeftRefs,A=i.subSectionRightRefs,y=i.lhsBadgeRefs,R=i.rhsBadgeRefs,x=i.sectionRowRefs,m=i.expandedSections,B=i.expandedSubSections,S=i.connectedSections,T=i.isSideBySide,I=i.activeSideBySideSection,C=i.maintainRelativeOrder,E=i.isGuidelineMode,M=i.cognitiveMap,D=i.getSectionCompareStyle,O=i.getSubSectionCompareStyle,L=i.getDeviationStyleByKey,_=i.isArrowVisible,F=i.isAnimatingRef,N=i.isSideBySideRef,H=i.sideBySideCacheRef,P=i.sideBySideLineRef,k=i.activeSideBySideSectionRef,w=i.activeSideBySideRightSectionRef,G=i.connectedLines,V=i.setConnectedLines,Y=i.cachedConnectedPositions,j=i.calculateLinesRef,z=i.resizeTimerRef,Q=i.scrollLock,X=i.scrollSyncLocked,q=i.handleResizeRef,K=i.activeProposed,J=i.existingRule,U=i.analysisData,W=i.pendingScrollTargetRef,Z=i.pendingScrollCallbackRef,$=i.resolvedComparisonConfig,tt=i.getFieldData,et=t.useState([]),nt=et[0],it=et[1],rt=t.useState(null),ct=rt[0],lt=rt[1],ot=t.useState([]),ut=ot[0],at=ot[1],dt=null!=G?G:ut,st=null!=V?V:at,vt=t.useState({width:0,height:0}),gt=vt[0],ht=vt[1],ft=t.useRef(!1),pt=t.useRef(!1),bt=t.useRef(!1),At=t.useRef(null),yt=t.useRef([]),Rt=null!=Y?Y:yt,xt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},mt=t.useCallback(function(){var t,i,o,x,_,N,H,P,k,w,G,V,Y,j,z,Q,X,q;if(!ft.current&&!F.current){ft.current=!0;try{if(!r.current)return;var K=function(t){var e=t.split("-"),n=e[0];if(!m[n]&&!1===C)return!1;if(C&&!m["left-".concat(n)]&&!m["right-".concat(n)]&&!m[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!B[i])return!1;return!0},J=r.current.getBoundingClientRect();ht({width:J.width,height:J.height});var U=[];if(v.forEach(function(t){var e,n,i=t.key,r=null===(e=g.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!F.current){for(var W=0;W<Math.max(d.length,s.length);W++){var Z=null===(t=f.current[W])||void 0===t?void 0:t.current,$=null===(i=p.current[W])||void 0===i?void 0:i.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(K(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=A.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var tt={};v.forEach(function(t){var e,n,i=t.key,r=null===(e=g.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();tt[i]=Math.max(l.height,o.height)}});var et={left:{},right:{}},nt={};if(!F.current)if(C){if(T&&null!==I)if("number"==typeof I){var rt=I,ct=d[rt],ot=null===(_=f.current[rt])||void 0===_?void 0:_.current;ot&&ct&&(ct.refIndexes||[]).forEach(function(t){var e,n=s.findIndex(function(e){return e.selfIndex===t}),i=null===(e=p.current[n])||void 0===e?void 0:e.current;if(i&&(m["left-".concat(rt)]||m["right-".concat(n)])){var r=Math.max(ot.getBoundingClientRect().height,i.getBoundingClientRect().height);et.left[rt]=Math.max(et.left[rt]||0,r),et.right[n]=Math.max(et.right[n]||0,r)}})}else{var ut=I.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ut){Z=null===(N=b.current[ut])||void 0===N?void 0:N.current,$=null===(H=A.current[ut])||void 0===H?void 0:H.current;if(Z&&$){at=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);nt[ut]=Math.max(nt[ut]||0,at)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(K(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=A.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);nt[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(W=0;W<Math.min(d.length,s.length);W++){var Z=null===(o=f.current[W])||void 0===o?void 0:o.current,$=null===(x=p.current[W])||void 0===x?void 0:x.current;if(Z&&$){var at=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et.left[W]=at,et.right[W]=at}}}if(v.forEach(function(t){var e,n,i=t.key,r=null===(e=g.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=tt[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),F.current||(Object.entries(et.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(et.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=p.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(nt).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=A.current[t])||void 0===n?void 0:n.current;if(i&&r&&nt[t]){var c=nt[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!E){d.forEach(function(t,e){var n,i=t.continuationSourceRowId?d.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,r=i>=0?i:e,o=null===(n=f.current[r])||void 0===n?void 0:n.current;if(o){var u=function(t,e){if(!C)return s[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return s.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&s[e]?[e]:Array.from(new Set(n))}(t,e);u.forEach(function(t){var n,u,a,v,g,h,f,b,A,y,R,x,m=null===(n=p.current[t])||void 0===n?void 0:n.current;if(m){var B=o.getBoundingClientRect(),S=m.getBoundingClientRect(),E=B.right-J.left,O=S.left-J.left,L=B.top+18-J.top,_=S.top+18-J.top;if(C&&T&&I===e){var F=null!==(a=null===(u=c.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,N=null!==(g=null===(v=l.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==g?g:0,H=F+(null!==(f=null===(h=c.current)||void 0===h?void 0:h.clientHeight)&&void 0!==f?f:1/0),P=N+(null!==(A=null===(b=l.current)||void 0===b?void 0:b.clientHeight)&&void 0!==A?A:1/0),k=function(t,e,n){return Math.max(e,Math.min(n,t))};L=k(B.top+18,F,H)-J.top,_=k(S.top+18,N,P)-J.top}var w=D(r);w&&U.push({id:"line-".concat(r,"-").concat(t),x1:E,y1:L,x2:O,y2:_,style:w,sectionIdx:r,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(y=d[r])||void 0===y?void 0:y.cognitiveData)||(null===(R=s[t])||void 0===R?void 0:R.cognitiveData)||(null===(x=d[r])||void 0===x?void 0:x.nodeId)&&M[d[r].nodeId])})}})}})}if(!E&&T&&"string"==typeof I&&I.includes(e.DEVIATION_BADGE_SEPARATOR)){var dt=I.split(e.DEVIATION_BADGE_SEPARATOR),vt=dt[0],gt=dt[1],pt=dt[2],bt=(dt[3],"".concat(vt).concat(e.DEVIATION_BADGE_SEPARATOR).concat(gt)),At=null===(P=y.current[bt])||void 0===P?void 0:P.current,yt=null===(k=R.current[bt])||void 0===k?void 0:k.current;if(At&&yt){var mt=At.getBoundingClientRect(),St=yt.getBoundingClientRect(),Tt=mt.right-J.left,It=St.left-J.left,Ct=mt.top+mt.height/2-J.top,Et=St.top+St.height/2-J.top;if(C){var Mt=null!==(G=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==G?G:0,Dt=null!==(Y=null===(V=l.current)||void 0===V?void 0:V.getBoundingClientRect().top)&&void 0!==Y?Y:0,Ot=Mt+(null!==(z=null===(j=c.current)||void 0===j?void 0:j.clientHeight)&&void 0!==z?z:1/0),Lt=Dt+(null!==(X=null===(Q=l.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==X?X:1/0),_t=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=_t(mt.top+mt.height/2,Mt,Ot)-J.top,Et=_t(St.top+St.height/2,Dt,Lt)-J.top}var Ft=null!==(q=L(vt,gt))&&void 0!==q?q:O(pt);Ft&&U.push({id:"line-subsec-".concat(bt),x1:Tt,y1:Ct,x2:It,y2:Et,style:Ft,sectionIdx:Number(pt.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(it(U),u.current&&a.current){var Nt=u.current.getBoundingClientRect(),Ht=a.current.getBoundingClientRect(),Pt=(Nt.top+Nt.height/2-J.top+Ht.top+Ht.height/2-J.top)/2;lt({x1:Nt.right-J.left,x2:Ht.left-J.left,y:Pt})}else lt(null);if(S.size>0){var kt=[],wt=c.current,Gt=l.current;if(wt&&Gt){var Vt=[],Yt=wt.getBoundingClientRect().top,jt=Gt.getBoundingClientRect().top,zt=Yt+wt.clientHeight,Qt=jt+Gt.clientHeight,Xt=wt.scrollTop,qt=Gt.scrollTop,Kt=J.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};S.forEach(function(t){var i,r,c,l,o,u,a,v,g;if(E){var h=null,f=null,p=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),A=b[0],x=b[1],m=b[2],B="".concat(A).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x);h=null===(i=y.current[B])||void 0===i?void 0:i.current,p=null!==(r=L(A,x))&&void 0!==r?r:O(m),f=Number((null==m?void 0:m.split("-")[0])||0)}else f=Number(t),h=null===(c=y.current[f])||void 0===c?void 0:c.current,p=D(f);if(!h)return;var S=n.getVisibleGuidelineTargets(Gt);S.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-J.left,o=c.left-J.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Yt+Xt,v=d-jt+qt,g="conn-guide-".concat(t,"-").concat(i),f="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?f=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):f=String(Number(t)+1);var b=String.fromCharCode(97+i),A=1===S.length?null:"".concat(f,"(").concat(b,")");Vt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:Kt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==p?void 0:p.badgeBorder)||"#6366F1",styleBg:(null==p?void 0:p.badgeBg)||"#FFFFFF",styleText:(null==p?void 0:p.badgeText)||"#A16207",styleId:g,centerX:u});var y=Jt(a,Yt,zt),R=Jt(d,jt,Qt),x=y-Kt,m=R-Kt,B=xt(l,x,o,m,u,a>=Yt-4&&a<=zt+4,d>=jt-4&&d<=Qt+4);kt.push({id:g,pathD:B,style:p,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var T=t.split(e.DEVIATION_BADGE_SEPARATOR),I=(A=T[0],x=T[1],m=T[2],T[3],B="".concat(A).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x),null===(l=y.current[B])||void 0===l?void 0:l.current),M=null===(o=R.current[B])||void 0===o?void 0:o.current;if(!I||!M)return;var _=I.getBoundingClientRect(),F=M.getBoundingClientRect(),N=null!==(u=L(A,x))&&void 0!==u?u:O(m),H=_.right-J.left,P=F.left-J.left-0,k=H+75,w=_.top+_.height/2,G=F.top+F.height/2,V=w-Yt+Xt,Y=G-jt+qt,j="conn-subsec-".concat(B),z=((m||"").split("-").map(function(t){return Number(t)+1}).join("."),null);Vt.push({lhsScrollY:V,rhsScrollY:Y,x1:H,x2:P,containerTop:Kt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==N?void 0:N.badgeBorder)||"#6366F1",styleBg:(null==N?void 0:N.badgeBg)||"#FFFFFF",styleText:(null==N?void 0:N.badgeText)||"#A16207",styleId:j,centerX:k});var Q=Jt(w,Yt,zt),X=Jt(G,jt,Qt),q=xt(H,$=Q-Kt,P,tt=X-Kt,k,w>=Yt-4&&w<=zt+4,G>=jt-4&&G<=Qt+4);kt.push({id:j,pathD:q,style:N,leftIdx:t,rhsArrayIdx:t,x1:H,x2:P,y1:$,y2:tt,matchLabel:z})}else if(C){var K=t,U=d[K];if(!(null===(g=null==U?void 0:U.refIndexes)||void 0===g?void 0:g.length))return;U.refIndexes.forEach(function(e,n){var i,r,c=s.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=y.current[K])||void 0===i?void 0:i.current,o=null===(r=R.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),d=D(K),v=u.right-J.left,g=a.left-J.left-0,h=v+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Yt+Xt,A=p-jt+qt,x="conn-".concat(K,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===U.refIndexes.length?null:"".concat(m,"(").concat(B,")");Vt.push({lhsScrollY:b,rhsScrollY:A,x1:v,x2:g,containerTop:Kt,leftIdx:K,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:h});var T=Jt(f,Yt,zt),I=Jt(p,jt,Qt),C=T-Kt,E=I-Kt,M=xt(v,C,g,E,h,f>=Yt-4&&f<=zt+4,p>=jt-4&&p<=Qt+4);kt.push({id:x,pathD:M,style:d,leftIdx:K,rhsArrayIdx:c,x1:v,x2:g,y1:C,y2:E,matchLabel:S})}}})}else{var W=t,Z=W;I=null===(a=y.current[W])||void 0===a?void 0:a.current,M=null===(v=R.current[Z])||void 0===v?void 0:v.current;if(!I||!M)return;_=I.getBoundingClientRect(),F=M.getBoundingClientRect(),N=D(W),H=_.right-J.left,P=F.left-J.left-0,k=H+75,w=_.top+_.height/2,G=F.top+F.height/2,V=w-Yt+Xt,Y=G-jt+qt,j="conn-".concat(W,"-").concat(Z),String(Number(t)+1),z=null;Vt.push({lhsScrollY:V,rhsScrollY:Y,x1:H,x2:P,containerTop:Kt,leftIdx:W,rhsArrayIdx:Z,styleColor:(null==N?void 0:N.badgeBorder)||"#6366F1",styleBg:(null==N?void 0:N.badgeBg)||"#FFFFFF",styleText:(null==N?void 0:N.badgeText)||"#A16207",styleId:j,centerX:k});var $,tt;Q=Jt(w,Yt,zt),X=Jt(G,jt,Qt),q=xt(H,$=Q-Kt,P,tt=X-Kt,k,w>=Yt-4&&w<=zt+4,G>=jt-4&&G<=Qt+4);kt.push({id:j,pathD:q,style:N,leftIdx:W,rhsArrayIdx:Z,x1:H,x2:P,y1:$,y2:tt,matchLabel:z})}}),Rt.current=Vt}st(kt),setTimeout(function(){return Bt()},10)}else st([]),Rt.current=[],setTimeout(function(){return Bt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{ft.current=!1}}},[v,d,s,M,$,tt,D,L,C,T,I,S,m,B,E]),Bt=t.useCallback(function(){var t,e,n,i,u,a,d,s,v,g,h,f,p,b,A,y,R,x,m,B=Rt.current;if(!B.length)return null===(t=o.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=o.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=o.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=o.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!F.current){var S=null!==(a=null===(u=c.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=l.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,I=null!==(g=null===(v=c.current)||void 0===v?void 0:v.clientHeight)&&void 0!==g?g:1/0,C=null!==(f=null===(h=l.current)||void 0===h?void 0:h.clientHeight)&&void 0!==f?f:1/0,E=null!==(b=null===(p=c.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,M=null!==(y=null===(A=l.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+I,O=M+C,L=null===(R=r.current)||void 0===R?void 0:R.getBoundingClientRect(),_=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,w=0,G=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=o.current[t.styleId+"-stroke"],r=o.current[t.styleId+"-bg"],c=o.current[t.styleId+"-btn"],l=o.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-_,s=a-_,v=e>=E-4&&e<=D+4,g=n>=M-4&&n<=O+4,h=!0;j=!0;var f=t.centerX||t.x1+75;0===w&&(w=t.x1,G=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,h=!1):n>O+4&&(k++,h=!1);var p=xt(t.x1,d,t.x2,s,z,v,g);i&&(h&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(h&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&h?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),l&&(v&&h?(l.setAttribute("visibility","visible"),l.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):l.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=o.current["guideline-up-stroke"],X=o.current["guideline-up-badge"],q=o.current["guideline-up-arrow"],K=o.current["guideline-up-text"],J=o.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-_+15),W=Math.min(15,Math.abs(z-w),Math.max(0,G-U)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=o.current["guideline-down-stroke"],tt=o.current["guideline-down-badge"],et=o.current["guideline-down-arrow"],nt=o.current["guideline-down-text"],it=o.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-_-15);W=Math.min(15,Math.abs(z-w),Math.max(0,rt-G)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),St=t.useCallback(function(){Rt.current.length>0&&!F.current||(null!==At.current&&clearTimeout(At.current),At.current=setTimeout(function(){j.current(),At.current=null},50))},[]),Tt=t.useCallback(function(t){if(null!==W.current&&Z.current&&Math.abs(t.currentTarget.scrollTop-W.current)<=2){var n=Z.current;W.current=null,Z.current=null,n()}if(!bt.current&&!Q.current){if(C&&X&&(N.current||S.size>0)){var i=t.currentTarget,o=c.current,u=l.current,a=i===o?u:i===u?o:null;if(i&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=k.current,g=w.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var h=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(h[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(h[1]);return{leftAnchor:(null===(t=y.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[h[2]])||void 0===n?void 0:n.current)||(null===(i=f.current[Number(h[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=R.current[m])||void 0===r?void 0:r.current)||(null===(c=A.current[h[3]])||void 0===c?void 0:c.current)||(null===(l=p.current[Number(h[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==g?Number(g):B;return{leftAnchor:(null===(o=y.current[B])||void 0===o?void 0:o.current)||(null===(u=x.current[B])||void 0===u?void 0:u.current)||(null===(a=f.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=R.current[S])||void 0===d?void 0:d.current)||(null===(s=p.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,g=i===o?s:v,h=i===o?v:s,m=null;if(g&&h){var B=g.getBoundingClientRect(),T=h.getBoundingClientRect(),I=a.getBoundingClientRect(),E=B.top+B.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,i.scrollHeight-i.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?i.scrollTop/M*D:i.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||St(),pt.current||(pt.current=!0,requestAnimationFrame(function(){var t,n,i,o,u,a,d;if(N.current){var s=c.current,v=l.current;if(s&&v&&P.current){if(!H.current){var g=k.current,h=void 0;if("string"==typeof g&&g.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=g.split(e.DEVIATION_BADGE_SEPARATOR),p="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);h=null===(t=y.current[p])||void 0===t?void 0:t.current}else h=null===(n=y.current[g])||void 0===n?void 0:n.current;if(h){var b=h.getBoundingClientRect();H.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(i=r.current)||void 0===i?void 0:i.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(H.current){var A=H.current,R=s.scrollTop-A.initialScrollTop,x=A.badgeScreenY-R,m=((u=x,a=A.leftTop,d=A.leftBottom,Math.max(a,Math.min(d,u)))-A.cTop).toString(),B=x>=A.leftTop-4&&x<=A.leftBottom+4;P.current.setAttribute("y1",m),P.current.setAttribute("y2",m),P.current.setAttribute("visibility",B?"visible":"hidden")}}}Bt(),pt.current=!1}))}},[Bt,C,X,S,St]);return t.useEffect(function(){j.current=mt},[mt]),t.useEffect(function(){var t=setTimeout(St,250),e=function(){return q.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==At.current&&clearTimeout(At.current),null!==z.current&&clearTimeout(z.current),window.removeEventListener("resize",e)}},[K,J,U,v,m,B,d,s,$,St,T,I,_,S]),{lines:nt,setLines:it,overallConnector:ct,setOverallConnector:lt,connectedLines:dt,setConnectedLines:st,svgDimensions:gt,cachedConnectedPositions:Rt,calculateLines:mt,calculateLinesRef:j,calculateLinesDebounced:St,handleColumnScroll:Tt}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,p=n.subSectionLeftRefs,b=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,I=n.activeSideBySideSection,T=n.maintainRelativeOrder,C=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,w=n.connectedLines,G=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=w?w:ot,dt=null!=G?G:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),pt=t.useRef(!1),bt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,w,G,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===T)return!1;if(T&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}T||Object.keys(p.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(T){if(S&&null!==I)if("number"==typeof I){var it=I,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=I.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=p.current[ot])||void 0===F?void 0:F.current,Z=null===(N=b.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),T||Object.keys(et).forEach(function(t){var e,n,i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!C){a.forEach(function(t,e){var n,i=t.continuationSourceRowId?a.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,l=i>=0?i:e,o=null===(n=g.current[l])||void 0===n?void 0:n.current;if(o){var u=function(t,e){if(!T)return d[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);u.forEach(function(t){var n,u,s,v,h,g,p,b,A,y,R,x,m=null===(n=f.current[t])||void 0===n?void 0:n.current;if(m){var B=o.getBoundingClientRect(),C=m.getBoundingClientRect(),D=B.right-K.left,O=C.left-K.left,L=B.top+18-K.top,_=C.top+18-K.top;if(T&&S&&I===e){var F=null!==(s=null===(u=r.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==s?s:0,N=null!==(h=null===(v=c.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==h?h:0,H=F+(null!==(p=null===(g=r.current)||void 0===g?void 0:g.clientHeight)&&void 0!==p?p:1/0),P=N+(null!==(A=null===(b=c.current)||void 0===b?void 0:b.clientHeight)&&void 0!==A?A:1/0),k=function(t,e,n){return Math.max(e,Math.min(n,t))};L=k(B.top+18,F,H)-K.top,_=k(C.top+18,N,P)-K.top}var w=M(l);w&&J.push({id:"line-".concat(l,"-").concat(t),x1:D,y1:L,x2:O,y2:_,style:w,sectionIdx:l,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(y=a[l])||void 0===y?void 0:y.cognitiveData)||(null===(R=d[t])||void 0===R?void 0:R.cognitiveData)||(null===(x=a[l])||void 0===x?void 0:x.nodeId)&&E[a[l].nodeId])})}})}})}if(!C&&S&&"string"==typeof I&&I.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=I.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],pt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),bt=null===(H=A.current[pt])||void 0===H?void 0:H.current,At=null===(P=y.current[pt])||void 0===P?void 0:P.current;if(bt&&At){var xt=bt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,It=Bt.left-K.left,Tt=xt.top+xt.height/2-K.top,Ct=Bt.top+Bt.height/2-K.top;if(T){var Et=null!==(w=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==w?w:0,Mt=null!==(V=null===(G=c.current)||void 0===G?void 0:G.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Tt=Lt(xt.top+xt.height/2,Et,Dt)-K.top,Ct=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(pt),x1:St,y1:Tt,x2:It,y2:Ct,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,wt=c.current;if(kt&&wt){var Gt=[],Vt=kt.getBoundingClientRect().top,Yt=wt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+wt.clientHeight,Qt=kt.scrollTop,Xt=wt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(C){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var p=t.split(e.DEVIATION_BADGE_SEPARATOR),b=p[0],R=p[1],x=p[2],m="".concat(b).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(b,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),p="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?p=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+i),A=1===B.length?null:"".concat(p,"(").concat(b,")");Gt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),I=(b=S[0],R=S[1],x=S[2],S[3],m="".concat(b).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!I||!E)return;var L=I.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(b,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,w=_.top+_.height/2,G=k-Vt+Qt,V=w-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);Gt.push({lhsScrollY:G,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(w,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,w>=Yt-4&&w<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(T){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Vt+Qt,R=p-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");Gt.push({lhsScrollY:b,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var I=Kt(f,Vt,jt),T=Kt(p,Yt,zt),C=I-qt,E=T-qt,D=Rt(v,C,h,E,g,f>=Vt-4&&f<=jt+4,p>=Yt-4&&p<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:C,y2:E,matchLabel:S})}}})}else{var U=t,W=U;I=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!I||!E)return;L=I.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,w=_.top+_.height/2,G=k-Vt+Qt,V=w-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;Gt.push({lhsScrollY:G,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(w,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,w>=Yt-4&&w<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=Gt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,T,S,I,B,x,m,C]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,p,b,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,I=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,T=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,C=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(b=null===(p=r.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+T,O=M+C,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,w=0,G=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-I+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===w&&(w=t.x1,G=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var p=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-w),Math.max(0,G-U)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-w),Math.max(0,rt-G)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==bt.current&&clearTimeout(bt.current),bt.current=setTimeout(function(){Y.current(),bt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!pt.current&&!z.current){if(T&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=p.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=b.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),I=x.getBoundingClientRect(),C=a.getBoundingClientRect(),E=S.top+S.height/2;m=I.top-C.top+a.scrollTop+I.height/2-(E-C.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(pt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){pt.current=!1}))}}T||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),p="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[p])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var b=g.getBoundingClientRect();N.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,T,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==bt.current&&clearTimeout(bt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,I,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("../CognitiveComparehelpers.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("../CognitiveComparehelpers.js");exports.useSideBySide=function(t){var r=t.isGuidelineMode,i=t.maintainRelativeOrder,l=t.proposedSections,u=t.existingSections,o=t.leftContainerRef,c=t.rightContainerRef,s=t.scrollContainerRef,d=t.sectionLeftRefs,a=t.sectionRightRefs,v=t.subSectionLeftRefs,f=t.subSectionRightRefs,p=t.lhsBadgeRefs,g=t.rhsBadgeRefs,R=t.sectionRowRefs,S=t.sectionRightRowRefs,h=t.rhsTopSpacerRef,A=t.rhsBottomSpacerRef,T=t.lhsTopSpacerRef,y=t.lhsBottomSpacerRef,B=t.calculateLinesRef,m=t.setConnectedSections,E=t.setConnectedLines,x=t.cachedConnectedPositions,C=t.closeMoreFunctionsPopup,I=t.setErrorToast;t.moreFunctions,t.closeSummaryPopup;var O=e.useState(!1),_=O[0],b=O[1],D=e.useState(!1),N=D[0],P=D[1],V=e.useState(!1),G=V[0],w=V[1],L=e.useState(!1),q=L[0],F=L[1],H=e.useState(null),M=H[0],k=H[1],j=e.useRef(!1),z=e.useRef(null),J=e.useRef(!1),K=e.useRef(null),Q=e.useRef(null),U=e.useRef(null),W=e.useRef(new Set),X=function(){W.current.forEach(function(e){n.resetClauseHighlight(e)}),W.current.clear()},Y=function(e,t,r){var i,l,u,s,h,A,T,y,B,m,E,x,C=null,I=null,O=null,_=null,b=null,D=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var P=t.split(n.DEVIATION_BADGE_SEPARATOR),V="".concat(P[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(P[1]);C=(null===(i=v.current[P[2]])||void 0===i?void 0:i.current)||(null===(l=d.current[Number(P[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=f.current[P[3]])||void 0===u?void 0:u.current)||(null===(s=a.current[Number(P[3])])||void 0===s?void 0:s.current)||null,O=(null===(h=p.current[V])||void 0===h?void 0:h.current)||C,_=(null===(A=g.current[V])||void 0===A?void 0:A.current)||I}else{var G=Number(t),w=null!==r?Number(r):G;C=(null===(T=d.current[G])||void 0===T?void 0:T.current)||null,I=(null===(y=a.current[w])||void 0===y?void 0:y.current)||null,b=(null===(B=p.current[G])||void 0===B?void 0:B.current)||null,D=(null===(m=g.current[w])||void 0===m?void 0:m.current)||null,O=b||(null===(E=R.current[G])||void 0===E?void 0:E.current)||C,_=D||(null===(x=S.current[w])||void 0===x?void 0:x.current)||I}if(C&&(C.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(b&&(b.style.marginTop="0px"),D&&(D.style.marginTop="0px")),!e&&b&&D){var L=o.current,q=c.current;if(!N(b,L)||!N(D,q))return;var F=b.getBoundingClientRect(),H=D.getBoundingClientRect(),M=F.top-H.top;if(Math.abs(M)>32)return;M>0&&(D.style.marginTop="".concat(M,"px"))}else if(O&&_&&C&&I){F=O.getBoundingClientRect(),H=_.getBoundingClientRect();(M=F.top-H.top)>0&&(I.style.paddingTop="".concat(M,"px"))}},Z=e.useCallback(function(){var e,t,r,i,l,u,o,c,s=K.current,R=Q.current;if(null!==s)if("string"==typeof s&&s.includes(n.DEVIATION_BADGE_SEPARATOR)){var S=s.split(n.DEVIATION_BADGE_SEPARATOR),B=(null===(e=v.current[S[2]])||void 0===e?void 0:e.current)||(null===(t=d.current[Number(S[2])])||void 0===t?void 0:t.current)||null,m=(null===(r=f.current[S[3]])||void 0===r?void 0:r.current)||(null===(i=a.current[Number(S[3])])||void 0===i?void 0:i.current)||null;B&&(B.style.paddingTop="0px"),m&&(m.style.paddingTop="0px")}else{B=(null===(l=d.current[s])||void 0===l?void 0:l.current)||null,m=(null===(u=a.current[null!=R?R:s])||void 0===u?void 0:u.current)||null;B&&(B.style.paddingTop="0px"),m&&(m.style.paddingTop="0px");var E=(null===(o=p.current[s])||void 0===o?void 0:o.current)||null,x=(null===(c=g.current[null!=R?R:s])||void 0===c?void 0:c.current)||null;E&&(E.style.marginTop="0px"),x&&(x.style.marginTop="0px")}h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px")},[]);e.useEffect(function(){J.current=_},[_]),e.useEffect(function(){K.current=M},[M]);var $=e.useCallback(function(){X(),b(!1),J.current=!1,z.current=null,Z(),k(null),K.current=null,Q.current=null,P(!1),F(!1)},[Z]),ee=e.useCallback(function(e,t,v){var f,O,D=null===(f=null==v?void 0:v.toggleIfSame)||void 0===f||f,N=null==v?void 0:v.onReady,V=null!==(O=null==v?void 0:v.sourceSide)&&void 0!==O?O:"left";if(C(),null!=e)if(!t||r){X();var G=_&&M===e;_&&null!==M&&Z(),G&&D?$():(m(new Set([e])),E([]),x.current=[],F(!0),j.current=!0,k(e),K.current=e,b(!0),J.current=!0,P(!1),h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px"),requestAnimationFrame(function(){var t=function(){var t,v,f,T,y,m,E,x,C,I,O,_="string"==typeof e&&e.includes(n.DEVIATION_BADGE_SEPARATOR),b=null,D=null,G=null;if(r){if(_){var w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);b=(null===(t=p.current[L])||void 0===t?void 0:t.current)||null}else b=(null===(v=d.current[e])||void 0===v?void 0:v.current)||(null===(f=R.current[e])||void 0===f?void 0:f.current)||null;D=document.getElementById("guideline-target-0"),G=D?e:null}else if(_){w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);b=(null===(T=p.current[L])||void 0===T?void 0:T.current)||null,D=(null===(y=g.current[L])||void 0===y?void 0:y.current)||null,G=D?e:null}else if(b=(null===(m=d.current[e])||void 0===m?void 0:m.current)||(null===(E=R.current[e])||void 0===E?void 0:E.current)||null,i){var q=l[e],H=(null==q?void 0:q.refIndexes)||[];if(H.length>0){var M=H[0],k=u.findIndex(function(e){return e.selfIndex===M});-1!==k&&(D=(null===(I=a.current[k])||void 0===I?void 0:I.current)||(null===(O=S.current[k])||void 0===O?void 0:O.current)||null,G=k)}}else D=(null===(x=a.current[e])||void 0===x?void 0:x.current)||(null===(C=S.current[e])||void 0===C?void 0:C.current)||null,G=D?e:null;Q.current=G;var z=o.current,J=c.current,K=function(){Y(_,e,G),P(!0),B.current&&B.current(),j.current=!1,"right"===V&&J?J.dispatchEvent(new Event("scroll")):z&&z.dispatchEvent(new Event("scroll")),F(!1),null==N||N()};if(!b||!z)return j.current=!1,F(!1),void(null==N||N());if(D&&J){if(!i){var U=0;U="right"===V?D?D.getBoundingClientRect().top:0:b?b.getBoundingClientRect().top:0;var W=s.current,X=(null==W?void 0:W.getBoundingClientRect().top)||0,Z=W?W.scrollTop+U-X-150:0;return W?void n.smoothScrollTo(W,Z,200,K):void K()}var $=b.getBoundingClientRect().top-z.getBoundingClientRect().top+z.scrollTop,ee=D.getBoundingClientRect().top-J.getBoundingClientRect().top+J.scrollTop,ne=200;if("left"===V){var te=ee-($-z.scrollTop);te<0&&h.current&&!r&&(h.current.style.height="".concat(Math.abs(te),"px")),requestAnimationFrame(function(){var e,t=J.scrollHeight-J.clientHeight;if(te<0)e=0;else{if(te>t){var i=te-t;return A.current&&!r&&(A.current.style.height="".concat(i+150,"px")),void requestAnimationFrame(function(){n.smoothScrollTo(J,te,ne,K)})}e=te}n.smoothScrollTo(J,e,ne,K)})}else{var re=$-(ee-J.scrollTop);requestAnimationFrame(function(){var e,t=z.scrollHeight-z.clientHeight;if(re<0)e=0;else{if(re>t)return void requestAnimationFrame(function(){return n.smoothScrollTo(z,t,ne,K)});e=re}n.smoothScrollTo(z,e,ne,K)})}}else K()};r?setTimeout(t,100):t()}))}else I("No counterpart exists for this section.")},[M,C,u,_,i,l,Z,$,r]);return{isSideBySide:_,setIsSideBySide:b,isArrowVisible:N,setIsArrowVisible:P,isResizing:G,setIsResizing:w,isSideBySideLoading:q,setIsSideBySideLoading:F,activeSideBySideSection:M,setActiveSideBySideSection:k,scrollLock:j,sideBySideCacheRef:z,isSideBySideRef:J,activeSideBySideSectionRef:K,activeSideBySideRightSectionRef:Q,sideBySideLineRef:U,highlightedClauseRefs:W,clearClauseHighlight:X,applyAlignmentPadding:Y,resetSideBySide:$,activateSideBySide:ee}};
|
|
2
2
|
//# sourceMappingURL=useSideBySide.js.map
|
package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),l=require("react"),i=require("lucide-react"),t=require("./CognitiveNonWebSearchReasoning.module.css.js"),s=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},a=function(l){return l.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(l,i){return l.startsWith("**")&&l.endsWith("**")||l.startsWith("__")&&l.endsWith("__")?e.jsx("strong",n.__assign({className:t.default.boldText},{children:l.slice(2,-2)}),i):l})};exports.default=function(o){var d=o.item,r=o.headerTitle;o.index;var u=o.iconsConfig,c=o.DocumentTitle,v=o.previewCallback,g=o.bodyHeight,h=o.disableMaximize,m=void 0!==h&&h,f=o.onFullscreenChange,_=o.splitterCustomStyle,x=void 0!==_&&_,p=o.themeTokens,j=o.classNames,y=o.styles,b=d.dataSource,C=d.confidence_score,N=d.trainingDataTitle,I=null==u?void 0:u.ChevronDownIcon,k=null==u?void 0:u.ChevronUpIcon,T=null==u?void 0:u.MaximizeIcon,H=null==u?void 0:u.CloseIcon,L=l.useMemo(function(){var e=(b?b.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}),t=i.filter(function(n){return n.isHighlight}).length,s=[],a=[];return i.forEach(function(e){var l=e.text,i=e.isHighlight,t=e.highlightIndex;l.split("\n").forEach(function(e,l){l>0&&((a.length>0||s.length>0)&&s.push(n.__spreadArray([],a,!0)),a=[]),e&&a.push({text:e,isHighlight:i,highlightIndex:t})})}),a.length>0&&s.push(n.__spreadArray([],a,!0)),{processedLines:s.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:t}},[b]),w=L.processedLines,B=L.totalHighlights,S=l.useState(0),z=S[0],A=S[1],F=l.useRef(null),R=l.useRef(null),D=l.useRef(null),E=l.useRef([]),W=l.useRef([]);l.useEffect(function(){E.current=E.current.slice(0,B),W.current=W.current.slice(0,B)},[B]),l.useEffect(function(){if(B>0){A(0);var n=setTimeout(function(){var n;null===(n=E.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[B]),l.useEffect(function(){return function(){var n;(null===(n=D.current)||void 0===n?void 0:n.open)&&(null==f||f(!1))}},[f]);var q=function(n,e){setTimeout(function(){var l=e?W.current[n]:E.current[n];null==l||l.scrollIntoView({behavior:"smooth",block:"center"})},50)},M=function(n){if(void 0===n&&(n=!1),B){var e=z>0?z-1:B-1;A(e),q(e,n)}},U=function(n){if(void 0===n&&(n=!1),B){var e=z<B-1?z+1:0;A(e),q(e,n)}},V=function(l){var i=l?W:E,o=0;return w.map(function(l,d){l.isHeader&&(o=0),l.isListItem&&(o+=1);var r=function(){return l.segments.map(function(o,d){var r=o.isHighlight&&o.highlightIndex===z,u=o.text;return l.isListItem&&0===d&&(u=o.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),o.isHighlight?e.jsx("span",n.__assign({ref:function(n){n&&(i.current[o.highlightIndex]=n)},className:s(t.default.highlight,r?t.default.highlightActive:void 0,null==j?void 0:j.highlight,r?null==j?void 0:j.highlightActive:void 0),style:r?n.__assign(n.__assign({},null==y?void 0:y.highlight),null==y?void 0:y.highlightActive):null==y?void 0:y.highlight},{children:a(u)}),d):e.jsx("span",{children:a(u)},d)})};return l.isHeader?e.jsx("span",n.__assign({className:s(t.default.headerLine,null==j?void 0:j.headerLine),style:null==y?void 0:y.headerLine},{children:r()}),d):l.isListItem?e.jsxs("span",n.__assign({className:s(t.default.listItemLine,null==j?void 0:j.listItemLine),style:n.__assign({paddingLeft:l.indent?"1rem":"0"},null==y?void 0:y.listItemLine)},{children:[e.jsxs("span",n.__assign({className:s(t.default.listCounter,null==j?void 0:j.listCounter),style:null==y?void 0:y.listCounter},{children:[o,"."]})),e.jsx("span",{children:r()})]}),d):e.jsx("span",n.__assign({className:s(t.default.blockLine,null==j?void 0:j.blockLine),style:null==y?void 0:y.blockLine},{children:r()}),d)})},$=function(l){return B>1?e.jsxs("div",n.__assign({className:s(l?t.default.modalNavContainer:t.default.navigationContainer,l?null==j?void 0:j.modalNavContainer:null==j?void 0:j.navigationContainer),style:l?null==y?void 0:y.modalNavContainer:null==y?void 0:y.navigationContainer},{children:[k&&e.jsx("button",n.__assign({onClick:function(){return M(l)},className:s(l?t.default.modalNavButton:t.default.navButton,null==j?void 0:j.navButton),style:null==y?void 0:y.navButton},{children:e.jsx(k,{className:s(t.default.navIcon,null==j?void 0:j.navIcon),style:null==y?void 0:y.navIcon})})),e.jsxs("span",n.__assign({className:s(t.default.navCounter,null==j?void 0:j.navCounter),style:null==y?void 0:y.navCounter},{children:[z+1,"/",B]})),I&&e.jsx("button",n.__assign({onClick:function(){return U(l)},className:s(l?t.default.modalNavButton:t.default.navButton,null==j?void 0:j.navButton),style:null==y?void 0:y.navButton},{children:e.jsx(I,{className:s(t.default.navIcon,null==j?void 0:j.navIcon),style:null==y?void 0:y.navIcon})}))]})):null},O=null!=C?e.jsxs("span",n.__assign({className:s(t.default.confidenceBadge,null==j?void 0:j.confidenceBadge),style:null==y?void 0:y.confidenceBadge},{children:[e.jsx("span",n.__assign({className:t.default.confidenceStar},{children:"✦"})),e.jsxs("span",n.__assign({className:t.default.confidenceScore},{children:[C,"%"]}))]})):null,P=x?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,Y=e.jsxs(e.Fragment,{children:[N&&e.jsx("div",n.__assign({className:s(t.default.footer,null==j?void 0:j.footer),style:n.__assign(n.__assign({},P),null==y?void 0:y.footer)},{children:e.jsx("span",n.__assign({className:s(t.default.trainingTitle,null==j?void 0:j.trainingTitle),style:null==y?void 0:y.trainingTitle},{children:N}))})),c&&e.jsx("div",n.__assign({className:s(t.default.modalFooterSource,null==j?void 0:j.modalFooterSource),style:n.__assign(n.__assign({},P),null==y?void 0:y.modalFooterSource)},{children:e.jsxs("button",n.__assign({type:"button",onClick:function(){return null==v?void 0:v()},className:s(t.default.trainingTitleLink,null==j?void 0:j.trainingTitleLink),style:null==y?void 0:y.trainingTitleLink},{children:[c,e.jsx(i.ExternalLink,{size:16,color:"#2563eb"})]}))}))]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",n.__assign({className:s(t.default.expandedContainer,null==j?void 0:j.expandedContainer),style:n.__assign(n.__assign(n.__assign(n.__assign({},p),g?{height:"".concat(g),display:"flex",flexDirection:"column"}:void 0),x?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==y?void 0:y.expandedContainer)},{children:[e.jsxs("div",n.__assign({className:s(t.default.expandedHeader,null==j?void 0:j.expandedHeader),style:n.__assign(n.__assign({},x?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==y?void 0:y.expandedHeader)},{children:[e.jsx("span",n.__assign({className:s(t.default.headerTitle,null==j?void 0:j.headerTitle),style:null==y?void 0:y.headerTitle},{children:r})),e.jsxs("div",n.__assign({className:s(t.default.headerActions,null==j?void 0:j.headerActions),style:null==y?void 0:y.headerActions},{children:[x?B>1&&e.jsxs(e.Fragment,{children:[e.jsxs("span",n.__assign({style:{fontSize:"12px",color:"#888"}},{children:[z+1," / ",B]})),e.jsx("button",n.__assign({onClick:function(){return M(!0)},disabled:z<=0,style:{padding:"2px 4px",cursor:z<=0?"not-allowed":"pointer",opacity:z<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(i.ChevronUp,{size:14,color:"#64748b"})})),e.jsx("button",n.__assign({onClick:function(){return U(!0)},disabled:z>=B-1,style:{padding:"2px 4px",cursor:z>=B-1?"not-allowed":"pointer",opacity:z>=B-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(i.ChevronDown,{size:14,color:"#64748b"})}))]}):$(!1),O,!m&&T&&e.jsx("button",n.__assign({onClick:function(){var n;null==f||f(!0),null===(n=D.current)||void 0===n||n.showModal()},className:s(t.default.maximizeButton,null==j?void 0:j.maximizeButton),style:null==y?void 0:y.maximizeButton,title:"View fullscreen"},{children:e.jsx(T,{className:t.default.maximizeIcon})}))]}))]})),e.jsx("div",n.__assign({ref:F,className:s(t.default.contentArea,null==j?void 0:j.contentArea),style:n.__assign(n.__assign(n.__assign({},g?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),x?{padding:"1rem 1.5rem"}:void 0),null==y?void 0:y.contentArea)},{children:e.jsx("div",n.__assign({className:s(t.default.contentInner,null==j?void 0:j.contentInner),style:null==y?void 0:y.contentInner},{children:V(!1)}))})),Y]})),!m&&e.jsx("dialog",n.__assign({ref:D,className:t.default.modalDialog,onClose:function(){return null==f?void 0:f(!1)},onClick:function(n){var e;n.target===D.current&&(null===(e=D.current)||void 0===e||e.close())}},{children:e.jsxs("div",n.__assign({className:s(t.default.modalContainer,null==j?void 0:j.modalContainer),style:null==y?void 0:y.modalContainer},{children:[e.jsxs("div",n.__assign({className:s(t.default.modalHeader,null==j?void 0:j.modalHeader),style:null==y?void 0:y.modalHeader},{children:[e.jsx("span",n.__assign({className:s(t.default.modalHeaderTitle,null==j?void 0:j.modalHeaderTitle),style:null==y?void 0:y.modalHeaderTitle},{children:r})),e.jsxs("div",n.__assign({className:s(t.default.modalHeaderActions,null==j?void 0:j.modalHeaderActions),style:null==y?void 0:y.modalHeaderActions},{children:[x?B>1&&e.jsxs(e.Fragment,{children:[e.jsxs("span",n.__assign({style:{fontSize:"12px",color:"#888"}},{children:[z+1," / ",B]})),e.jsx("button",n.__assign({onClick:function(){return M(!0)},disabled:z<=0,style:{padding:"2px 4px",cursor:z<=0?"not-allowed":"pointer",opacity:z<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(i.ChevronUp,{size:14,color:"#64748b"})})),e.jsx("button",n.__assign({onClick:function(){return U(!0)},disabled:z>=B-1,style:{padding:"2px 4px",cursor:z>=B-1?"not-allowed":"pointer",opacity:z>=B-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(i.ChevronDown,{size:14,color:"#64748b"})}))]}):$(!0),O,H&&e.jsx("button",n.__assign({onClick:function(){var n;return null===(n=D.current)||void 0===n?void 0:n.close()},className:s(t.default.closeButton,null==j?void 0:j.closeButton),style:null==y?void 0:y.closeButton,title:"Close"},{children:e.jsx(H,{className:s(t.default.closeIcon,null==j?void 0:j.closeIcon),style:null==y?void 0:y.closeIcon})}))]}))]})),e.jsx("div",n.__assign({ref:R,className:s(t.default.modalContent,null==j?void 0:j.modalContent),style:null==y?void 0:y.modalContent},{children:e.jsx("div",n.__assign({className:s(t.default.modalContentInner,null==j?void 0:j.modalContentInner),style:null==y?void 0:y.modalContentInner},{children:V(!0)}))})),N&&e.jsx("div",n.__assign({className:s(t.default.modalFooter,null==j?void 0:j.modalFooter),style:null==y?void 0:y.modalFooter},{children:e.jsx("span",n.__assign({className:s(t.default.trainingTitle,null==j?void 0:j.trainingTitle),style:null==y?void 0:y.trainingTitle},{children:N}))})),c&&e.jsx("div",n.__assign({className:s(t.default.modalFooterSource,null==j?void 0:j.modalFooterSource),style:null==y?void 0:y.modalFooterSource},{children:e.jsxs("button",n.__assign({type:"button",onClick:function(){var n;null==v||v(),null===(n=D.current)||void 0===n||n.close()},className:s(t.default.trainingTitleLink,null==j?void 0:j.trainingTitleLink),style:null==y?void 0:y.trainingTitleLink},{children:[c,e.jsx(i.ExternalLink,{size:16,color:"#2563eb"})]}))}))]}))}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),l=require("lucide-react"),t=require("./CognitiveNonWebSearchReasoning.module.css.js"),s=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},a=function(i){return i.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(i,l){return i.startsWith("**")&&i.endsWith("**")||i.startsWith("__")&&i.endsWith("__")?e.jsx("strong",n.__assign({className:t.default.boldText},{children:i.slice(2,-2)}),l):i})};exports.default=function(o){var d=o.item,r=o.headerTitle;o.index;var u=o.iconsConfig,c=o.DocumentTitle,v=o.previewCallback,g=o.bodyHeight,h=o.disableMaximize,m=void 0!==h&&h,_=o.splitterCustomStyle,f=void 0!==_&&_,x=o.themeTokens,p=o.classNames,j=o.styles,y=d.dataSource,b=d.confidence_score,C=d.trainingDataTitle,N=null==u?void 0:u.ChevronDownIcon,I=null==u?void 0:u.ChevronUpIcon,k=null==u?void 0:u.MaximizeIcon,T=null==u?void 0:u.CloseIcon,H=i.useMemo(function(){var e=(y?y.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),i=0,l=e.map(function(n){var e=n.startsWith("<highlight>"),l={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?i:-1};return e&&i++,l}),t=l.filter(function(n){return n.isHighlight}).length,s=[],a=[];return l.forEach(function(e){var i=e.text,l=e.isHighlight,t=e.highlightIndex;i.split("\n").forEach(function(e,i){i>0&&((a.length>0||s.length>0)&&s.push(n.__spreadArray([],a,!0)),a=[]),e&&a.push({text:e,isHighlight:l,highlightIndex:t})})}),a.length>0&&s.push(n.__spreadArray([],a,!0)),{processedLines:s.map(function(n){var e=n.map(function(n){return n.text}).join(""),i=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!i,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==i?void 0:i[1])||"",content:(null==i?void 0:i[3])||e}}),totalHighlights:t}},[y]),L=H.processedLines,w=H.totalHighlights,B=i.useState(0),S=B[0],z=B[1],A=i.useRef(null),F=i.useRef(null),R=i.useRef(null),D=i.useRef([]),E=i.useRef([]);i.useEffect(function(){D.current=D.current.slice(0,w),E.current=E.current.slice(0,w)},[w]),i.useEffect(function(){if(w>0){z(0);var n=setTimeout(function(){var n;null===(n=D.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[w]);var W=function(n,e){setTimeout(function(){var i=e?E.current[n]:D.current[n];null==i||i.scrollIntoView({behavior:"smooth",block:"center"})},50)},q=function(n){if(void 0===n&&(n=!1),w){var e=S>0?S-1:w-1;z(e),W(e,n)}},M=function(n){if(void 0===n&&(n=!1),w){var e=S<w-1?S+1:0;z(e),W(e,n)}},U=function(i){var l=i?E:D,o=0;return L.map(function(i,d){i.isHeader&&(o=0),i.isListItem&&(o+=1);var r=function(){return i.segments.map(function(o,d){var r=o.isHighlight&&o.highlightIndex===S,u=o.text;return i.isListItem&&0===d&&(u=o.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),o.isHighlight?e.jsx("span",n.__assign({ref:function(n){n&&(l.current[o.highlightIndex]=n)},className:s(t.default.highlight,r?t.default.highlightActive:void 0,null==p?void 0:p.highlight,r?null==p?void 0:p.highlightActive:void 0),style:r?n.__assign(n.__assign({},null==j?void 0:j.highlight),null==j?void 0:j.highlightActive):null==j?void 0:j.highlight},{children:a(u)}),d):e.jsx("span",{children:a(u)},d)})};return i.isHeader?e.jsx("span",n.__assign({className:s(t.default.headerLine,null==p?void 0:p.headerLine),style:null==j?void 0:j.headerLine},{children:r()}),d):i.isListItem?e.jsxs("span",n.__assign({className:s(t.default.listItemLine,null==p?void 0:p.listItemLine),style:n.__assign({paddingLeft:i.indent?"1rem":"0"},null==j?void 0:j.listItemLine)},{children:[e.jsxs("span",n.__assign({className:s(t.default.listCounter,null==p?void 0:p.listCounter),style:null==j?void 0:j.listCounter},{children:[o,"."]})),e.jsx("span",{children:r()})]}),d):e.jsx("span",n.__assign({className:s(t.default.blockLine,null==p?void 0:p.blockLine),style:null==j?void 0:j.blockLine},{children:r()}),d)})},V=function(i){return w>1?e.jsxs("div",n.__assign({className:s(i?t.default.modalNavContainer:t.default.navigationContainer,i?null==p?void 0:p.modalNavContainer:null==p?void 0:p.navigationContainer),style:i?null==j?void 0:j.modalNavContainer:null==j?void 0:j.navigationContainer},{children:[I&&e.jsx("button",n.__assign({onClick:function(){return q(i)},className:s(i?t.default.modalNavButton:t.default.navButton,null==p?void 0:p.navButton),style:null==j?void 0:j.navButton},{children:e.jsx(I,{className:s(t.default.navIcon,null==p?void 0:p.navIcon),style:null==j?void 0:j.navIcon})})),e.jsxs("span",n.__assign({className:s(t.default.navCounter,null==p?void 0:p.navCounter),style:null==j?void 0:j.navCounter},{children:[S+1,"/",w]})),N&&e.jsx("button",n.__assign({onClick:function(){return M(i)},className:s(i?t.default.modalNavButton:t.default.navButton,null==p?void 0:p.navButton),style:null==j?void 0:j.navButton},{children:e.jsx(N,{className:s(t.default.navIcon,null==p?void 0:p.navIcon),style:null==j?void 0:j.navIcon})}))]})):null},$=null!=b?e.jsxs("span",n.__assign({className:s(t.default.confidenceBadge,null==p?void 0:p.confidenceBadge),style:null==j?void 0:j.confidenceBadge},{children:[e.jsx("span",n.__assign({className:t.default.confidenceStar},{children:"✦"})),e.jsxs("span",n.__assign({className:t.default.confidenceScore},{children:[b,"%"]}))]})):null,O=f?{backgroundColor:"white",padding:"1rem 1.5rem"}:void 0,P=e.jsxs(e.Fragment,{children:[C&&e.jsx("div",n.__assign({className:s(t.default.footer,null==p?void 0:p.footer),style:n.__assign(n.__assign({},O),null==j?void 0:j.footer)},{children:e.jsx("span",n.__assign({className:s(t.default.trainingTitle,null==p?void 0:p.trainingTitle),style:null==j?void 0:j.trainingTitle},{children:C}))})),c&&e.jsx("div",n.__assign({className:s(t.default.modalFooterSource,null==p?void 0:p.modalFooterSource),style:n.__assign(n.__assign({},O),null==j?void 0:j.modalFooterSource)},{children:e.jsxs("button",n.__assign({type:"button",onClick:function(){return null==v?void 0:v()},className:s(t.default.trainingTitleLink,null==p?void 0:p.trainingTitleLink),style:null==j?void 0:j.trainingTitleLink},{children:[c,e.jsx(l.ExternalLink,{size:16,color:"#2563eb"})]}))}))]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",n.__assign({className:s(t.default.expandedContainer,null==p?void 0:p.expandedContainer),style:n.__assign(n.__assign(n.__assign(n.__assign({},x),g?{height:"".concat(g),display:"flex",flexDirection:"column"}:void 0),f?{border:"none",borderRadius:0,marginLeft:"0px",marginTop:"0px"}:void 0),null==j?void 0:j.expandedContainer)},{children:[e.jsxs("div",n.__assign({className:s(t.default.expandedHeader,null==p?void 0:p.expandedHeader),style:n.__assign(n.__assign({},f?{backgroundColor:"white",padding:"0.5rem 1.5rem"}:void 0),null==j?void 0:j.expandedHeader)},{children:[e.jsx("span",n.__assign({className:s(t.default.headerTitle,null==p?void 0:p.headerTitle),style:null==j?void 0:j.headerTitle},{children:r})),e.jsxs("div",n.__assign({className:s(t.default.headerActions,null==p?void 0:p.headerActions),style:null==j?void 0:j.headerActions},{children:[f?w>1&&e.jsxs(e.Fragment,{children:[e.jsxs("span",n.__assign({style:{fontSize:"12px",color:"#888"}},{children:[S+1," / ",w]})),e.jsx("button",n.__assign({onClick:function(){return q(!0)},disabled:S<=0,style:{padding:"2px 4px",cursor:S<=0?"not-allowed":"pointer",opacity:S<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(l.ChevronUp,{size:14,color:"#64748b"})})),e.jsx("button",n.__assign({onClick:function(){return M(!0)},disabled:S>=w-1,style:{padding:"2px 4px",cursor:S>=w-1?"not-allowed":"pointer",opacity:S>=w-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(l.ChevronDown,{size:14,color:"#64748b"})}))]}):V(!1),$,!m&&k&&e.jsx("button",n.__assign({onClick:function(){var n;return null===(n=R.current)||void 0===n?void 0:n.showModal()},className:s(t.default.maximizeButton,null==p?void 0:p.maximizeButton),style:null==j?void 0:j.maximizeButton,title:"View fullscreen"},{children:e.jsx(k,{className:t.default.maximizeIcon})}))]}))]})),e.jsx("div",n.__assign({ref:A,className:s(t.default.contentArea,null==p?void 0:p.contentArea),style:n.__assign(n.__assign(n.__assign({},g?{flex:1,maxHeight:"300px",overflowY:"scroll",minHeight:0}:void 0),f?{padding:"1rem 1.5rem"}:void 0),null==j?void 0:j.contentArea)},{children:e.jsx("div",n.__assign({className:s(t.default.contentInner,null==p?void 0:p.contentInner),style:null==j?void 0:j.contentInner},{children:U(!1)}))})),P]})),!m&&e.jsx("dialog",n.__assign({ref:R,className:t.default.modalDialog,onClick:function(n){var e;n.target===R.current&&(null===(e=R.current)||void 0===e||e.close())}},{children:e.jsxs("div",n.__assign({className:s(t.default.modalContainer,null==p?void 0:p.modalContainer),style:null==j?void 0:j.modalContainer},{children:[e.jsxs("div",n.__assign({className:s(t.default.modalHeader,null==p?void 0:p.modalHeader),style:null==j?void 0:j.modalHeader},{children:[e.jsx("span",n.__assign({className:s(t.default.modalHeaderTitle,null==p?void 0:p.modalHeaderTitle),style:null==j?void 0:j.modalHeaderTitle},{children:r})),e.jsxs("div",n.__assign({className:s(t.default.modalHeaderActions,null==p?void 0:p.modalHeaderActions),style:null==j?void 0:j.modalHeaderActions},{children:[f?w>1&&e.jsxs(e.Fragment,{children:[e.jsxs("span",n.__assign({style:{fontSize:"12px",color:"#888"}},{children:[S+1," / ",w]})),e.jsx("button",n.__assign({onClick:function(){return q(!0)},disabled:S<=0,style:{padding:"2px 4px",cursor:S<=0?"not-allowed":"pointer",opacity:S<=0?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(l.ChevronUp,{size:14,color:"#64748b"})})),e.jsx("button",n.__assign({onClick:function(){return M(!0)},disabled:S>=w-1,style:{padding:"2px 4px",cursor:S>=w-1?"not-allowed":"pointer",opacity:S>=w-1?.4:1,border:"1px solid #ddd",borderRadius:"3px",background:"white",display:"flex",alignItems:"center"}},{children:e.jsx(l.ChevronDown,{size:14,color:"#64748b"})}))]}):V(!0),$,T&&e.jsx("button",n.__assign({onClick:function(){var n;return null===(n=R.current)||void 0===n?void 0:n.close()},className:s(t.default.closeButton,null==p?void 0:p.closeButton),style:null==j?void 0:j.closeButton,title:"Close"},{children:e.jsx(T,{className:s(t.default.closeIcon,null==p?void 0:p.closeIcon),style:null==j?void 0:j.closeIcon})}))]}))]})),e.jsx("div",n.__assign({ref:F,className:s(t.default.modalContent,null==p?void 0:p.modalContent),style:null==j?void 0:j.modalContent},{children:e.jsx("div",n.__assign({className:s(t.default.modalContentInner,null==p?void 0:p.modalContentInner),style:null==j?void 0:j.modalContentInner},{children:U(!0)}))})),C&&e.jsx("div",n.__assign({className:s(t.default.modalFooter,null==p?void 0:p.modalFooter),style:null==j?void 0:j.modalFooter},{children:e.jsx("span",n.__assign({className:s(t.default.trainingTitle,null==p?void 0:p.trainingTitle),style:null==j?void 0:j.trainingTitle},{children:C}))})),c&&e.jsx("div",n.__assign({className:s(t.default.modalFooterSource,null==p?void 0:p.modalFooterSource),style:null==j?void 0:j.modalFooterSource},{children:e.jsxs("button",n.__assign({type:"button",onClick:function(){var n;null==v||v(),null===(n=R.current)||void 0===n||n.close()},className:s(t.default.trainingTitleLink,null==p?void 0:p.trainingTitleLink),style:null==j?void 0:j.trainingTitleLink},{children:[c,e.jsx(l.ExternalLink,{size:16,color:"#2563eb"})]}))}))]}))}))]})};
|
|
2
2
|
//# sourceMappingURL=CognitiveInternalgptCoreComponent.js.map
|