@viswa-test/test-citation 0.0.167 → 0.0.169
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/components/LHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/ScrollLockToggle.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/connectedLines.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/ScrollLockToggle.js +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/features/CognitiveCompare/components/connectedLines.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +783 -7527
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/connectedLines.d.ts +4 -2
- package/dist/types/src/features/CognitiveCompare/components/connectedLines.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/useCompareLayout.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),i=require("react"),n=require("@mui/material"),t=require("lucide-react"),r=require("./SectionAccordion.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),i=require("react"),n=require("@mui/material"),t=require("lucide-react"),r=require("./SectionAccordion.js"),a=require("./ThreeDotsLoader.js"),l=require("../CognitiveComparehelpers.js"),s=require("../CompareContext.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(i).default.memo(function(i){var d,c,u,p=i.section,x=i.idx,g=s.useCompareContext(),v=g.maintainRelativeOrder,f=g.existingSections;g.proposedSections;var m=g.connectedSections,b=g.expandedSections,h=g.displayConfig,S=g.treeData;g.deviationNumberRegistry;var B=g.getSectionCompareStyle;g.getBadgeRef;var _=g.getSectionRowRef,y=g.sectionLeftRefs,R=g.lhsBadgeRefs,j=g.openMoreFunctionsPopup,w=g.handleOpenSummaryPopup,C=g.handleCloseSummaryPopup,I=g.toggleSection;g.showDeviationBadges,g.renderSubSectionAccordion,g.isProposingFix,g.proposingFixNodeId,g.isRedlineFlow,g.isSideBySide,g.activeSideBySideSection,g.scrollSyncLocked,g.toggleScrollSyncLocked,g.summaryPopupAnchorEl,g.deviationNodeIdToView,g.deviationTargetParentId;var N=g.showDeviationNavigation;g.showOpenNodeRef,g.resolvedMarkdownStyles;var q=g.unifiedNumbering,P=!p.title&&!p.content;if(v&&P)return null;var k=p,D=B(x,"left"),T=v?!(null===(d=k.refIndexes)||void 0===d?void 0:d.length)||k.selfIndex<0:!f[x],A=m.has(x);null===(c=R.current[x])||void 0===c||c.current;var L=l.extractDeviationScore(k.evaluationResult,null==D?void 0:D.deviationLabel),z=q.leftNums.get(k.id);return o.jsx(n.Box,e.__assign({ref:_(x),sx:{mb:1,width:"100%"}},{children:o.jsx(n.Box,e.__assign({ref:y.current[x],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},A&&{borderRadius:"6px",outline:"2px solid ".concat((null==D?void 0:D.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:o.jsxs(n.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[o.jsx(r.default,{section:p,idx:x,columnKey:"left",colRef:_("left-accordion-".concat(x)),mb:0,parentNodeId:(null===(u=null==S?void 0:S.input_index_map)||void 0===u?void 0:u[0])||"",isExpanded:v?!!b["left-".concat(x)]:!!b[String(x)],onToggle:function(){C(),I(x,"left")},navigation:p.id?N[p.id]:null}),v&&D&&o.jsxs(n.Box,e.__assign({ref:R.current[x],onClick:function(e){var o,i,n,t=h.enableDeviationSchemaBackwardCompatibility?null!==(o=k.evaluationResult)&&void 0!==o?o:null:null!==(n=null===(i=k.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==n?n:null;w(e,String(x),T,t)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:D.badgeBg,color:D.badgeText,border:"1px solid ".concat(D.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[o.jsxs(n.Box,e.__assign({component:"span",onClick:function(e){var o,i,n;e.stopPropagation();var t=h.enableDeviationSchemaBackwardCompatibility?null!==(o=k.evaluationResult)&&void 0!==o?o:null:null!==(n=null===(i=k.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==n?n:null;w(e,String(x),T,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:T?"default":"pointer",borderRight:"1px solid ".concat(D.badgeBorder),"&:hover":T?{}:{bgColor:"".concat(D.badgeBorder,"22")}}},{children:[null!=z&&o.jsx(n.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(D.badgeBorder)}},{children:z})),o.jsx(n.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!h.isLoading||null!=k.evaluationResult&&void 0!==k.evaluationResult?"N/A"===L||"NA"===L?"N/A":0==L||null==L?"Same":"".concat(L):o.jsx(a.default,{color:D.badgeText})}))]})),o.jsx(n.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var o=v?f.find(function(e){var o;return null===(o=k.refIndexes)||void 0===o?void 0:o.includes(e.selfIndex)})||{title:"",content:""}:f[x]||{title:"",content:""};j(e,p,T,o,x,D)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(D.badgeBorder,"22")}}},{children:o.jsx(t.EllipsisVertical,{size:11,color:D.badgeText})}))]}))]}))}))}),"left-row-".concat(x))});exports.default=c;
|
|
2
2
|
//# sourceMappingURL=LHSSectionRow.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),i=require("@mui/material");exports.default=function(r){var t=r.locked,s=r.onToggle,n=r.color,l=void 0===n?"#3730A3":n,c=r.borderColor,d=void 0===c?"#C7D2FE":c,a=r.size,u=void 0===a?12:a,x=t?function(i){var r=i.size,t=i.color;return o.jsxs("svg",e.__assign({xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock"},{children:[o.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),o.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}))}:function(i){var r=i.size,t=i.color;return o.jsxs("svg",e.__assign({xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-open-icon lucide-lock-open"},{children:[o.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),o.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}))};return o.jsx(i.Tooltip,e.__assign({title:t?"Unlock scroll":"Lock scroll",placement:"top"},{children:o.jsx(i.Box,e.__assign({component:"span",onClick:s,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:.5,borderLeft:"1px solid ".concat(d),cursor:"pointer"}},{children:o.jsx(x,{size:u,color:l})}))}))};
|
|
2
2
|
//# sourceMappingURL=ScrollLockToggle.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("lucide-react"),n=require("../../../assests/svg/ButtonCognitiveIcon.js"),s=require("../CognitiveComparehelpers.js"),o=require("../CognitiveCompareConstants.js"),l=require("./ThreeDotsLoader.js"),r=require("./connectedLines.js"),a=require("@mui/material");exports.default=function(d){var c=d.svgContainerRef,u=d.svgDimensions,g=d.isResizing,v=d.overallConnector,x=d.rootDeviationStyle,p=d.lines,h=d.isSideBySide,y=d.activeSideBySideSection,b=d.isArrowVisible,f=d.maintainRelativeOrder,S=d.proposedSections,_=d.existingSections,j=d.cognitivePopup,m=d.activeBadgeId,I=d.closeCognitivePopup,B=d.setActiveBadgeId,C=d.openCognitivePopupFromState,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("lucide-react"),n=require("../../../assests/svg/ButtonCognitiveIcon.js"),s=require("../CognitiveComparehelpers.js"),o=require("../CognitiveCompareConstants.js"),l=require("./ThreeDotsLoader.js"),r=require("./connectedLines.js"),a=require("@mui/material");exports.default=function(d){var c=d.svgContainerRef,u=d.svgDimensions,g=d.isResizing,v=d.overallConnector,x=d.rootDeviationStyle,p=d.lines,h=d.isSideBySide,y=d.activeSideBySideSection,b=d.isArrowVisible,f=d.maintainRelativeOrder,S=d.proposedSections,_=d.existingSections,j=d.cognitivePopup,m=d.activeBadgeId,I=d.closeCognitivePopup,B=d.setActiveBadgeId,C=d.openCognitivePopupFromState,R=d.buildSectionPopupState,A=d.connectedLines,P=d.pathRefs;return t.jsxs("svg",e.__assign({ref:c,style:{position:"absolute",top:0,left:0,width:u.width||"100%",height:u.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:g?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[v&&t.jsx("g",{children:t.jsx("line",{x1:v.x1,y1:v.y,x2:v.x2,y2:v.y,stroke:x.badgeBorder,strokeWidth:"1.5"})}),p.map(function(r){var d,c,u,g,v,x,p,A=r.x1+.5*(r.x2-r.x1),P=(r.y1+r.y2)/2;if("Not Defined"===r.style.label&&!r.hasCognitive)return null;if(r.isSubSection?h&&y===r.subSectionKeyPath&&b:h&&y===r.sectionIdx&&b)return null;if(f)return null;var D=r.isSubSection?s.getBentArrowPath(r.x1,r.y1,r.x2,r.y2):"M ".concat(r.x1," ").concat(r.y1," L ").concat(r.x2," ").concat(r.y2),w=S[r.sectionIdx]||{title:"",content:""},E=_[null!==(d=r.targetRightIdx)&&void 0!==d?d:r.sectionIdx]||{title:"",content:""};if(r.isSubSection&&r.subSectionKeyPath){var O=r.subSectionKeyPath.includes(s.DEVIATION_BADGE_SEPARATOR)?r.subSectionKeyPath.split(s.DEVIATION_BADGE_SEPARATOR):[],T=O[2]||r.subSectionKeyPath,q=O[3]||T,L=T.split("-").map(Number),N=q.split("-").map(Number),k=null,K=null;L.length>0&&(k=S[L[0]]||null),N.length>0&&(K=_[N[0]]||null);for(var z=(null==k?void 0:k.title)||"",V=(null==K?void 0:K.title)||"",F=1;F<L.length;F+=1)(null==k?void 0:k.subsections)&&(k=k.subsections[L[F]]||null);for(F=1;F<N.length;F+=1)(null==K?void 0:K.subsections)&&(K=K.subsections[N[F]]||null);k&&(w=e.__assign(e.__assign({},k),{title:z||k.title})),K&&(E=e.__assign(e.__assign({},K),{title:V||K.title}))}var M=!(null===(c=w.cognitiveData)||void 0===c?void 0:c.isMissingRationale)||Boolean(null===(g=null===(u=w.cognitiveData)||void 0===u?void 0:u.decisioning)||void 0===g?void 0:g.length),W=(null===(p=null===(x=null===(v=w.evaluationResult)||void 0===v?void 0:v.cognitive_decisioning)||void 0===x?void 0:x.decisioning_factors)||void 0===p?void 0:p.length)||!1,G=M||W;return t.jsxs("g",{children:[t.jsx("path",{d:D,fill:"none",stroke:r.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t.jsx("foreignObject",e.__assign({x:A-100,y:P-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t.jsx(a.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t.jsxs(a.Box,e.__assign({onClick:function(e){e.stopPropagation(),G&&(j.open&&m===r.id?I():(B(r.id),C(R(e.currentTarget,w,E,r.sectionIdx,!1,r.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:r.style.badgeBg,color:r.style.badgeText,border:"1px solid ".concat(r.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:G?"pointer":"default"}},{children:[r.style.badgeText===o.DEFAULT_DEVIAION_COLOR&&null==r.style.label?t.jsx(l.default,{color:r.style.badgeText}):null==r.style.label?null:"0"===String(r.style.label)?"Same":r.style.label,t.jsx(a.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t.jsx(n.ButtonCognitiveIcon,{})})),G&&t.jsx(i.ChevronDown,{size:11,style:{transform:j.open&&m===r.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},r.id)}),t.jsx(r.default,{maintainRelativeOrder:f,connectedLines:A,pathRefs:P})]}))};
|
|
2
2
|
//# sourceMappingURL=SvgConnectors.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime");exports.default=function(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("@mui/material"),o=require("./ScrollLockToggle.js"),n=require("../CompareContext.js");exports.default=function(i){var s=i.connectedLines,c=i.pathRefs,a=i.maintainRelativeOrder,l=n.useCompareContext(),d=l.scrollSyncLocked,u=l.toggleScrollSyncLocked;return r.jsx(r.Fragment,{children:s.map(function(n){var i,s,l=n.pathD,x=(null===(i=n.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",f="conn-marker-".concat(n.id),p="".concat(n.id,"-bg"),g="".concat(n.id,"-stroke"),h="".concat(n.id,"-btn"),j=void 0!==n.x1?n.x1+40:0,k=void 0!==n.y1?n.y1:0;return r.jsxs("g",{children:[r.jsx("defs",{children:r.jsx("clipPath",e.__assign({id:"connections-clip"},{children:r.jsx("marker",e.__assign({id:f,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:r.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:x})}))}))}),r.jsx("path",{ref:function(e){c.current[p]=e},d:l,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),r.jsx("path",{ref:function(e){c.current[g]=e},d:l,fill:"none",stroke:x,strokeWidth:"1.75",markerEnd:"url(#".concat(f,")")}),a&&void 0!==n.x1&&r.jsx("foreignObject",e.__assign({ref:function(e){c.current[h]=e},x:j-12,y:k-12,width:"24",height:"24",style:{pointerEvents:"auto",overflow:"visible"}},{children:r.jsx(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),u&&u(e)},sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",bgcolor:"#FFFFFF",borderRadius:"50%",border:"1px solid ".concat(x),cursor:"pointer",transition:"transform 0.2s ease","&:hover":{transform:"scale(1.05)",boxShadow:"0px 2px 4px rgba(0,0,0,0.1)"}}},{children:r.jsx(o.default,{locked:d,onToggle:u,color:(null===(s=n.style)||void 0===s?void 0:s.badgeText)||x,borderColor:"transparent",size:12})}))}))]},n.id)})})};
|
|
2
2
|
//# sourceMappingURL=connectedLines.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("@mui/material"),t=require("react"),i=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw"),c=require("remark-gfm"),d=require("../components/ScrollLockToggle.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=u(t),h=u(a),p=u(l),f=u(c),v=g.default.memo(function(a){var l=a.content,c=a.overlayContent,u=a.sxStyles,v=a.deviationBadges,x=void 0===v?[]:v,m=a.highlights,_=void 0===m?[]:m;a.maintainRelativeOrder;var b=a.highlightBg,y=a.suppressHighlightBg,B=void 0!==y&&y,E=a.collisionKey,C=t.useRef(null),j=!!c,S=t.useMemo(function(){return x.reduce(function(n,r){var t;return e.__assign(e.__assign({},n),((t={})[r.id]=r,t))},{})},[x]),k=t.useRef({badgeMap:S,highlightBg:b,hideHighlightBg:j,suppressHighlightBg:B});k.current={badgeMap:S,highlightBg:b,hideHighlightBg:j,suppressHighlightBg:B};var F=function(n,r){return g.default.Children.map(n,function(n){var t;if(!g.default.isValidElement(n))return n;var i=(null===(t=n.props)||void 0===t?void 0:t.children)?F(n.props.children,r):n.props.children,o=g.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:i}));return r(o)})},w=t.useMemo(function(){return{mark:function(r){var t,i,o,a,s=r.children,l=e.__rest(r,["children"]),c=k.current,d=c.badgeMap,u=c.highlightBg,g=c.hideHighlightBg,h=c.suppressHighlightBg,p=l["data-badge-id"],f=p?d[p]:null,v=l["data-highlight-color"],x=null!==(a=null!==(i=null!=v?v:null===(t=null==f?void 0:f.style)||void 0===t?void 0:t.highlightBg)&&void 0!==i?i:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m=l.isSuggestedDeviationFix||h;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"}),g?{color:"transparent"}:{})},{children:s}))},span:function(t){var a,s,l,c,u,g,h,p,f=t.children,v=e.__rest(t,["children"]),x=k.current.badgeMap,m=v["data-badge-id"];if(!m)return n.jsx("span",e.__assign({},v,{children:f}));var _=x[m];if(!_)return n.jsx("span",e.__assign({},v,{children:f}));var b="number"==typeof _.stackIndex?_.stackIndex:0,y="translateY(calc(-20% + ".concat(12*b,"px + var(--badge-nudge, 0px)))");return n.jsxs(r.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(r.Box,e.__assign({ref:_.badgeRef,className:"deviation-badge","data-side":_.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+b,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=_.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=_.style)||void 0===s?void 0:s.badgeText)||i.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=_.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"===_.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),_.isConnected&&_.style&&{outline:"2px solid ".concat(_.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),_.onSummaryClick&&_.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:_.label})),("left"===_.side||_.isOrphan)&&n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=_.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=_.score&&"N/A"!==_.score&&"NA"!==_.score&&0!==_.score?"".concat(_.score):"N/A"===_.score||"NA"===_.score?"N/A":"Same"}))]})),("left"===_.side||_.isOrphan)&&n.jsxs(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),_.onClick&&_.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(u=_.style)||void 0===u?void 0:u.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:[n.jsx(o.EllipsisVertical,{size:12,color:(null===(g=_.style)||void 0===g?void 0:g.badgeText)||"#3730A3"}),_.showScrollLockToggle&&n.jsx(d.default,{locked:!!_.scrollSyncLocked,onToggle:_.toggleScrollSyncLocked,color:(null===(h=_.style)||void 0===h?void 0:h.badgeText)||"#3730A3",borderColor:(null===(p=_.style)||void 0===p?void 0:p.badgeBorder)||"#C7D2FE",size:12})]}))]})),f]}))},table:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:i}))},thead:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"thead"},{children:i}))},tbody:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"tbody"},{children:i}))},tr:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"tr",sx:{borderBotttom:"1px solid #E5E7EB"}},{children:i}))},th:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:i}))},td:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:i}))},updated:function(r){var t=r.children;return e.__rest(r,["children"]),n.jsx(n.Fragment,{children:t})},deleted:function(r){var t=r.children;e.__rest(r,["children"]),console.log("nitish: ",t);var i=F(t,function(e){return g.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(r){var t=r.children;e.__rest(r,["children"]);var i=F(t,function(e){return g.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))}}},[]),T=function(e){if(!e)return"";var n=e.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n");return/\|.*\|/.test(n)&&/\|[-:\s]+\|/.test(n)?n.replace(/(\|.*\|)\n\s*\n(?=\|)/g,"$1\n"):n.split(/(\n{2,})/).map(function(e){return e.startsWith("\n")?e:e.replace(/\n/g," ")}).join("")},A=t.useMemo(function(){return x.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[x]),M=function(e){return e.replace(/[\.,;:]/g," ")},q=t.useMemo(function(){var n=T(s.safeStringify(l||"")),r=B?M(n):n,t=(x||[]).map(function(e){var n,r;return{id:null==e?void 0:e.id,highlight:T((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(r=null==e?void 0:e.style)||void 0===r?void 0:r.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 o=function(e,n){void 0===e&&(e="");var r=n?' data-highlight-color="'.concat(n,'"'):"";return'<mark data-badge-id="'.concat(e,'"').concat(r,">")},a=function(e){return'<span data-badge-id="'.concat(e,'">')},c=[];Object.entries(i).forEach(function(e){var t=e[0],i=e[1],o=n.indexOf(t),a=!1;if(-1===o&&B){var l=M(t);-1!==(o=r.indexOf(l))&&(a=!0)}if(-1!==o){for(var d=i[0].highlightColor,u=1;u<i.length;u++)d=s.mixHexColors(d,i[u].highlightColor);c.push({highlight:t,start:o,end:o+t.length,badges:i,color:d,usedLooseMatch:a})}}),c.sort(function(e,n){return e.start-n.start||n.end-e.end});var d=[],u={};c.forEach(function(e,n){for(var r=e.start,t=e.end,i=0,o=d;i<o.length;i++){var a=o[i],s=a.start,l=a.end,c=r<l&&t>l&&r>=s,g=r<s&&t>s&&t<=l;if(r>=s&&t<=l){e.orphaned=!0,u[n]=a.matchIdx;break}c&&(r=l),g&&(t=s)}e.trimmedStart=r,e.trimmedEnd=t,!e.orphaned&&r<t&&d.push({start:r,end:t,matchIdx:n})});var g={};Object.entries(u).forEach(function(e){var n=e[0],r=e[1],t=Number(n);g[r]||(g[r]=[]),g[r].push(t)});var h=function(e,n,r){void 0===n&&(n="");var t=e.startsWith("\n\n"),i=e.endsWith("\n\n"),a=e.split(/(\n{2,})/).map(function(e,a,s){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var l=0===a||1===a&&/^\n{2,}$/.test(s[0]),c=a===s.length-1||a===s.length-2&&/^\n{2,}$/.test(s[s.length-1]);return t&&l||i&&c?e:function(e,n,r){var t,i,a;void 0===n&&(n="");var s=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!s)return e;var l=null!==(t=s[1])&&void 0!==t?t:"",c=null!==(i=s[2])&&void 0!==i?i:"",d=null!==(a=s[3])&&void 0!==a?a:"";return c?l+o(n,r)+c+"</mark>"+d:e}(e,n,r)}).join("");return a.replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")},p=c.map(function(n,r){return e.__assign(e.__assign({},n),{idx:r})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var r,t;return(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)-(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)});p.forEach(function(e){var r,t,i=null!==(r=e.trimmedStart)&&void 0!==r?r:e.start,o=null!==(t=e.trimmedEnd)&&void 0!==t?t:e.end;if(!(i>=o)){var l=n.slice(i,o),d=function(e,n,r,t){if(!r.length)return e;var i=r.map(function(e){return c[e]}).sort(function(e,n){return e.start-n.start}),o="",l=0;return i.forEach(function(r){var i=r.start-n,c=r.end-n,d=s.mixHexColors(t,r.color);o+=e.slice(l,i);var u="",g="";r.badges.forEach(function(e){u+=a(e.id),g="</span>"+g}),o+=u+h(e.slice(i,c),r.badges[0].id,d)+g,l=c}),o+=e.slice(l)}(e.usedLooseMatch||i!==e.start||o!==e.end?l:e.highlight,e.start,g[e.idx]||[],e.color),u=h(d,e.badges[0].id,e.color),p="",f="";e.badges.forEach(function(e){p+=a(e.id),f="</span>"+f});var v=p+u+f;n=n.slice(0,i)+v+n.slice(o)}});var f=new Set(Object.keys(i));return _.forEach(function(e){if(e){var t=T(e);if(t&&!f.has(t)){var i=B?r.indexOf(M(t)):n.indexOf(t);if(-1!==i){var a=n.slice(0,i);if((a.match(/</g)||[]).length===(a.match(/>/g)||[]).length){var s=o("","")+t+"</mark>";n=n.slice(0,i)+s+n.slice(i+t.length)}}}}}),n},[l,x,_,b,B]),O=t.useMemo(function(){return c?T(s.safeStringify(c||"")):""},[c]),I=!!c,z=e.__assign(e.__assign(e.__assign(e.__assign({},u),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),I?{color:"transparent"}:{}),{"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}}),D=e.__assign(e.__assign({},u),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}});return t.useLayoutEffect(function(){if(C.current){var e=function(){var e=Array.from(C.current.querySelectorAll(".deviation-badge"));if(0!==e.length){e.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var n=e.filter(function(e){return"left"===e.dataset.side}),r=e.filter(function(e){return"left"!==e.dataset.side}),t=C.current.getBoundingClientRect(),i=t.bottom-4,o=t.top+4,a=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 r=[],t=[];n.forEach(function(e){if(0===t.length)t.push(e);else{var n=t[t.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,t.push(e)):(r.push(t),t=[e])}}),t.length>0&&r.push(t),r.forEach(function(e){var n=e[e.length-1],r=n.currentTop+n.height;if(r>i){var t=r-i,a=e[0].currentTop-o,s=Math.max(0,Math.min(t,a));e.forEach(function(e){e.currentTop-=s})}}),r.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};a(n),a(r)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),r=new ResizeObserver(function(){requestAnimationFrame(e)});return r.observe(C.current),function(){r.disconnect(),cancelAnimationFrame(n)}}},[q,E,A]),n.jsxs(r.Box,e.__assign({ref:C,sx:{position:"relative",display:"grid"}},{children:[n.jsx(r.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},z),{padding:"3px"})},{children:n.jsx(h.default,e.__assign({components:w,remarkPlugins:[f.default],rehypePlugins:[p.default]},{children:s.safeStringify(q).replace(/\\n/g,"\n")}))})),I&&n.jsx(r.Typography,e.__assign({component:"div",sx:D},{children:n.jsx(h.default,e.__assign({components:w,remarkPlugins:[f.default],rehypePlugins:[p.default]},{children:s.safeStringify(O).replace(/\\n/g,"\n")}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("@mui/material"),t=require("react"),i=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw"),c=require("remark-gfm");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=d(t),g=d(a),h=d(l),p=d(c),f=u.default.memo(function(a){var l=a.content,c=a.overlayContent,d=a.sxStyles,f=a.deviationBadges,v=void 0===f?[]:f,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=t.useRef(null),C=!!c,j=t.useMemo(function(){return v.reduce(function(n,r){var t;return e.__assign(e.__assign({},n),((t={})[r.id]=r,t))},{})},[v]),F=t.useRef({badgeMap:j,highlightBg:_,hideHighlightBg:C,suppressHighlightBg:y});F.current={badgeMap:j,highlightBg:_,hideHighlightBg:C,suppressHighlightBg:y};var S=function(n,r){return u.default.Children.map(n,function(n){var t;if(!u.default.isValidElement(n))return n;var i=(null===(t=n.props)||void 0===t?void 0:t.children)?S(n.props.children,r):n.props.children,o=u.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:i}));return r(o)})},k=t.useMemo(function(){return{mark:function(r){var t,i,o,a,s=r.children,l=e.__rest(r,["children"]),c=F.current,d=c.badgeMap,u=c.highlightBg,g=c.hideHighlightBg,h=c.suppressHighlightBg,p=l["data-badge-id"],f=p?d[p]:null,v=l["data-highlight-color"],x=null!==(a=null!==(i=null!=v?v:null===(t=null==f?void 0:f.style)||void 0===t?void 0:t.highlightBg)&&void 0!==i?i:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m=l.isSuggestedDeviationFix||h;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"}),g?{color:"transparent"}:{})},{children:s}))},span:function(t){var a,s,l,c,d,u,g=t.children,h=e.__rest(t,["children"]),p=F.current.badgeMap,f=h["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},h,{children:g}));var v=p[f];if(!v)return n.jsx("span",e.__assign({},h,{children:g}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return n.jsxs(r.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(r.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===(s=v.style)||void 0===s?void 0:s.badgeText)||i.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:[n.jsxs(r.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(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.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(r.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===(d=v.style)||void 0===d?void 0:d.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"})}))]})),g]}))},table:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:i}))},thead:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"thead"},{children:i}))},tbody:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"tbody"},{children:i}))},tr:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"tr",sx:{borderBotttom:"1px solid #E5E7EB"}},{children:i}))},th:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:i}))},td:function(t){var i=t.children;return n.jsx(r.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:i}))},updated:function(r){var t=r.children;return e.__rest(r,["children"]),n.jsx(n.Fragment,{children:t})},deleted:function(r){var t=r.children;e.__rest(r,["children"]),console.log("nitish: ",t);var i=S(t,function(e){return u.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(r){var t=r.children;e.__rest(r,["children"]);var i=S(t,function(e){return u.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))}}},[]),w=function(e){return e?e.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(e){return e.startsWith("\n")||/\|.*\|/.test(e)&&/\|[-:\s]+\|/.test(e)?e:e.replace(/\n/g," ")}).join(""):""},A=t.useMemo(function(){return v.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[v]),M=function(e){return e.replace(/[\.,;:]/g," ")},T=t.useMemo(function(){var n=w(s.safeStringify(l||"")),r=y?M(n):n,t=(v||[]).map(function(e){var n,r;return{id:null==e?void 0:e.id,highlight:w((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(r=null==e?void 0:e.style)||void 0===r?void 0:r.badgeBg)||_}}).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 o=function(e,n){void 0===e&&(e="");var r=n?' data-highlight-color="'.concat(n,'"'):"";return'<mark data-badge-id="'.concat(e,'"').concat(r,">")},a=function(e){return'<span data-badge-id="'.concat(e,'">')},c=[];Object.entries(i).forEach(function(e){var t=e[0],i=e[1],o=n.indexOf(t),a=!1;if(-1===o&&y){var l=M(t);-1!==(o=r.indexOf(l))&&(a=!0)}if(-1!==o){for(var d=i[0].highlightColor,u=1;u<i.length;u++)d=s.mixHexColors(d,i[u].highlightColor);c.push({highlight:t,start:o,end:o+t.length,badges:i,color:d,usedLooseMatch:a})}}),c.sort(function(e,n){return e.start-n.start||n.end-e.end});var d=[],u={};c.forEach(function(e,n){for(var r=e.start,t=e.end,i=0,o=d;i<o.length;i++){var a=o[i],s=a.start,l=a.end,c=r<l&&t>l&&r>=s,g=r<s&&t>s&&t<=l;if(r>=s&&t<=l){e.orphaned=!0,u[n]=a.matchIdx;break}c&&(r=l),g&&(t=s)}e.trimmedStart=r,e.trimmedEnd=t,!e.orphaned&&r<t&&d.push({start:r,end:t,matchIdx:n})});var g={};Object.entries(u).forEach(function(e){var n=e[0],r=e[1],t=Number(n);g[r]||(g[r]=[]),g[r].push(t)});var h=function(e,n,r){void 0===n&&(n="");var t=e.startsWith("\n\n"),i=e.endsWith("\n\n"),a=e.split(/(\n{2,})/).map(function(e,a,s){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var l=0===a||1===a&&/^\n{2,}$/.test(s[0]),c=a===s.length-1||a===s.length-2&&/^\n{2,}$/.test(s[s.length-1]);return t&&l||i&&c?e:function(e,n,r){var t,i,a;void 0===n&&(n="");var s=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!s)return e;var l=null!==(t=s[1])&&void 0!==t?t:"",c=null!==(i=s[2])&&void 0!==i?i:"",d=null!==(a=s[3])&&void 0!==a?a:"";return c?l+o(n,r)+c+"</mark>"+d:e}(e,n,r)}).join("");return a.replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")},p=c.map(function(n,r){return e.__assign(e.__assign({},n),{idx:r})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var r,t;return(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)-(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)});p.forEach(function(e){var r,t,i=null!==(r=e.trimmedStart)&&void 0!==r?r:e.start,o=null!==(t=e.trimmedEnd)&&void 0!==t?t:e.end;if(!(i>=o)){var l=n.slice(i,o),d=function(e,n,r,t){if(!r.length)return e;var i=r.map(function(e){return c[e]}).sort(function(e,n){return e.start-n.start}),o="",l=0;return i.forEach(function(r){var i=r.start-n,c=r.end-n,d=s.mixHexColors(t,r.color);o+=e.slice(l,i);var u="",g="";r.badges.forEach(function(e){u+=a(e.id),g="</span>"+g}),o+=u+h(e.slice(i,c),r.badges[0].id,d)+g,l=c}),o+=e.slice(l)}(e.usedLooseMatch||i!==e.start||o!==e.end?l:e.highlight,e.start,g[e.idx]||[],e.color),u=h(d,e.badges[0].id,e.color),p="",f="";e.badges.forEach(function(e){p+=a(e.id),f="</span>"+f});var v=p+u+f;n=n.slice(0,i)+v+n.slice(o)}});var f=new Set(Object.keys(i));return m.forEach(function(e){if(e){var t=w(e);if(t&&!f.has(t)){var i=y?r.indexOf(M(t)):n.indexOf(t);if(-1!==i){var a=n.slice(0,i);if((a.match(/</g)||[]).length===(a.match(/>/g)||[]).length){var s=o("","")+t+"</mark>";n=n.slice(0,i)+s+n.slice(i+t.length)}}}}}),n},[l,v,m,_,y]),O=t.useMemo(function(){return c?w(s.safeStringify(c||"")):""},[c]),q=!!c,I=e.__assign(e.__assign(e.__assign(e.__assign({},d),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),q?{color:"transparent"}:{}),{"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}}),z=e.__assign(e.__assign({},d),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}});return t.useLayoutEffect(function(){if(E.current){var e=function(){var e=Array.from(E.current.querySelectorAll(".deviation-badge"));if(0!==e.length){e.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var n=e.filter(function(e){return"left"===e.dataset.side}),r=e.filter(function(e){return"left"!==e.dataset.side}),t=E.current.getBoundingClientRect(),i=t.bottom-4,o=t.top+4,a=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 r=[],t=[];n.forEach(function(e){if(0===t.length)t.push(e);else{var n=t[t.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,t.push(e)):(r.push(t),t=[e])}}),t.length>0&&r.push(t),r.forEach(function(e){var n=e[e.length-1],r=n.currentTop+n.height;if(r>i){var t=r-i,a=e[0].currentTop-o,s=Math.max(0,Math.min(t,a));e.forEach(function(e){e.currentTop-=s})}}),r.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};a(n),a(r)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),r=new ResizeObserver(function(){requestAnimationFrame(e)});return r.observe(E.current),function(){r.disconnect(),cancelAnimationFrame(n)}}},[T,B,A]),n.jsxs(r.Box,e.__assign({ref:E,sx:{position:"relative",display:"grid"}},{children:[n.jsx(r.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},I),{padding:"3px"})},{children:n.jsx(g.default,e.__assign({components:k,remarkPlugins:[p.default],rehypePlugins:[h.default]},{children:s.safeStringify(T).replace(/\\n/g,"\n")}))})),q&&n.jsx(r.Typography,e.__assign({component:"div",sx:z},{children:n.jsx(g.default,e.__assign({components:k,remarkPlugins:[p.default],rehypePlugins:[h.default]},{children:s.safeStringify(O).replace(/\\n/g,"\n")}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=f;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var r=n.containerRef,i=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var o=n.pathRefs,l=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,v=n.visibleFields,s=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,p=n.subSectionLeftRefs,R=n.subSectionRightRefs,x=n.lhsBadgeRefs,y=n.rhsBadgeRefs,A=n.sectionRowRefs,B=n.expandedSections,m=n.expandedSubSections,C=n.connectedSections,S=n.isSideBySide,b=n.activeSideBySideSection,T=n.maintainRelativeOrder,E=n.cognitiveMap,I=n.getSectionCompareStyle,M=n.getSubSectionCompareStyle,D=n.getDeviationStyleByKey,L=n.isArrowVisible,O=n.isAnimatingRef,H=n.isSideBySideRef,_=n.sideBySideCacheRef,P=n.sideBySideLineRef,N=n.activeSideBySideSectionRef,V=n.activeSideBySideRightSectionRef,k=n.connectedLines,w=n.setConnectedLines,G=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,F=n.scrollLock,z=n.scrollSyncLocked,q=n.handleResizeRef,K=n.activeProposed,J=n.existingRule,Q=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,X=n.resolvedComparisonConfig,Z=n.getFieldData,$=t.useState([]),tt=$[0],et=$[1],nt=t.useState(null),rt=nt[0],it=nt[1],ct=t.useState([]),ot=ct[0],lt=ct[1],ut=null!=k?k:ot,at=null!=w?w:lt,dt=t.useState({width:0,height:0}),vt=dt[0],st=dt[1],ht=t.useRef(!1),gt=t.useRef(!1),ft=t.useRef(!1),pt=t.useRef(null),Rt=t.useRef([]),xt=null!=G?G:Rt,yt=t.useCallback(function(){var t,n,o,A,L,H,_,P,N,V,k,w,G,Y,j,F,z,q,K,J,Q,U,W;if(!ht.current&&!O.current){ht.current=!0;try{if(!r.current)return;var X=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===T)return!1;if(T&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!m[r])return!1;return!0},Z=r.current.getBoundingClientRect();st({width:Z.width,height:Z.height});var $=[];if(v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!O.current){for(var tt=0;tt<Math.max(a.length,d.length);tt++){var nt=null===(t=g.current[tt])||void 0===t?void 0:t.current,rt=null===(n=f.current[tt])||void 0===n?void 0:n.current;nt&&(nt.style.height="auto",nt.style.minHeight="0px"),rt&&(rt.style.height="auto",rt.style.minHeight="0px")}T||Object.keys(p.current).forEach(function(t){var e,n;if(X(t)){var r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var ct={};v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();ct[r]=Math.max(o.height,l.height)}});var ot={left:{},right:{}},lt={};if(!O.current)if(T){if(S&&null!==b)if("number"==typeof b){var ut=b,dt=a[ut],vt=null===(L=g.current[ut])||void 0===L?void 0:L.current;vt&&dt&&(dt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),r=null===(e=f.current[n])||void 0===e?void 0:e.current;if(r&&(B["left-".concat(ut)]||B["right-".concat(n)])){var i=Math.max(vt.getBoundingClientRect().height,r.getBoundingClientRect().height);ot.left[ut]=Math.max(ot.left[ut]||0,i),ot.right[n]=Math.max(ot.right[n]||0,i)}})}else{var gt=b.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(gt){nt=null===(H=p.current[gt])||void 0===H?void 0:H.current,rt=null===(_=R.current[gt])||void 0===_?void 0:_.current;if(nt&&rt){ft=Math.max(nt.getBoundingClientRect().height,rt.getBoundingClientRect().height);lt[gt]=Math.max(lt[gt]||0,ft)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(X(t)){var r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);lt[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(tt=0;tt<Math.min(a.length,d.length);tt++){var nt=null===(o=g.current[tt])||void 0===o?void 0:o.current,rt=null===(A=f.current[tt])||void 0===A?void 0:A.current;if(nt&&rt){var ft=Math.max(nt.getBoundingClientRect().height,rt.getBoundingClientRect().height);ot.left[tt]=ft,ot.right[tt]=ft}}}if(v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=ct[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(ot.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries(ot.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),T||Object.keys(lt).forEach(function(t){var e,n,r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;if(r&&i&<[t]){var c=lt[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}})),T)a.forEach(function(t,e){var n;(null===(n=g.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,r,o,l,u,a,v,s,h,g,f=d.findIndex(function(e){return e.selfIndex===t});if(-1!==f){var p=null===(n=x.current[e])||void 0===n?void 0:n.current,R=null===(r=y.current[f])||void 0===r?void 0:r.current;if(p&&R){var A=p.getBoundingClientRect(),B=R.getBoundingClientRect(),m=A.right-Z.left,C=B.left-Z.left,T=A.top+A.height/2-Z.top,E=B.top+B.height/2-Z.top;if(S&&b===e){var M=null!==(l=null===(o=i.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,D=null!==(a=null===(u=c.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,L=M+(null!==(s=null===(v=i.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0),O=D+(null!==(g=null===(h=c.current)||void 0===h?void 0:h.clientHeight)&&void 0!==g?g:1/0),H=A.top+A.height/2,_=B.top+B.height/2,P=function(t,e,n){return Math.max(e,Math.min(n,t))};T=P(H,M,L)-Z.top,E=P(_,D,O)-Z.top}var N=I(e);N&&$.push({id:"line-".concat(e,"-").concat(f),x1:m,y1:T,x2:C,y2:E,style:N,sectionIdx:e,targetRightIdx:f})}}})});else{for(tt=0;tt<Math.min(a.length,d.length);tt++){var pt=null===(P=g.current[tt])||void 0===P?void 0:P.current,Rt=null===(N=f.current[tt])||void 0===N?void 0:N.current;if(pt&&Rt){var yt=pt.getBoundingClientRect(),At=Rt.getBoundingClientRect(),Bt=Math.max(yt.top,At.top)+18-Z.top,mt=(null===(V=d[tt])||void 0===V?void 0:V.id)||"sec-".concat(tt);(Dt=I(tt))&&$.push({id:mt,x1:yt.right-Z.left,y1:Bt,x2:At.left-Z.left,y2:Bt,style:Dt,sectionIdx:tt,hasCognitive:!!((null===(k=a[tt])||void 0===k?void 0:k.cognitiveData)||(null===(w=d[tt])||void 0===w?void 0:w.cognitiveData)||mt&&E[mt]),isSubSection:!1})}}Object.keys(p.current).forEach(function(t){var n,r,i,c,o,l;if(X(t)){var u=null===(n=p.current[t])||void 0===n?void 0:n.current,v=null===(r=R.current[t])||void 0===r?void 0:r.current;if(u&&v){for(var s=t.split("-").map(Number),h=a[s[0]],g=d[s[0]],f=1;f<s.length;f++)(null==h?void 0:h.subsections)&&(h=h.subsections[s[f]]),(null==g?void 0:g.subsections)&&(g=g.subsections[s[f]]);var x=!!h&&((null===(i=h.displayTitle)||void 0===i||i)&&e.hasValue(h.title)),y=!!h&&((null===(c=h.displayContent)||void 0===c||c)&&e.hasValue(h.content)),A=!!g&&((null===(o=g.displayTitle)||void 0===o||o)&&e.hasValue(g.title)),B=!!g&&((null===(l=g.displayContent)||void 0===l||l)&&e.hasValue(g.content));if(x&&y||A&&B){var m=u.getBoundingClientRect(),C=v.getBoundingClientRect(),S=Math.max(m.top,C.top)+16-Z.top,b=M(t);b&&"Not Defined"!==b.label&&$.push({id:"subsec-".concat(t),x1:m.right-Z.left,y1:S,x2:C.left-Z.left,y2:S,style:b,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==h?void 0:h.cognitiveData)&&!(null==g?void 0:g.cognitiveData))})}}}})}if(S&&"string"==typeof b&&b.includes(e.DEVIATION_BADGE_SEPARATOR)){var Ct=b.split(e.DEVIATION_BADGE_SEPARATOR),St=Ct[0],bt=Ct[1],Tt=Ct[2],Et=(Ct[3],"".concat(St).concat(e.DEVIATION_BADGE_SEPARATOR).concat(bt)),It=null===(G=x.current[Et])||void 0===G?void 0:G.current,Mt=null===(Y=y.current[Et])||void 0===Y?void 0:Y.current;if(It&&Mt){var Dt,Lt=It.getBoundingClientRect(),Ot=Mt.getBoundingClientRect(),Ht=Lt.right-Z.left,_t=Ot.left-Z.left,Pt=Lt.top+Lt.height/2-Z.top,Nt=Ot.top+Ot.height/2-Z.top;if(T){var Vt=null!==(F=null===(j=i.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==F?F:0,kt=null!==(q=null===(z=c.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==q?q:0,wt=Vt+(null!==(J=null===(K=i.current)||void 0===K?void 0:K.clientHeight)&&void 0!==J?J:1/0),Gt=kt+(null!==(U=null===(Q=c.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==U?U:1/0),Yt=function(t,e,n){return Math.max(e,Math.min(n,t))};Pt=Yt(Lt.top+Lt.height/2,Vt,wt)-Z.top,Nt=Yt(Ot.top+Ot.height/2,kt,Gt)-Z.top}(Dt=null!==(W=D(St,bt))&&void 0!==W?W:M(Tt))&&$.push({id:"line-subsec-".concat(Et),x1:Ht,y1:Pt,x2:_t,y2:Nt,style:Dt,sectionIdx:Number(Tt.split("-")[0]),isSubSection:!0,subSectionKeyPath:b})}}if(et($),l.current&&u.current){var jt=l.current.getBoundingClientRect(),Ft=u.current.getBoundingClientRect(),zt=(jt.top+jt.height/2-Z.top+Ft.top+Ft.height/2-Z.top)/2;it({x1:jt.right-Z.left,x2:Ft.left-Z.left,y:zt})}else it(null);if(C.size>0){var qt=[],Kt=i.current,Jt=c.current;if(Kt&&Jt){var Qt=[],Ut=Kt.getBoundingClientRect().top,Wt=Jt.getBoundingClientRect().top,Xt=Ut+Kt.clientHeight,Zt=Wt+Jt.clientHeight,$t=Kt.scrollTop,te=Jt.scrollTop,ee=Z.top,ne=function(t,e,n){return Math.max(e,Math.min(n,t))};C.forEach(function(t){var n,r,i,c,o,l;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var u=t.split(e.DEVIATION_BADGE_SEPARATOR),v=u[0],s=u[1],h=u[2],g=(u[3],"".concat(v).concat(e.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=x.current[g])||void 0===n?void 0:n.current,p=null===(r=y.current[g])||void 0===r?void 0:r.current;if(!f||!p)return;var R=f.getBoundingClientRect(),A=p.getBoundingClientRect(),B=null!==(i=D(v,s))&&void 0!==i?i:M(h),m=(j=R.right-Z.left)+.5*((F=A.left-Z.left-0)-j),C=R.top+R.height/2,S=A.top+A.height/2,b=C-Ut+$t,E=S-Wt+te,L="conn-subsec-".concat(g);Qt.push({lhsScrollY:b,rhsScrollY:E,x1:j,x2:F,containerTop:ee,leftIdx:t,rhsArrayIdx:t,styleColor:(null==B?void 0:B.badgeBorder)||"#6366F1",styleId:L});var O=ne(C,Ut,Xt),H=ne(S,Wt,Zt),_=O-ee,P=H-ee,N=S>=Wt-4&&S<=Zt+4,V="";V=(z=C>=Ut-4&&C<=Xt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(P):!z&&N?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P),qt.push({id:L,pathD:V,style:B,leftIdx:t,rhsArrayIdx:t})}else if(T){var k=t,w=a[k];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(t){var n,r,i=d.findIndex(function(e){return e.selfIndex===t});if(-1!==i){var c=null===(n=x.current[k])||void 0===n?void 0:n.current,o=null===(r=y.current[i])||void 0===r?void 0:r.current;if(c&&o){var l=c.getBoundingClientRect(),u=o.getBoundingClientRect(),a=I(k),v=l.right-Z.left,s=u.left-Z.left-0,h=v+.5*(s-v),g=l.top+l.height/2,f=u.top+u.height/2,p=g-Ut+$t,R=f-Wt+te,A="conn-".concat(k,"-").concat(i);Qt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:s,containerTop:ee,leftIdx:k,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:A});var B=ne(g,Ut,Xt),m=ne(f,Wt,Zt),C=B-ee,S=m-ee,b=g>=Ut-4&&g<=Xt+4,T=f>=Wt-4&&f<=Zt+4,E="";E=b&&T?e.getBentArrowPath(v,C,s,S):b&&!T?"M ".concat(v,",").concat(C," L ").concat(h,",").concat(C," L ").concat(h,",").concat(S):!b&&T?"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S),qt.push({id:A,pathD:E,style:a,leftIdx:k,rhsArrayIdx:i})}}})}else{var G=t,Y=G;f=null===(c=x.current[G])||void 0===c?void 0:c.current,p=null===(o=y.current[Y])||void 0===o?void 0:o.current;if(!f||!p)return;var j,F;R=f.getBoundingClientRect(),A=p.getBoundingClientRect(),B=I(G),m=(j=R.right-Z.left)+.5*((F=A.left-Z.left-0)-j),C=R.top+R.height/2,S=A.top+A.height/2,b=C-Ut+$t,E=S-Wt+te,L="conn-".concat(G,"-").concat(Y);Qt.push({lhsScrollY:b,rhsScrollY:E,x1:j,x2:F,containerTop:ee,leftIdx:G,rhsArrayIdx:Y,styleColor:(null==B?void 0:B.badgeBorder)||"#6366F1",styleId:L});var z;O=ne(C,Ut,Xt),H=ne(S,Wt,Zt),_=O-ee,P=H-ee,N=S>=Wt-4&&S<=Zt+4,V="";V=(z=C>=Ut-4&&C<=Xt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(P):!z&&N?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P),qt.push({id:L,pathD:V,style:B,leftIdx:G,rhsArrayIdx:Y})}}),xt.current=Qt}at(qt)}else at([]),xt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{ht.current=!1}}},[v,a,d,E,X,Z,I,D,T,S,b,C,B,m]),At=t.useCallback(function(){var t,n,l,u,a,d,v,s,h,g,f,p,R,x,y=xt.current;if(y.length&&!O.current){var A=null!==(n=null===(t=i.current)||void 0===t?void 0:t.scrollTop)&&void 0!==n?n:0,B=null!==(u=null===(l=c.current)||void 0===l?void 0:l.scrollTop)&&void 0!==u?u:0,m=null!==(d=null===(a=i.current)||void 0===a?void 0:a.clientHeight)&&void 0!==d?d:1/0,C=null!==(s=null===(v=c.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0,S=null!==(g=null===(h=i.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,b=null!==(p=null===(f=c.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,T=S+m,E=b+C,I=null!==(x=null===(R=r.current)||void 0===R?void 0:R.getBoundingClientRect().top)&&void 0!==x?x:0,M=function(t,e,n){return Math.max(e,Math.min(n,t))};y.forEach(function(t){var n=t.lhsScrollY-A+S,r=t.rhsScrollY-B+b,i=o.current[t.styleId+"-stroke"],c=o.current[t.styleId+"-bg"];if(i||c){var l,u=M(n,S,T),a=M(r,b,E),d=u-I,v=a-I,s=n>=S-4&&n<=T+4,h=r>=b-4&&r<=E+4,g=t.x1+.5*(t.x2-t.x1);l=s&&h?e.getBentArrowPath(t.x1,d,t.x2,v):s&&!h?"M ".concat(t.x1,",").concat(d," L ").concat(g,",").concat(d," L ").concat(g,",").concat(v):!s&&h?"M ".concat(g,",").concat(d," L ").concat(g,",").concat(v," L ").concat(t.x2,",").concat(v):"M ".concat(g,",").concat(d," L ").concat(g,",").concat(v),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),c&&(c.setAttribute("visibility","visible"),c.setAttribute("d",l))}})}},[]),Bt=t.useCallback(function(){xt.current.length>0&&!O.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),mt=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(!ft.current&&!F.current){if(T&&z&&(H.current||C.size>0)){var o=t.currentTarget,l=i.current,u=c.current,a=o===l?u:o===u?l:null;if(o&&a){var d=function(){var t,n,r,i,c,o,l,u,a,d,v,s=N.current,h=V.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(e.DEVIATION_BADGE_SEPARATOR)){var B=s.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(B[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(B[1]);return{leftAnchor:(null===(t=x.current[m])||void 0===t?void 0:t.current)||(null===(n=p.current[B[2]])||void 0===n?void 0:n.current)||(null===(r=g.current[Number(B[2])])||void 0===r?void 0:r.current)||null,rightAnchor:(null===(i=y.current[m])||void 0===i?void 0:i.current)||(null===(c=R.current[B[3]])||void 0===c?void 0:c.current)||(null===(o=f.current[Number(B[3])])||void 0===o?void 0:o.current)||null}}var C=Number(s),S=null!==h?Number(h):C;return{leftAnchor:(null===(l=x.current[C])||void 0===l?void 0:l.current)||(null===(u=A.current[C])||void 0===u?void 0:u.current)||(null===(a=g.current[C])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(v=f.current[S])||void 0===v?void 0:v.current)||null}}(),v=d.leftAnchor,s=d.rightAnchor,h=o===l?v:s,B=o===l?s:v,m=null;if(h&&B){var S=h.getBoundingClientRect(),b=B.getBoundingClientRect(),E=a.getBoundingClientRect(),I=S.top+S.height/2;m=b.top-E.top+a.scrollTop+b.height/2-(I-E.top)}else{var M=Math.max(0,o.scrollHeight-o.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?o.scrollTop/M*D:o.scrollTop}var L=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,L)),Math.abs(a.scrollTop-m)>1&&(ft.current=!0,a.scrollTop=m,requestAnimationFrame(function(){ft.current=!1}))}}T||Bt(),gt.current||(gt.current=!0,requestAnimationFrame(function(){var t,n,o,l,u,a,d;if(H.current){var v=i.current,s=c.current;if(v&&s&&P.current){if(!_.current){var h=N.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=x.current[p])||void 0===t?void 0:t.current}else g=null===(n=x.current[h])||void 0===n?void 0:n.current;if(g){var R=g.getBoundingClientRect();_.current={badgeScreenY:R.top+R.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(l=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0}}}if(_.current){var y=_.current,A=v.scrollTop-y.initialScrollTop,B=y.badgeScreenY-A,m=((u=B,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),C=B>=y.leftTop-4&&B<=y.leftBottom+4;P.current.setAttribute("y1",m),P.current.setAttribute("y2",m),P.current.setAttribute("visibility",C?"visible":"hidden")}}}xt.current.length>0&&At(),gt.current=!1}))}},[At,T,z,C,Bt]);return t.useEffect(function(){Y.current=yt},[yt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return q.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[K,J,Q,v,B,m,a,d,X,Bt,S,b,L,C]),{lines:tt,setLines:et,overallConnector:rt,setOverallConnector:it,connectedLines:ut,setConnectedLines:at,svgDimensions:vt,cachedConnectedPositions:xt,calculateLines:yt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:mt}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var r=n.containerRef,i=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var o=n.pathRefs,l=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,v=n.visibleFields,s=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,p=n.subSectionLeftRefs,R=n.subSectionRightRefs,y=n.lhsBadgeRefs,x=n.rhsBadgeRefs,A=n.sectionRowRefs,B=n.expandedSections,m=n.expandedSubSections,C=n.connectedSections,S=n.isSideBySide,b=n.activeSideBySideSection,T=n.maintainRelativeOrder,I=n.cognitiveMap,E=n.getSectionCompareStyle,M=n.getSubSectionCompareStyle,D=n.getDeviationStyleByKey,L=n.isArrowVisible,O=n.isAnimatingRef,H=n.isSideBySideRef,_=n.sideBySideCacheRef,P=n.sideBySideLineRef,N=n.activeSideBySideSectionRef,V=n.activeSideBySideRightSectionRef,k=n.connectedLines,w=n.setConnectedLines,G=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,F=n.scrollLock,z=n.scrollSyncLocked,q=n.handleResizeRef,K=n.activeProposed,J=n.existingRule,Q=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,X=n.resolvedComparisonConfig,Z=n.getFieldData,$=t.useState([]),tt=$[0],et=$[1],nt=t.useState(null),rt=nt[0],it=nt[1],ct=t.useState([]),ot=ct[0],lt=ct[1],ut=null!=k?k:ot,at=null!=w?w:lt,dt=t.useState({width:0,height:0}),vt=dt[0],st=dt[1],ht=t.useRef(!1),gt=t.useRef(!1),ft=t.useRef(!1),pt=t.useRef(null),Rt=t.useRef([]),yt=null!=G?G:Rt,xt=t.useCallback(function(){var t,n,o,A,L,H,_,P,N,V,k,w,G,Y,j,F,z,q,K,J,Q,U,W;if(!ht.current&&!O.current){ht.current=!0;try{if(!r.current)return;var X=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===T)return!1;if(T&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!m[r])return!1;return!0},Z=r.current.getBoundingClientRect();st({width:Z.width,height:Z.height});var $=[];if(v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!O.current){for(var tt=0;tt<Math.max(a.length,d.length);tt++){var nt=null===(t=g.current[tt])||void 0===t?void 0:t.current,rt=null===(n=f.current[tt])||void 0===n?void 0:n.current;nt&&(nt.style.height="auto",nt.style.minHeight="0px"),rt&&(rt.style.height="auto",rt.style.minHeight="0px")}T||Object.keys(p.current).forEach(function(t){var e,n;if(X(t)){var r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var ct={};v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();ct[r]=Math.max(o.height,l.height)}});var ot={left:{},right:{}},lt={};if(!O.current)if(T){if(S&&null!==b)if("number"==typeof b){var ut=b,dt=a[ut],vt=null===(L=g.current[ut])||void 0===L?void 0:L.current;vt&&dt&&(dt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),r=null===(e=f.current[n])||void 0===e?void 0:e.current;if(r&&(B["left-".concat(ut)]||B["right-".concat(n)])){var i=Math.max(vt.getBoundingClientRect().height,r.getBoundingClientRect().height);ot.left[ut]=Math.max(ot.left[ut]||0,i),ot.right[n]=Math.max(ot.right[n]||0,i)}})}else{var gt=b.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(gt){nt=null===(H=p.current[gt])||void 0===H?void 0:H.current,rt=null===(_=R.current[gt])||void 0===_?void 0:_.current;if(nt&&rt){ft=Math.max(nt.getBoundingClientRect().height,rt.getBoundingClientRect().height);lt[gt]=Math.max(lt[gt]||0,ft)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(X(t)){var r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);lt[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(tt=0;tt<Math.min(a.length,d.length);tt++){var nt=null===(o=g.current[tt])||void 0===o?void 0:o.current,rt=null===(A=f.current[tt])||void 0===A?void 0:A.current;if(nt&&rt){var ft=Math.max(nt.getBoundingClientRect().height,rt.getBoundingClientRect().height);ot.left[tt]=ft,ot.right[tt]=ft}}}if(v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=ct[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(ot.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries(ot.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),T||Object.keys(lt).forEach(function(t){var e,n,r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;if(r&&i&<[t]){var c=lt[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}})),T)a.forEach(function(t,e){var n;(null===(n=g.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,r,o,l,u,a,v,s,h,g,f=d.findIndex(function(e){return e.selfIndex===t});if(-1!==f){var p=null===(n=y.current[e])||void 0===n?void 0:n.current,R=null===(r=x.current[f])||void 0===r?void 0:r.current;if(p&&R){var A=p.getBoundingClientRect(),B=R.getBoundingClientRect(),m=A.right-Z.left,C=B.left-Z.left,T=A.top+A.height/2-Z.top,I=B.top+B.height/2-Z.top;if(S&&b===e){var M=null!==(l=null===(o=i.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,D=null!==(a=null===(u=c.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,L=M+(null!==(s=null===(v=i.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0),O=D+(null!==(g=null===(h=c.current)||void 0===h?void 0:h.clientHeight)&&void 0!==g?g:1/0),H=A.top+A.height/2,_=B.top+B.height/2,P=function(t,e,n){return Math.max(e,Math.min(n,t))};T=P(H,M,L)-Z.top,I=P(_,D,O)-Z.top}var N=E(e);N&&$.push({id:"line-".concat(e,"-").concat(f),x1:m,y1:T,x2:C,y2:I,style:N,sectionIdx:e,targetRightIdx:f})}}})});else{for(tt=0;tt<Math.min(a.length,d.length);tt++){var pt=null===(P=g.current[tt])||void 0===P?void 0:P.current,Rt=null===(N=f.current[tt])||void 0===N?void 0:N.current;if(pt&&Rt){var xt=pt.getBoundingClientRect(),At=Rt.getBoundingClientRect(),Bt=Math.max(xt.top,At.top)+18-Z.top,mt=(null===(V=d[tt])||void 0===V?void 0:V.id)||"sec-".concat(tt);(Dt=E(tt))&&$.push({id:mt,x1:xt.right-Z.left,y1:Bt,x2:At.left-Z.left,y2:Bt,style:Dt,sectionIdx:tt,hasCognitive:!!((null===(k=a[tt])||void 0===k?void 0:k.cognitiveData)||(null===(w=d[tt])||void 0===w?void 0:w.cognitiveData)||mt&&I[mt]),isSubSection:!1})}}Object.keys(p.current).forEach(function(t){var n,r,i,c,o,l;if(X(t)){var u=null===(n=p.current[t])||void 0===n?void 0:n.current,v=null===(r=R.current[t])||void 0===r?void 0:r.current;if(u&&v){for(var s=t.split("-").map(Number),h=a[s[0]],g=d[s[0]],f=1;f<s.length;f++)(null==h?void 0:h.subsections)&&(h=h.subsections[s[f]]),(null==g?void 0:g.subsections)&&(g=g.subsections[s[f]]);var y=!!h&&((null===(i=h.displayTitle)||void 0===i||i)&&e.hasValue(h.title)),x=!!h&&((null===(c=h.displayContent)||void 0===c||c)&&e.hasValue(h.content)),A=!!g&&((null===(o=g.displayTitle)||void 0===o||o)&&e.hasValue(g.title)),B=!!g&&((null===(l=g.displayContent)||void 0===l||l)&&e.hasValue(g.content));if(y&&x||A&&B){var m=u.getBoundingClientRect(),C=v.getBoundingClientRect(),S=Math.max(m.top,C.top)+16-Z.top,b=M(t);b&&"Not Defined"!==b.label&&$.push({id:"subsec-".concat(t),x1:m.right-Z.left,y1:S,x2:C.left-Z.left,y2:S,style:b,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==h?void 0:h.cognitiveData)&&!(null==g?void 0:g.cognitiveData))})}}}})}if(S&&"string"==typeof b&&b.includes(e.DEVIATION_BADGE_SEPARATOR)){var Ct=b.split(e.DEVIATION_BADGE_SEPARATOR),St=Ct[0],bt=Ct[1],Tt=Ct[2],It=(Ct[3],"".concat(St).concat(e.DEVIATION_BADGE_SEPARATOR).concat(bt)),Et=null===(G=y.current[It])||void 0===G?void 0:G.current,Mt=null===(Y=x.current[It])||void 0===Y?void 0:Y.current;if(Et&&Mt){var Dt,Lt=Et.getBoundingClientRect(),Ot=Mt.getBoundingClientRect(),Ht=Lt.right-Z.left,_t=Ot.left-Z.left,Pt=Lt.top+Lt.height/2-Z.top,Nt=Ot.top+Ot.height/2-Z.top;if(T){var Vt=null!==(F=null===(j=i.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==F?F:0,kt=null!==(q=null===(z=c.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==q?q:0,wt=Vt+(null!==(J=null===(K=i.current)||void 0===K?void 0:K.clientHeight)&&void 0!==J?J:1/0),Gt=kt+(null!==(U=null===(Q=c.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==U?U:1/0),Yt=function(t,e,n){return Math.max(e,Math.min(n,t))};Pt=Yt(Lt.top+Lt.height/2,Vt,wt)-Z.top,Nt=Yt(Ot.top+Ot.height/2,kt,Gt)-Z.top}(Dt=null!==(W=D(St,bt))&&void 0!==W?W:M(Tt))&&$.push({id:"line-subsec-".concat(It),x1:Ht,y1:Pt,x2:_t,y2:Nt,style:Dt,sectionIdx:Number(Tt.split("-")[0]),isSubSection:!0,subSectionKeyPath:b})}}if(et($),l.current&&u.current){var jt=l.current.getBoundingClientRect(),Ft=u.current.getBoundingClientRect(),zt=(jt.top+jt.height/2-Z.top+Ft.top+Ft.height/2-Z.top)/2;it({x1:jt.right-Z.left,x2:Ft.left-Z.left,y:zt})}else it(null);if(C.size>0){var qt=[],Kt=i.current,Jt=c.current;if(Kt&&Jt){var Qt=[],Ut=Kt.getBoundingClientRect().top,Wt=Jt.getBoundingClientRect().top,Xt=Ut+Kt.clientHeight,Zt=Wt+Jt.clientHeight,$t=Kt.scrollTop,te=Jt.scrollTop,ee=Z.top,ne=function(t,e,n){return Math.max(e,Math.min(n,t))};C.forEach(function(t){var n,r,i,c,o,l;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var u=t.split(e.DEVIATION_BADGE_SEPARATOR),v=u[0],s=u[1],h=u[2],g=(u[3],"".concat(v).concat(e.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=y.current[g])||void 0===n?void 0:n.current,p=null===(r=x.current[g])||void 0===r?void 0:r.current;if(!f||!p)return;var R=f.getBoundingClientRect(),A=p.getBoundingClientRect(),B=null!==(i=D(v,s))&&void 0!==i?i:M(h),m=(j=R.right-Z.left)+.5*((F=A.left-Z.left-0)-j),C=R.top+R.height/2,S=A.top+A.height/2,b=C-Ut+$t,I=S-Wt+te,L="conn-subsec-".concat(g);Qt.push({lhsScrollY:b,rhsScrollY:I,x1:j,x2:F,containerTop:ee,leftIdx:t,rhsArrayIdx:t,styleColor:(null==B?void 0:B.badgeBorder)||"#6366F1",styleId:L});var O=ne(C,Ut,Xt),H=ne(S,Wt,Zt),_=O-ee,P=H-ee,N=S>=Wt-4&&S<=Zt+4,V="";V=(z=C>=Ut-4&&C<=Xt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(P):!z&&N?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P),qt.push({id:L,pathD:V,style:B,leftIdx:t,rhsArrayIdx:t,x1:j,x2:F,y1:_,y2:P})}else if(T){var k=t,w=a[k];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(t){var n,r,i=d.findIndex(function(e){return e.selfIndex===t});if(-1!==i){var c=null===(n=y.current[k])||void 0===n?void 0:n.current,o=null===(r=x.current[i])||void 0===r?void 0:r.current;if(c&&o){var l=c.getBoundingClientRect(),u=o.getBoundingClientRect(),a=E(k),v=l.right-Z.left,s=u.left-Z.left-0,h=v+.5*(s-v),g=l.top+l.height/2,f=u.top+u.height/2,p=g-Ut+$t,R=f-Wt+te,A="conn-".concat(k,"-").concat(i);Qt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:s,containerTop:ee,leftIdx:k,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:A});var B=ne(g,Ut,Xt),m=ne(f,Wt,Zt),C=B-ee,S=m-ee,b=g>=Ut-4&&g<=Xt+4,T=f>=Wt-4&&f<=Zt+4,I="";I=b&&T?e.getBentArrowPath(v,C,s,S):b&&!T?"M ".concat(v,",").concat(C," L ").concat(h,",").concat(C," L ").concat(h,",").concat(S):!b&&T?"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S),qt.push({id:A,pathD:I,style:a,leftIdx:k,rhsArrayIdx:i,x1:v,x2:s,y1:C,y2:S})}}})}else{var G=t,Y=G;f=null===(c=y.current[G])||void 0===c?void 0:c.current,p=null===(o=x.current[Y])||void 0===o?void 0:o.current;if(!f||!p)return;var j,F;R=f.getBoundingClientRect(),A=p.getBoundingClientRect(),B=E(G),m=(j=R.right-Z.left)+.5*((F=A.left-Z.left-0)-j),C=R.top+R.height/2,S=A.top+A.height/2,b=C-Ut+$t,I=S-Wt+te,L="conn-".concat(G,"-").concat(Y);Qt.push({lhsScrollY:b,rhsScrollY:I,x1:j,x2:F,containerTop:ee,leftIdx:G,rhsArrayIdx:Y,styleColor:(null==B?void 0:B.badgeBorder)||"#6366F1",styleId:L});var z;O=ne(C,Ut,Xt),H=ne(S,Wt,Zt),_=O-ee,P=H-ee,N=S>=Wt-4&&S<=Zt+4,V="";V=(z=C>=Ut-4&&C<=Xt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(P):!z&&N?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P),qt.push({id:L,pathD:V,style:B,leftIdx:G,rhsArrayIdx:Y,x1:j,x2:F,y1:_,y2:P})}}),yt.current=Qt}at(qt)}else at([]),yt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{ht.current=!1}}},[v,a,d,I,X,Z,E,D,T,S,b,C,B,m]),At=t.useCallback(function(){var t,n,l,u,a,d,v,s,h,g,f,p,R,y,x=yt.current;if(x.length&&!O.current){var A=null!==(n=null===(t=i.current)||void 0===t?void 0:t.scrollTop)&&void 0!==n?n:0,B=null!==(u=null===(l=c.current)||void 0===l?void 0:l.scrollTop)&&void 0!==u?u:0,m=null!==(d=null===(a=i.current)||void 0===a?void 0:a.clientHeight)&&void 0!==d?d:1/0,C=null!==(s=null===(v=c.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0,S=null!==(g=null===(h=i.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,b=null!==(p=null===(f=c.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,T=S+m,I=b+C,E=null!==(y=null===(R=r.current)||void 0===R?void 0:R.getBoundingClientRect().top)&&void 0!==y?y:0,M=function(t,e,n){return Math.max(e,Math.min(n,t))};x.forEach(function(t){var n=t.lhsScrollY-A+S,r=t.rhsScrollY-B+b,i=o.current[t.styleId+"-stroke"],c=o.current[t.styleId+"-bg"],l=o.current[t.styleId+"-btn"];if(i||c){var u,a=M(n,S,T),d=M(r,b,I),v=a-E,s=d-E,h=n>=S-4&&n<=T+4,g=r>=b-4&&r<=I+4,f=t.x1+.5*(t.x2-t.x1);u=h&&g?e.getBentArrowPath(t.x1,v,t.x2,s):h&&!g?"M ".concat(t.x1,",").concat(v," L ").concat(f,",").concat(v," L ").concat(f,",").concat(s):!h&&g?"M ".concat(f,",").concat(v," L ").concat(f,",").concat(s," L ").concat(t.x2,",").concat(s):"M ".concat(f,",").concat(v," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",u)),c&&(c.setAttribute("visibility","visible"),c.setAttribute("d",u)),l&&(h?(l.setAttribute("visibility","visible"),l.setAttribute("y",String(v-12))):l.setAttribute("visibility","hidden"))}})}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!O.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),mt=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(!ft.current&&!F.current){if(T&&z&&(H.current||C.size>0)){var o=t.currentTarget,l=i.current,u=c.current,a=o===l?u:o===u?l:null;if(o&&a){var d=function(){var t,n,r,i,c,o,l,u,a,d,v,s=N.current,h=V.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(e.DEVIATION_BADGE_SEPARATOR)){var B=s.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(B[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(B[1]);return{leftAnchor:(null===(t=y.current[m])||void 0===t?void 0:t.current)||(null===(n=p.current[B[2]])||void 0===n?void 0:n.current)||(null===(r=g.current[Number(B[2])])||void 0===r?void 0:r.current)||null,rightAnchor:(null===(i=x.current[m])||void 0===i?void 0:i.current)||(null===(c=R.current[B[3]])||void 0===c?void 0:c.current)||(null===(o=f.current[Number(B[3])])||void 0===o?void 0:o.current)||null}}var C=Number(s),S=null!==h?Number(h):C;return{leftAnchor:(null===(l=y.current[C])||void 0===l?void 0:l.current)||(null===(u=A.current[C])||void 0===u?void 0:u.current)||(null===(a=g.current[C])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=x.current[S])||void 0===d?void 0:d.current)||(null===(v=f.current[S])||void 0===v?void 0:v.current)||null}}(),v=d.leftAnchor,s=d.rightAnchor,h=o===l?v:s,B=o===l?s:v,m=null;if(h&&B){var S=h.getBoundingClientRect(),b=B.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=b.top-I.top+a.scrollTop+b.height/2-(E-I.top)}else{var M=Math.max(0,o.scrollHeight-o.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?o.scrollTop/M*D:o.scrollTop}var L=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,L)),Math.abs(a.scrollTop-m)>1&&(ft.current=!0,a.scrollTop=m,requestAnimationFrame(function(){ft.current=!1}))}}T||Bt(),gt.current||(gt.current=!0,requestAnimationFrame(function(){var t,n,o,l,u,a,d;if(H.current){var v=i.current,s=c.current;if(v&&s&&P.current){if(!_.current){var h=N.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=y.current[p])||void 0===t?void 0:t.current}else g=null===(n=y.current[h])||void 0===n?void 0:n.current;if(g){var R=g.getBoundingClientRect();_.current={badgeScreenY:R.top+R.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(l=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0}}}if(_.current){var x=_.current,A=v.scrollTop-x.initialScrollTop,B=x.badgeScreenY-A,m=((u=B,a=x.leftTop,d=x.leftBottom,Math.max(a,Math.min(d,u)))-x.cTop).toString(),C=B>=x.leftTop-4&&B<=x.leftBottom+4;P.current.setAttribute("y1",m),P.current.setAttribute("y2",m),P.current.setAttribute("visibility",C?"visible":"hidden")}}}yt.current.length>0&&At(),gt.current=!1}))}},[At,T,z,C,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return q.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[K,J,Q,v,B,m,a,d,X,Bt,S,b,L,C]),{lines:tt,setLines:et,overallConnector:rt,setOverallConnector:it,connectedLines:ut,setConnectedLines:at,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:mt}};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as o,jsxs as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import i from"react";import{Box as t}from"@mui/material";import{EllipsisVertical as r}from"lucide-react";import l from"./SectionAccordion.js";import a from"./ThreeDotsLoader.js";import{extractDeviationScore as d}from"../CognitiveComparehelpers.js";import{useCompareContext as c}from"../CompareContext.js";var s=i.memo(function(i){var s,p,u,v=i.section,f=i.idx,g=c(),m=g.maintainRelativeOrder,x=g.existingSections;g.proposedSections;var h=g.connectedSections,S=g.expandedSections,b=g.displayConfig,R=g.treeData;g.deviationNumberRegistry;var y=g.getSectionCompareStyle;g.getBadgeRef;var w=g.getSectionRowRef,B=g.sectionLeftRefs,C=g.lhsBadgeRefs,I=g.openMoreFunctionsPopup,N=g.handleOpenSummaryPopup,k=g.handleCloseSummaryPopup,P=g.toggleSection;g.showDeviationBadges,g.renderSubSectionAccordion,g.isProposingFix,g.proposingFixNodeId,g.isRedlineFlow,g.isSideBySide,g.activeSideBySideSection,g.scrollSyncLocked,g.toggleScrollSyncLocked,g.summaryPopupAnchorEl,g.deviationNodeIdToView,g.deviationTargetParentId;var D=g.showDeviationNavigation;g.showOpenNodeRef,g.resolvedMarkdownStyles;var T=g.unifiedNumbering,A=!v.title&&!v.content;if(m&&A)return null;var L=v,j=y(f,"left"),z=m?!(null===(s=L.refIndexes)||void 0===s?void 0:s.length)||L.selfIndex<0:!x[f],F=h.has(f);null===(p=C.current[f])||void 0===p||p.current;var O=d(L.evaluationResult,null==j?void 0:j.deviationLabel),W=T.leftNums.get(L.id);return o(t,e({ref:w(f),sx:{mb:1,width:"100%"}},{children:o(t,e({ref:B.current[f],sx:e({width:"100%",display:"flex",flexDirection:"column",minWidth:0},F&&{borderRadius:"6px",outline:"2px solid ".concat((null==j?void 0:j.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n(t,e({sx:{position:"relative",width:"100%"}},{children:[o(l,{section:v,idx:f,columnKey:"left",colRef:w("left-accordion-".concat(f)),mb:0,parentNodeId:(null===(u=null==R?void 0:R.input_index_map)||void 0===u?void 0:u[0])||"",isExpanded:m?!!S["left-".concat(f)]:!!S[String(f)],onToggle:function(){k(),P(f,"left")},navigation:v.id?D[v.id]:null}),m&&j&&n(t,e({ref:C.current[f],onClick:function(e){var o,n,i,t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=L.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=L.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;N(e,String(f),z,t)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:j.badgeBg,color:j.badgeText,border:"1px solid ".concat(j.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n(t,e({component:"span",onClick:function(e){var o,n,i;e.stopPropagation();var t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=L.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=L.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;N(e,String(f),z,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:z?"default":"pointer",borderRight:"1px solid ".concat(j.badgeBorder),"&:hover":z?{}:{bgColor:"".concat(j.badgeBorder,"22")}}},{children:[null!=W&&o(t,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(j.badgeBorder)}},{children:W})),o(t,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!b.isLoading||null!=L.evaluationResult&&void 0!==L.evaluationResult?"N/A"===O||"NA"===O?"N/A":0==O||null==O?"Same":"".concat(O):o(a,{color:j.badgeText})}))]})),o(t,e({component:"span",onClick:function(e){e.stopPropagation();var o=m?x.find(function(e){var o;return null===(o=L.refIndexes)||void 0===o?void 0:o.includes(e.selfIndex)})||{title:"",content:""}:x[f]||{title:"",content:""};I(e,v,z,o,f,j)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(j.badgeBorder,"22")}}},{children:o(r,{size:11,color:j.badgeText})}))]}))]}))}))}),"left-row-".concat(f))});export{s as default};
|
|
2
2
|
//# sourceMappingURL=LHSSectionRow.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as o}from"tslib";import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Tooltip as i,Box as t}from"@mui/material";var n=function(n){var l=n.locked,c=n.onToggle,s=n.color,d=void 0===s?"#3730A3":s,a=n.borderColor,h=void 0===a?"#C7D2FE":a,u=n.size,p=void 0===u?12:u,k=l?function(i){var t=i.size,n=i.color;return r("svg",o({xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock"},{children:[e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}))}:function(i){var t=i.size,n=i.color;return r("svg",o({xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"1
|
|
1
|
+
import{__assign as o}from"tslib";import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Tooltip as i,Box as t}from"@mui/material";var n=function(n){var l=n.locked,c=n.onToggle,s=n.color,d=void 0===s?"#3730A3":s,a=n.borderColor,h=void 0===a?"#C7D2FE":a,u=n.size,p=void 0===u?12:u,k=l?function(i){var t=i.size,n=i.color;return r("svg",o({xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-icon lucide-lock"},{children:[e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}))}:function(i){var t=i.size,n=i.color;return r("svg",o({xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-lock-open-icon lucide-lock-open"},{children:[e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}))};return e(i,o({title:l?"Unlock scroll":"Lock scroll",placement:"top"},{children:e(t,o({component:"span",onClick:c,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:.5,borderLeft:"1px solid ".concat(h),cursor:"pointer"}},{children:e(k,{size:p,color:d})}))}))};export{n as default};
|
|
2
2
|
//# sourceMappingURL=ScrollLockToggle.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{ChevronDown as n}from"lucide-react";import{ButtonCognitiveIcon as o}from"../../../assests/svg/ButtonCognitiveIcon.js";import{getBentArrowPath as l,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as r}from"../CognitiveCompareConstants.js";import a from"./ThreeDotsLoader.js";import d from"./connectedLines.js";import{Box as c}from"@mui/material";function u(u){var g=u.svgContainerRef,p=u.svgDimensions,v=u.isResizing,h=u.overallConnector,y=u.rootDeviationStyle,f=u.lines,m=u.isSideBySide,x=u.activeSideBySideSection,b=u.isArrowVisible,S=u.maintainRelativeOrder,C=u.proposedSections,I=u.existingSections,w=u.cognitivePopup,B=u.activeBadgeId,P=u.closeCognitivePopup,R=u.setActiveBadgeId,j=u.openCognitivePopupFromState,D=u.buildSectionPopupState,k=u.connectedLines,K=u.pathRefs;return t("svg",e({ref:g,style:{position:"absolute",top:0,left:0,width:p.width||"100%",height:p.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:v?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[h&&i("g",{children:i("line",{x1:h.x1,y1:h.y,x2:h.x2,y2:h.y,stroke:y.badgeBorder,strokeWidth:"1.5"})}),f.map(function(d){var u,g,p,v,h,y,f,k=d.x1+.5*(d.x2-d.x1),K=(d.y1+d.y2)/2;if("Not Defined"===d.style.label&&!d.hasCognitive)return null;if(d.isSubSection?m&&x===d.subSectionKeyPath&&b:m&&x===d.sectionIdx&&b)return null;if(S)return null;var L=d.isSubSection?l(d.x1,d.y1,d.x2,d.y2):"M ".concat(d.x1," ").concat(d.y1," L ").concat(d.x2," ").concat(d.y2),T=C[d.sectionIdx]||{title:"",content:""},z=I[null!==(u=d.targetRightIdx)&&void 0!==u?u:d.sectionIdx]||{title:"",content:""};if(d.isSubSection&&d.subSectionKeyPath){var E=d.subSectionKeyPath.includes(s)?d.subSectionKeyPath.split(s):[],A=E[2]||d.subSectionKeyPath,N=E[3]||A,
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{ChevronDown as n}from"lucide-react";import{ButtonCognitiveIcon as o}from"../../../assests/svg/ButtonCognitiveIcon.js";import{getBentArrowPath as l,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as r}from"../CognitiveCompareConstants.js";import a from"./ThreeDotsLoader.js";import d from"./connectedLines.js";import{Box as c}from"@mui/material";function u(u){var g=u.svgContainerRef,p=u.svgDimensions,v=u.isResizing,h=u.overallConnector,y=u.rootDeviationStyle,f=u.lines,m=u.isSideBySide,x=u.activeSideBySideSection,b=u.isArrowVisible,S=u.maintainRelativeOrder,C=u.proposedSections,I=u.existingSections,w=u.cognitivePopup,B=u.activeBadgeId,P=u.closeCognitivePopup,R=u.setActiveBadgeId,j=u.openCognitivePopupFromState,D=u.buildSectionPopupState,k=u.connectedLines,K=u.pathRefs;return t("svg",e({ref:g,style:{position:"absolute",top:0,left:0,width:p.width||"100%",height:p.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:v?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[h&&i("g",{children:i("line",{x1:h.x1,y1:h.y,x2:h.x2,y2:h.y,stroke:y.badgeBorder,strokeWidth:"1.5"})}),f.map(function(d){var u,g,p,v,h,y,f,k=d.x1+.5*(d.x2-d.x1),K=(d.y1+d.y2)/2;if("Not Defined"===d.style.label&&!d.hasCognitive)return null;if(d.isSubSection?m&&x===d.subSectionKeyPath&&b:m&&x===d.sectionIdx&&b)return null;if(S)return null;var L=d.isSubSection?l(d.x1,d.y1,d.x2,d.y2):"M ".concat(d.x1," ").concat(d.y1," L ").concat(d.x2," ").concat(d.y2),T=C[d.sectionIdx]||{title:"",content:""},z=I[null!==(u=d.targetRightIdx)&&void 0!==u?u:d.sectionIdx]||{title:"",content:""};if(d.isSubSection&&d.subSectionKeyPath){var E=d.subSectionKeyPath.includes(s)?d.subSectionKeyPath.split(s):[],A=E[2]||d.subSectionKeyPath,N=E[3]||A,O=A.split("-").map(Number),W=N.split("-").map(Number),F=null,M=null;O.length>0&&(F=C[O[0]]||null),W.length>0&&(M=I[W[0]]||null);for(var _=(null==F?void 0:F.title)||"",V=(null==M?void 0:M.title)||"",q=1;q<O.length;q+=1)(null==F?void 0:F.subsections)&&(F=F.subsections[O[q]]||null);for(q=1;q<W.length;q+=1)(null==M?void 0:M.subsections)&&(M=M.subsections[W[q]]||null);F&&(T=e(e({},F),{title:_||F.title})),M&&(z=e(e({},M),{title:V||M.title}))}var G=!(null===(g=T.cognitiveData)||void 0===g?void 0:g.isMissingRationale)||Boolean(null===(v=null===(p=T.cognitiveData)||void 0===p?void 0:p.decisioning)||void 0===v?void 0:v.length),H=(null===(f=null===(y=null===(h=T.evaluationResult)||void 0===h?void 0:h.cognitive_decisioning)||void 0===y?void 0:y.decisioning_factors)||void 0===f?void 0:f.length)||!1,J=G||H;return t("g",{children:[i("path",{d:L,fill:"none",stroke:d.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:k-100,y:K-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(c,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(c,e({onClick:function(e){e.stopPropagation(),J&&(w.open&&B===d.id?P():(R(d.id),j(D(e.currentTarget,T,z,d.sectionIdx,!1,d.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.style.badgeBg,color:d.style.badgeText,border:"1px solid ".concat(d.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:J?"pointer":"default"}},{children:[d.style.badgeText===r&&null==d.style.label?i(a,{color:d.style.badgeText}):null==d.style.label?null:"0"===String(d.style.label)?"Same":d.style.label,i(c,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(o,{})})),J&&i(n,{size:11,style:{transform:w.open&&B===d.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},d.id)}),i(d,{maintainRelativeOrder:S,connectedLines:k,pathRefs:K})]}))}export{u as default};
|
|
2
2
|
//# sourceMappingURL=SvgConnectors.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as r}from"tslib";import{jsx as
|
|
1
|
+
import{__assign as r}from"tslib";import{jsx as o,Fragment as e,jsxs as t}from"react/jsx-runtime";import{Box as n}from"@mui/material";import i from"./ScrollLockToggle.js";import{useCompareContext as c}from"../CompareContext.js";var l=function(l){var a=l.connectedLines,d=l.pathRefs,s=l.maintainRelativeOrder,f=c(),p=f.scrollSyncLocked,h=f.toggleScrollSyncLocked;return o(e,{children:a.map(function(e){var c,l,a=e.pathD,f=(null===(c=e.style)||void 0===c?void 0:c.badgeBorder)||"#6366F1",m="conn-marker-".concat(e.id),u="".concat(e.id,"-bg"),g="".concat(e.id,"-stroke"),k="".concat(e.id,"-btn"),v=void 0!==e.x1?e.x1+40:0,x=void 0!==e.y1?e.y1:0;return t("g",{children:[o("defs",{children:o("clipPath",r({id:"connections-clip"},{children:o("marker",r({id:m,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:o("polygon",{points:"0 0, 8 3, 0 6",fill:f})}))}))}),o("path",{ref:function(r){d.current[u]=r},d:a,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),o("path",{ref:function(r){d.current[g]=r},d:a,fill:"none",stroke:f,strokeWidth:"1.75",markerEnd:"url(#".concat(m,")")}),s&&void 0!==e.x1&&o("foreignObject",r({ref:function(r){d.current[k]=r},x:v-12,y:x-12,width:"24",height:"24",style:{pointerEvents:"auto",overflow:"visible"}},{children:o(n,r({onClick:function(r){r.stopPropagation(),h&&h(r)},sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",bgcolor:"#FFFFFF",borderRadius:"50%",border:"1px solid ".concat(f),cursor:"pointer",transition:"transform 0.2s ease","&:hover":{transform:"scale(1.05)",boxShadow:"0px 2px 4px rgba(0,0,0,0.1)"}}},{children:o(i,{locked:p,onToggle:h,color:(null===(l=e.style)||void 0===l?void 0:l.badgeText)||f,borderColor:"transparent",size:12})}))}))]},e.id)})})};export{l as default};
|
|
2
2
|
//# sourceMappingURL=connectedLines.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n,__rest as e}from"tslib";import{jsx as r,jsxs as t,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{safeStringify as g,mixHexColors as f,areMarkdownPropsEqual as v}from"../CognitiveComparehelpers.js";import m from"rehype-raw";import x from"remark-gfm";import b from"../components/ScrollLockToggle.js";var y=l.memo(function(v){var y=v.content,E=v.overlayContent,C=v.sxStyles,k=v.deviationBadges,B=void 0===k?[]:k,S=v.highlights,F=void 0===S?[]:S;v.maintainRelativeOrder;var w=v.highlightBg,A=v.suppressHighlightBg,T=void 0!==A&&A,z=v.collisionKey,I=c(null),O=!!E,D=d(function(){return B.reduce(function(e,r){var t;return n(n({},e),((t={})[r.id]=r,t))},{})},[B]),j=c({badgeMap:D,highlightBg:w,hideHighlightBg:O,suppressHighlightBg:T});j.current={badgeMap:D,highlightBg:w,hideHighlightBg:O,suppressHighlightBg:T};var L=function(e,r){return l.Children.map(e,function(e){var t;if(!l.isValidElement(e))return e;var i=(null===(t=e.props)||void 0===t?void 0:t.children)?L(e.props.children,r):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return r(o)})},M=d(function(){return{mark:function(t){var i,o,a,l,c=t.children,d=e(t,["children"]),s=j.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],x=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,b=d.isSuggestedDeviationFix||g;return r("span",n({style:n(n(n({},b?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g,f,v=i.children,m=e(i,["children"]),x=j.current.badgeMap,y=m["data-badge-id"];if(!y)return r("span",n({},m,{children:v}));var E=x[y];if(!E)return r("span",n({},m,{children:v}));var C="number"==typeof E.stackIndex?E.stackIndex:0,k="translateY(calc(-20% + ".concat(12*C,"px + var(--badge-nudge, 0px)))");return t(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[t(o,n({ref:E.badgeRef,className:"deviation-badge","data-side":E.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+C,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=E.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=E.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=E.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===E.side?{right:"-16px",transform:"".concat(k," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(k," translateX(calc(-100% - 8px))")}),E.isConnected&&E.style&&{outline:"2px solid ".concat(E.style.badgeBorder),outlineOffset:"1px"})},{children:[t(o,n({onClick:function(n){n.stopPropagation(),E.onSummaryClick&&E.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[r(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:E.label})),("left"===E.side||E.isOrphan)&&r(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=E.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=E.score&&"N/A"!==E.score&&"NA"!==E.score&&0!==E.score?"".concat(E.score):"N/A"===E.score||"NA"===E.score?"N/A":"Same"}))]})),("left"===E.side||E.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),E.onClick&&E.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=E.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:[r(h,{size:12,color:(null===(p=E.style)||void 0===p?void 0:p.badgeText)||"#3730A3"}),E.showScrollLockToggle&&r(b,{locked:!!E.scrollSyncLocked,onToggle:E.toggleScrollSyncLocked,color:(null===(g=E.style)||void 0===g?void 0:g.badgeText)||"#3730A3",borderColor:(null===(f=E.style)||void 0===f?void 0:f.badgeBorder)||"#C7D2FE",size:12})]}))]})),v]}))},table:function(e){var t=e.children;return r(o,n({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:t}))},thead:function(e){var t=e.children;return r(o,n({component:"thead"},{children:t}))},tbody:function(e){var t=e.children;return r(o,n({component:"tbody"},{children:t}))},tr:function(e){var t=e.children;return r(o,n({component:"tr",sx:{borderBotttom:"1px solid #E5E7EB"}},{children:t}))},th:function(e){var t=e.children;return r(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:t}))},td:function(e){var t=e.children;return r(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:t}))},updated:function(n){var t=n.children;return e(n,["children"]),r(i,{children:t})},deleted:function(t){var i=t.children;e(t,["children"]),console.log("nitish: ",i);var o=L(i,function(n){return l.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:o}))},changed:function(t){var i=t.children;e(t,["children"]);var o=L(i,function(n){return l.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:o}))}}},[]),P=function(n){if(!n)return"";var e=n.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n");return/\|.*\|/.test(e)&&/\|[-:\s]+\|/.test(e)?e.replace(/(\|.*\|)\n\s*\n(?=\|)/g,"$1\n"):e.split(/(\n{2,})/).map(function(n){return n.startsWith("\n")?n:n.replace(/\n/g," ")}).join("")},H=d(function(){return B.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[B]),N=function(n){return n.replace(/[\.,;:]/g," ")},R=d(function(){var e=P(g(y||"")),r=T?N(e):e,t=(B||[]).map(function(n){var e,r;return{id:null==n?void 0:n.id,highlight:P((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(r=null==n?void 0:n.style)||void 0===r?void 0:r.badgeBg)||w}}).filter(function(n){return n.id&&n.highlight}),i={};t.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e){void 0===n&&(n="");var r=e?' data-highlight-color="'.concat(e,'"'):"";return'<mark data-badge-id="'.concat(n,'"').concat(r,">")},a=function(n){return'<span data-badge-id="'.concat(n,'">')},l=[];Object.entries(i).forEach(function(n){var t=n[0],i=n[1],o=e.indexOf(t),a=!1;if(-1===o&&T){var c=N(t);-1!==(o=r.indexOf(c))&&(a=!0)}if(-1!==o){for(var d=i[0].highlightColor,s=1;s<i.length;s++)d=f(d,i[s].highlightColor);l.push({highlight:t,start:o,end:o+t.length,badges:i,color:d,usedLooseMatch:a})}}),l.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],d={};l.forEach(function(n,e){for(var r=n.start,t=n.end,i=0,o=c;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=r<s&&t>s&&r>=l,h=r<l&&t>l&&t<=s;if(r>=l&&t<=s){n.orphaned=!0,d[e]=a.matchIdx;break}u&&(r=s),h&&(t=l)}n.trimmedStart=r,n.trimmedEnd=t,!n.orphaned&&r<t&&c.push({start:r,end:t,matchIdx:e})});var s={};Object.entries(d).forEach(function(n){var e=n[0],r=n[1],t=Number(e);s[r]||(s[r]=[]),s[r].push(t)});var u=function(n,e,r){void 0===e&&(e="");var t=n.startsWith("\n\n"),i=n.endsWith("\n\n"),a=n.split(/(\n{2,})/).map(function(n,a,l){if(/^\n{2,}$/.test(n))return n;if(!n.trim())return n;var c=0===a||1===a&&/^\n{2,}$/.test(l[0]),d=a===l.length-1||a===l.length-2&&/^\n{2,}$/.test(l[l.length-1]);return t&&c||i&&d?n:function(n,e,r){var t,i,a;void 0===e&&(e="");var l=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!l)return n;var c=null!==(t=l[1])&&void 0!==t?t:"",d=null!==(i=l[2])&&void 0!==i?i:"",s=null!==(a=l[3])&&void 0!==a?a:"";return d?c+o(e,r)+d+"</mark>"+s:n}(n,e,r)}).join("");return a.replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")},h=l.map(function(e,r){return n(n({},e),{idx:r})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var r,t;return(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)-(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)});h.forEach(function(n){var r,t,i=null!==(r=n.trimmedStart)&&void 0!==r?r:n.start,o=null!==(t=n.trimmedEnd)&&void 0!==t?t:n.end;if(!(i>=o)){var c=e.slice(i,o),d=function(n,e,r,t){if(!r.length)return n;var i=r.map(function(n){return l[n]}).sort(function(n,e){return n.start-e.start}),o="",c=0;return i.forEach(function(r){var i=r.start-e,l=r.end-e,d=f(t,r.color);o+=n.slice(c,i);var s="",h="";r.badges.forEach(function(n){s+=a(n.id),h="</span>"+h}),o+=s+u(n.slice(i,l),r.badges[0].id,d)+h,c=l}),o+=n.slice(c)}(n.usedLooseMatch||i!==n.start||o!==n.end?c:n.highlight,n.start,s[n.idx]||[],n.color),h=u(d,n.badges[0].id,n.color),p="",g="";n.badges.forEach(function(n){p+=a(n.id),g="</span>"+g});var v=p+h+g;e=e.slice(0,i)+v+e.slice(o)}});var p=new Set(Object.keys(i));return F.forEach(function(n){if(n){var t=P(n);if(t&&!p.has(t)){var i=T?r.indexOf(N(t)):e.indexOf(t);if(-1!==i){var a=e.slice(0,i);if((a.match(/</g)||[]).length===(a.match(/>/g)||[]).length){var l=o("","")+t+"</mark>";e=e.slice(0,i)+l+e.slice(i+t.length)}}}}}),e},[y,B,F,w,T]),W=d(function(){return E?P(g(E||"")):""},[E]),$=!!E,q=n(n(n(n({},C),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),$?{color:"transparent"}:{}),{"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}}),X=n(n({},C),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}});return s(function(){if(I.current){var n=function(){var n=Array.from(I.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),r=n.filter(function(n){return"left"!==n.dataset.side}),t=I.current.getBoundingClientRect(),i=t.bottom-4,o=t.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 r=[],t=[];e.forEach(function(n){if(0===t.length)t.push(n);else{var e=t[t.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,t.push(n)):(r.push(t),t=[n])}}),t.length>0&&r.push(t),r.forEach(function(n){var e=n[n.length-1],r=e.currentTop+e.height;if(r>i){var t=r-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(t,a));n.forEach(function(n){n.currentTop-=l})}}),r.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(r)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),r=new ResizeObserver(function(){requestAnimationFrame(n)});return r.observe(I.current),function(){r.disconnect(),cancelAnimationFrame(e)}}},[R,z,H]),t(o,n({ref:I,sx:{position:"relative",display:"grid"}},{children:[r(a,n({component:"div",sx:n(n({},q),{padding:"3px"})},{children:r(p,n({components:M,remarkPlugins:[x],rehypePlugins:[m]},{children:g(R).replace(/\\n/g,"\n")}))})),$&&r(a,n({component:"div",sx:X},{children:r(p,n({components:M,remarkPlugins:[x],rehypePlugins:[m]},{children:g(W).replace(/\\n/g,"\n")}))}))]}))},v);export{y as MemoizedMarkdown};
|
|
1
|
+
import{__assign as n,__rest as e}from"tslib";import{jsx as r,jsxs as t,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{safeStringify as g,mixHexColors as f,areMarkdownPropsEqual as v}from"../CognitiveComparehelpers.js";import m from"rehype-raw";import x from"remark-gfm";var b=l.memo(function(v){var b=v.content,y=v.overlayContent,E=v.sxStyles,C=v.deviationBadges,B=void 0===C?[]:C,F=v.highlights,k=void 0===F?[]:F;v.maintainRelativeOrder;var S=v.highlightBg,w=v.suppressHighlightBg,A=void 0!==w&&w,T=v.collisionKey,I=c(null),O=!!y,z=d(function(){return B.reduce(function(e,r){var t;return n(n({},e),((t={})[r.id]=r,t))},{})},[B]),D=c({badgeMap:z,highlightBg:S,hideHighlightBg:O,suppressHighlightBg:A});D.current={badgeMap:z,highlightBg:S,hideHighlightBg:O,suppressHighlightBg:A};var j=function(e,r){return l.Children.map(e,function(e){var t;if(!l.isValidElement(e))return e;var i=(null===(t=e.props)||void 0===t?void 0:t.children)?j(e.props.children,r):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return r(o)})},M=d(function(){return{mark:function(t){var i,o,a,l,c=t.children,d=e(t,["children"]),s=D.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],x=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,b=d.isSuggestedDeviationFix||g;return r("span",n({style:n(n(n({},b?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g=i.children,f=e(i,["children"]),v=D.current.badgeMap,m=f["data-badge-id"];if(!m)return r("span",n({},f,{children:g}));var x=v[m];if(!x)return r("span",n({},f,{children:g}));var b="number"==typeof x.stackIndex?x.stackIndex:0,y="translateY(calc(-20% + ".concat(12*b,"px + var(--badge-nudge, 0px)))");return t(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[t(o,n({ref:x.badgeRef,className:"deviation-badge","data-side":x.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+b,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=x.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=x.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=x.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===x.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),x.isConnected&&x.style&&{outline:"2px solid ".concat(x.style.badgeBorder),outlineOffset:"1px"})},{children:[t(o,n({onClick:function(n){n.stopPropagation(),x.onSummaryClick&&x.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[r(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:x.label})),("left"===x.side||x.isOrphan)&&r(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=x.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=x.score&&"N/A"!==x.score&&"NA"!==x.score&&0!==x.score?"".concat(x.score):"N/A"===x.score||"NA"===x.score?"N/A":"Same"}))]})),("left"===x.side||x.isOrphan)&&r(o,n({onClick:function(n){n.stopPropagation(),x.onClick&&x.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=x.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:r(h,{size:12,color:(null===(p=x.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var t=e.children;return r(o,n({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:t}))},thead:function(e){var t=e.children;return r(o,n({component:"thead"},{children:t}))},tbody:function(e){var t=e.children;return r(o,n({component:"tbody"},{children:t}))},tr:function(e){var t=e.children;return r(o,n({component:"tr",sx:{borderBotttom:"1px solid #E5E7EB"}},{children:t}))},th:function(e){var t=e.children;return r(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:t}))},td:function(e){var t=e.children;return r(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:t}))},updated:function(n){var t=n.children;return e(n,["children"]),r(i,{children:t})},deleted:function(t){var i=t.children;e(t,["children"]),console.log("nitish: ",i);var o=j(i,function(n){return l.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:o}))},changed:function(t){var i=t.children;e(t,["children"]);var o=j(i,function(n){return l.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:o}))}}},[]),P=function(n){return n?n.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(n){return n.startsWith("\n")||/\|.*\|/.test(n)&&/\|[-:\s]+\|/.test(n)?n:n.replace(/\n/g," ")}).join(""):""},H=d(function(){return B.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[B]),N=function(n){return n.replace(/[\.,;:]/g," ")},R=d(function(){var e=P(g(b||"")),r=A?N(e):e,t=(B||[]).map(function(n){var e,r;return{id:null==n?void 0:n.id,highlight:P((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(r=null==n?void 0:n.style)||void 0===r?void 0:r.badgeBg)||S}}).filter(function(n){return n.id&&n.highlight}),i={};t.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e){void 0===n&&(n="");var r=e?' data-highlight-color="'.concat(e,'"'):"";return'<mark data-badge-id="'.concat(n,'"').concat(r,">")},a=function(n){return'<span data-badge-id="'.concat(n,'">')},l=[];Object.entries(i).forEach(function(n){var t=n[0],i=n[1],o=e.indexOf(t),a=!1;if(-1===o&&A){var c=N(t);-1!==(o=r.indexOf(c))&&(a=!0)}if(-1!==o){for(var d=i[0].highlightColor,s=1;s<i.length;s++)d=f(d,i[s].highlightColor);l.push({highlight:t,start:o,end:o+t.length,badges:i,color:d,usedLooseMatch:a})}}),l.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],d={};l.forEach(function(n,e){for(var r=n.start,t=n.end,i=0,o=c;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=r<s&&t>s&&r>=l,h=r<l&&t>l&&t<=s;if(r>=l&&t<=s){n.orphaned=!0,d[e]=a.matchIdx;break}u&&(r=s),h&&(t=l)}n.trimmedStart=r,n.trimmedEnd=t,!n.orphaned&&r<t&&c.push({start:r,end:t,matchIdx:e})});var s={};Object.entries(d).forEach(function(n){var e=n[0],r=n[1],t=Number(e);s[r]||(s[r]=[]),s[r].push(t)});var u=function(n,e,r){void 0===e&&(e="");var t=n.startsWith("\n\n"),i=n.endsWith("\n\n"),a=n.split(/(\n{2,})/).map(function(n,a,l){if(/^\n{2,}$/.test(n))return n;if(!n.trim())return n;var c=0===a||1===a&&/^\n{2,}$/.test(l[0]),d=a===l.length-1||a===l.length-2&&/^\n{2,}$/.test(l[l.length-1]);return t&&c||i&&d?n:function(n,e,r){var t,i,a;void 0===e&&(e="");var l=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!l)return n;var c=null!==(t=l[1])&&void 0!==t?t:"",d=null!==(i=l[2])&&void 0!==i?i:"",s=null!==(a=l[3])&&void 0!==a?a:"";return d?c+o(e,r)+d+"</mark>"+s:n}(n,e,r)}).join("");return a.replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")},h=l.map(function(e,r){return n(n({},e),{idx:r})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var r,t;return(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)-(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)});h.forEach(function(n){var r,t,i=null!==(r=n.trimmedStart)&&void 0!==r?r:n.start,o=null!==(t=n.trimmedEnd)&&void 0!==t?t:n.end;if(!(i>=o)){var c=e.slice(i,o),d=function(n,e,r,t){if(!r.length)return n;var i=r.map(function(n){return l[n]}).sort(function(n,e){return n.start-e.start}),o="",c=0;return i.forEach(function(r){var i=r.start-e,l=r.end-e,d=f(t,r.color);o+=n.slice(c,i);var s="",h="";r.badges.forEach(function(n){s+=a(n.id),h="</span>"+h}),o+=s+u(n.slice(i,l),r.badges[0].id,d)+h,c=l}),o+=n.slice(c)}(n.usedLooseMatch||i!==n.start||o!==n.end?c:n.highlight,n.start,s[n.idx]||[],n.color),h=u(d,n.badges[0].id,n.color),p="",g="";n.badges.forEach(function(n){p+=a(n.id),g="</span>"+g});var v=p+h+g;e=e.slice(0,i)+v+e.slice(o)}});var p=new Set(Object.keys(i));return k.forEach(function(n){if(n){var t=P(n);if(t&&!p.has(t)){var i=A?r.indexOf(N(t)):e.indexOf(t);if(-1!==i){var a=e.slice(0,i);if((a.match(/</g)||[]).length===(a.match(/>/g)||[]).length){var l=o("","")+t+"</mark>";e=e.slice(0,i)+l+e.slice(i+t.length)}}}}}),e},[b,B,k,S,A]),W=d(function(){return y?P(g(y||"")):""},[y]),$=!!y,q=n(n(n(n({},E),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),$?{color:"transparent"}:{}),{"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}}),L=n(n({},E),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}});return s(function(){if(I.current){var n=function(){var n=Array.from(I.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),r=n.filter(function(n){return"left"!==n.dataset.side}),t=I.current.getBoundingClientRect(),i=t.bottom-4,o=t.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 r=[],t=[];e.forEach(function(n){if(0===t.length)t.push(n);else{var e=t[t.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,t.push(n)):(r.push(t),t=[n])}}),t.length>0&&r.push(t),r.forEach(function(n){var e=n[n.length-1],r=e.currentTop+e.height;if(r>i){var t=r-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(t,a));n.forEach(function(n){n.currentTop-=l})}}),r.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(r)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),r=new ResizeObserver(function(){requestAnimationFrame(n)});return r.observe(I.current),function(){r.disconnect(),cancelAnimationFrame(e)}}},[R,T,H]),t(o,n({ref:I,sx:{position:"relative",display:"grid"}},{children:[r(a,n({component:"div",sx:n(n({},q),{padding:"3px"})},{children:r(p,n({components:M,remarkPlugins:[x],rehypePlugins:[m]},{children:g(R).replace(/\\n/g,"\n")}))})),$&&r(a,n({component:"div",sx:L},{children:r(p,n({components:M,remarkPlugins:[x],rehypePlugins:[m]},{children:g(W).replace(/\\n/g,"\n")}))}))]}))},v);export{b as MemoizedMarkdown};
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as t,useRef as e,useCallback as n,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,hasValue as c,getBentArrowPath as o}from"../CognitiveComparehelpers.js";var l=function(l){var u=l.containerRef,a=l.leftContainerRef,d=l.rightContainerRef;l.svgContainerRef;var v=l.pathRefs,s=l.leftHeaderRef,h=l.rightHeaderRef,g=l.proposedSections,f=l.existingSections,p=l.visibleFields,x=l.leftRefs,y=l.rightRefs,m=l.sectionLeftRefs,R=l.sectionRightRefs,C=l.subSectionLeftRefs,B=l.subSectionRightRefs,b=l.lhsBadgeRefs,S=l.rhsBadgeRefs,M=l.sectionRowRefs,L=l.expandedSections,T=l.expandedSubSections,I=l.connectedSections,H=l.isSideBySide,A=l.activeSideBySideSection,E=l.maintainRelativeOrder,D=l.cognitiveMap,k=l.getSectionCompareStyle,Y=l.getSubSectionCompareStyle,w=l.getDeviationStyleByKey,N=l.isArrowVisible,O=l.isAnimatingRef,j=l.isSideBySideRef,F=l.sideBySideCacheRef,P=l.sideBySideLineRef,z=l.activeSideBySideSectionRef,K=l.activeSideBySideRightSectionRef,q=l.connectedLines,V=l.setConnectedLines,G=l.cachedConnectedPositions,J=l.calculateLinesRef,Q=l.resizeTimerRef,U=l.scrollLock,W=l.scrollSyncLocked,X=l.handleResizeRef,Z=l.activeProposed,$=l.existingRule,_=l.analysisData,tt=l.pendingScrollTargetRef,et=l.pendingScrollCallbackRef,nt=l.resolvedComparisonConfig,rt=l.getFieldData,it=t([]),ct=it[0],ot=it[1],lt=t(null),ut=lt[0],at=lt[1],dt=t([]),vt=dt[0],st=dt[1],ht=null!=q?q:vt,gt=null!=V?V:st,ft=t({width:0,height:0}),pt=ft[0],xt=ft[1],yt=e(!1),mt=e(!1),Rt=e(!1),Ct=e(null),Bt=e([]),bt=null!=G?G:Bt,St=n(function(){var t,e,n,r,l,v,M,N,j,F,P,z,K,q,V,G,J,Q,U,W,X,Z,$;if(!yt.current&&!O.current){yt.current=!0;try{if(!u.current)return;var _=function(t){var e=t.split("-"),n=e[0];if(!L[n]&&!1===E)return!1;if(E&&!L["left-".concat(n)]&&!L["right-".concat(n)]&&!L[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!T[r])return!1;return!0},tt=u.current.getBoundingClientRect();xt({width:tt.width,height:tt.height});var et=[];if(p.forEach(function(t){var e,n,r=t.key,i=null===(e=x.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!O.current){for(var nt=0;nt<Math.max(g.length,f.length);nt++){var rt=null===(t=m.current[nt])||void 0===t?void 0:t.current,it=null===(e=R.current[nt])||void 0===e?void 0:e.current;rt&&(rt.style.height="auto",rt.style.minHeight="0px"),it&&(it.style.height="auto",it.style.minHeight="0px")}E||Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var r=null===(e=C.current[t])||void 0===e?void 0:e.current,i=null===(n=B.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var ct={};p.forEach(function(t){var e,n,r=t.key,i=null===(e=x.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();ct[r]=Math.max(o.height,l.height)}});var lt={left:{},right:{}},ut={};if(!O.current)if(E){if(H&&null!==A)if("number"==typeof A){var dt=A,vt=g[dt],st=null===(l=m.current[dt])||void 0===l?void 0:l.current;st&&vt&&(vt.refIndexes||[]).forEach(function(t){var e,n=f.findIndex(function(e){return e.selfIndex===t}),r=null===(e=R.current[n])||void 0===e?void 0:e.current;if(r&&(L["left-".concat(dt)]||L["right-".concat(n)])){var i=Math.max(st.getBoundingClientRect().height,r.getBoundingClientRect().height);lt.left[dt]=Math.max(lt.left[dt]||0,i),lt.right[n]=Math.max(lt.right[n]||0,i)}})}else{var ht=A.split(i)[2];if(ht){rt=null===(v=C.current[ht])||void 0===v?void 0:v.current,it=null===(M=B.current[ht])||void 0===M?void 0:M.current;if(rt&&it){ft=Math.max(rt.getBoundingClientRect().height,it.getBoundingClientRect().height);ut[ht]=Math.max(ut[ht]||0,ft)}}}}else{Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var r=null===(e=C.current[t])||void 0===e?void 0:e.current,i=null===(n=B.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);ut[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(nt=0;nt<Math.min(g.length,f.length);nt++){var rt=null===(n=m.current[nt])||void 0===n?void 0:n.current,it=null===(r=R.current[nt])||void 0===r?void 0:r.current;if(rt&&it){var ft=Math.max(rt.getBoundingClientRect().height,it.getBoundingClientRect().height);lt.left[nt]=ft,lt.right[nt]=ft}}}if(p.forEach(function(t){var e,n,r=t.key,i=null===(e=x.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=ct[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(lt.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=m.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries(lt.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=R.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),E||Object.keys(ut).forEach(function(t){var e,n,r=null===(e=C.current[t])||void 0===e?void 0:e.current,i=null===(n=B.current[t])||void 0===n?void 0:n.current;if(r&&i&&ut[t]){var c=ut[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}})),E)g.forEach(function(t,e){var n;(null===(n=m.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,r,i,c,o,l,u,v,s,h,g=f.findIndex(function(e){return e.selfIndex===t});if(-1!==g){var p=null===(n=b.current[e])||void 0===n?void 0:n.current,x=null===(r=S.current[g])||void 0===r?void 0:r.current;if(p&&x){var y=p.getBoundingClientRect(),m=x.getBoundingClientRect(),R=y.right-tt.left,C=m.left-tt.left,B=y.top+y.height/2-tt.top,M=m.top+m.height/2-tt.top;if(H&&A===e){var L=null!==(c=null===(i=a.current)||void 0===i?void 0:i.getBoundingClientRect().top)&&void 0!==c?c:0,T=null!==(l=null===(o=d.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,I=L+(null!==(v=null===(u=a.current)||void 0===u?void 0:u.clientHeight)&&void 0!==v?v:1/0),E=T+(null!==(h=null===(s=d.current)||void 0===s?void 0:s.clientHeight)&&void 0!==h?h:1/0),D=y.top+y.height/2,Y=m.top+m.height/2,w=function(t,e,n){return Math.max(e,Math.min(n,t))};B=w(D,L,I)-tt.top,M=w(Y,T,E)-tt.top}var N=k(e);N&&et.push({id:"line-".concat(e,"-").concat(g),x1:R,y1:B,x2:C,y2:M,style:N,sectionIdx:e,targetRightIdx:g})}}})});else{for(nt=0;nt<Math.min(g.length,f.length);nt++){var pt=null===(N=m.current[nt])||void 0===N?void 0:N.current,mt=null===(j=R.current[nt])||void 0===j?void 0:j.current;if(pt&&mt){var Rt=pt.getBoundingClientRect(),Ct=mt.getBoundingClientRect(),Bt=Math.max(Rt.top,Ct.top)+18-tt.top,St=(null===(F=f[nt])||void 0===F?void 0:F.id)||"sec-".concat(nt);(Dt=k(nt))&&et.push({id:St,x1:Rt.right-tt.left,y1:Bt,x2:Ct.left-tt.left,y2:Bt,style:Dt,sectionIdx:nt,hasCognitive:!!((null===(P=g[nt])||void 0===P?void 0:P.cognitiveData)||(null===(z=f[nt])||void 0===z?void 0:z.cognitiveData)||St&&D[St]),isSubSection:!1})}}Object.keys(C.current).forEach(function(t){var e,n,r,i,o,l;if(_(t)){var u=null===(e=C.current[t])||void 0===e?void 0:e.current,a=null===(n=B.current[t])||void 0===n?void 0:n.current;if(u&&a){for(var d=t.split("-").map(Number),v=g[d[0]],s=f[d[0]],h=1;h<d.length;h++)(null==v?void 0:v.subsections)&&(v=v.subsections[d[h]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[h]]);var p=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&c(v.title)),x=!!v&&((null===(i=v.displayContent)||void 0===i||i)&&c(v.content)),y=!!s&&((null===(o=s.displayTitle)||void 0===o||o)&&c(s.title)),m=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&c(s.content));if(p&&x||y&&m){var R=u.getBoundingClientRect(),b=a.getBoundingClientRect(),S=Math.max(R.top,b.top)+16-tt.top,M=Y(t);M&&"Not Defined"!==M.label&&et.push({id:"subsec-".concat(t),x1:R.right-tt.left,y1:S,x2:b.left-tt.left,y2:S,style:M,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==v?void 0:v.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(H&&"string"==typeof A&&A.includes(i)){var Mt=A.split(i),Lt=Mt[0],Tt=Mt[1],It=Mt[2],Ht=(Mt[3],"".concat(Lt).concat(i).concat(Tt)),At=null===(K=b.current[Ht])||void 0===K?void 0:K.current,Et=null===(q=S.current[Ht])||void 0===q?void 0:q.current;if(At&&Et){var Dt,kt=At.getBoundingClientRect(),Yt=Et.getBoundingClientRect(),wt=kt.right-tt.left,Nt=Yt.left-tt.left,Ot=kt.top+kt.height/2-tt.top,jt=Yt.top+Yt.height/2-tt.top;if(E){var Ft=null!==(G=null===(V=a.current)||void 0===V?void 0:V.getBoundingClientRect().top)&&void 0!==G?G:0,Pt=null!==(Q=null===(J=d.current)||void 0===J?void 0:J.getBoundingClientRect().top)&&void 0!==Q?Q:0,zt=Ft+(null!==(W=null===(U=a.current)||void 0===U?void 0:U.clientHeight)&&void 0!==W?W:1/0),Kt=Pt+(null!==(Z=null===(X=d.current)||void 0===X?void 0:X.clientHeight)&&void 0!==Z?Z:1/0),qt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ot=qt(kt.top+kt.height/2,Ft,zt)-tt.top,jt=qt(Yt.top+Yt.height/2,Pt,Kt)-tt.top}(Dt=null!==($=w(Lt,Tt))&&void 0!==$?$:Y(It))&&et.push({id:"line-subsec-".concat(Ht),x1:wt,y1:Ot,x2:Nt,y2:jt,style:Dt,sectionIdx:Number(It.split("-")[0]),isSubSection:!0,subSectionKeyPath:A})}}if(ot(et),s.current&&h.current){var Vt=s.current.getBoundingClientRect(),Gt=h.current.getBoundingClientRect(),Jt=(Vt.top+Vt.height/2-tt.top+Gt.top+Gt.height/2-tt.top)/2;at({x1:Vt.right-tt.left,x2:Gt.left-tt.left,y:Jt})}else at(null);if(I.size>0){var Qt=[],Ut=a.current,Wt=d.current;if(Ut&&Wt){var Xt=[],Zt=Ut.getBoundingClientRect().top,$t=Wt.getBoundingClientRect().top,_t=Zt+Ut.clientHeight,te=$t+Wt.clientHeight,ee=Ut.scrollTop,ne=Wt.scrollTop,re=tt.top,ie=function(t,e,n){return Math.max(e,Math.min(n,t))};I.forEach(function(t){var e,n,r,c,l,u;if("string"==typeof t&&t.includes(i)){var a=t.split(i),d=a[0],v=a[1],s=a[2],h=(a[3],"".concat(d).concat(i).concat(v)),p=null===(e=b.current[h])||void 0===e?void 0:e.current,x=null===(n=S.current[h])||void 0===n?void 0:n.current;if(!p||!x)return;var y=p.getBoundingClientRect(),m=x.getBoundingClientRect(),R=null!==(r=w(d,v))&&void 0!==r?r:Y(s),C=(q=y.right-tt.left)+.5*((V=m.left-tt.left-0)-q),B=y.top+y.height/2,M=m.top+m.height/2,L=B-Zt+ee,T=M-$t+ne,I="conn-subsec-".concat(h);Xt.push({lhsScrollY:L,rhsScrollY:T,x1:q,x2:V,containerTop:re,leftIdx:t,rhsArrayIdx:t,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:I});var H=ie(B,Zt,_t),A=ie(M,$t,te),D=H-re,N=A-re,O=M>=$t-4&&M<=te+4,j="";j=(G=B>=Zt-4&&B<=_t+4)&&O?o(q,D,V,N):G&&!O?"M ".concat(q,",").concat(D," L ").concat(C,",").concat(D," L ").concat(C,",").concat(N):!G&&O?"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N," L ").concat(V,",").concat(N):"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N),Qt.push({id:I,pathD:j,style:R,leftIdx:t,rhsArrayIdx:t})}else if(E){var F=t,P=g[F];if(!(null===(u=null==P?void 0:P.refIndexes)||void 0===u?void 0:u.length))return;P.refIndexes.forEach(function(t){var e,n,r=f.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var i=null===(e=b.current[F])||void 0===e?void 0:e.current,c=null===(n=S.current[r])||void 0===n?void 0:n.current;if(i&&c){var l=i.getBoundingClientRect(),u=c.getBoundingClientRect(),a=k(F),d=l.right-tt.left,v=u.left-tt.left-0,s=d+.5*(v-d),h=l.top+l.height/2,g=u.top+u.height/2,p=h-Zt+ee,x=g-$t+ne,y="conn-".concat(F,"-").concat(r);Xt.push({lhsScrollY:p,rhsScrollY:x,x1:d,x2:v,containerTop:re,leftIdx:F,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:y});var m=ie(h,Zt,_t),R=ie(g,$t,te),C=m-re,B=R-re,M=h>=Zt-4&&h<=_t+4,L=g>=$t-4&&g<=te+4,T="";T=M&&L?o(d,C,v,B):M&&!L?"M ".concat(d,",").concat(C," L ").concat(s,",").concat(C," L ").concat(s,",").concat(B):!M&&L?"M ".concat(s,",").concat(C," L ").concat(s,",").concat(B," L ").concat(v,",").concat(B):"M ".concat(s,",").concat(C," L ").concat(s,",").concat(B),Qt.push({id:y,pathD:T,style:a,leftIdx:F,rhsArrayIdx:r})}}})}else{var z=t,K=z;p=null===(c=b.current[z])||void 0===c?void 0:c.current,x=null===(l=S.current[K])||void 0===l?void 0:l.current;if(!p||!x)return;var q,V;y=p.getBoundingClientRect(),m=x.getBoundingClientRect(),R=k(z),C=(q=y.right-tt.left)+.5*((V=m.left-tt.left-0)-q),B=y.top+y.height/2,M=m.top+m.height/2,L=B-Zt+ee,T=M-$t+ne,I="conn-".concat(z,"-").concat(K);Xt.push({lhsScrollY:L,rhsScrollY:T,x1:q,x2:V,containerTop:re,leftIdx:z,rhsArrayIdx:K,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:I});var G;H=ie(B,Zt,_t),A=ie(M,$t,te),D=H-re,N=A-re,O=M>=$t-4&&M<=te+4,j="";j=(G=B>=Zt-4&&B<=_t+4)&&O?o(q,D,V,N):G&&!O?"M ".concat(q,",").concat(D," L ").concat(C,",").concat(D," L ").concat(C,",").concat(N):!G&&O?"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N," L ").concat(V,",").concat(N):"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N),Qt.push({id:I,pathD:j,style:R,leftIdx:z,rhsArrayIdx:K})}}),bt.current=Xt}gt(Qt)}else gt([]),bt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{yt.current=!1}}},[p,g,f,D,nt,rt,k,w,E,H,A,I,L,T]),Mt=n(function(){var t,e,n,r,i,c,l,s,h,g,f,p,x,y,m=bt.current;if(m.length&&!O.current){var R=null!==(e=null===(t=a.current)||void 0===t?void 0:t.scrollTop)&&void 0!==e?e:0,C=null!==(r=null===(n=d.current)||void 0===n?void 0:n.scrollTop)&&void 0!==r?r:0,B=null!==(c=null===(i=a.current)||void 0===i?void 0:i.clientHeight)&&void 0!==c?c:1/0,b=null!==(s=null===(l=d.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,S=null!==(g=null===(h=a.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,M=null!==(p=null===(f=d.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,L=S+B,T=M+b,I=null!==(y=null===(x=u.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==y?y:0,H=function(t,e,n){return Math.max(e,Math.min(n,t))};m.forEach(function(t){var e=t.lhsScrollY-R+S,n=t.rhsScrollY-C+M,r=v.current[t.styleId+"-stroke"],i=v.current[t.styleId+"-bg"];if(r||i){var c,l=H(e,S,L),u=H(n,M,T),a=l-I,d=u-I,s=e>=S-4&&e<=L+4,h=n>=M-4&&n<=T+4,g=t.x1+.5*(t.x2-t.x1);c=s&&h?o(t.x1,a,t.x2,d):s&&!h?"M ".concat(t.x1,",").concat(a," L ").concat(g,",").concat(a," L ").concat(g,",").concat(d):!s&&h?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(d," L ").concat(t.x2,",").concat(d):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(d),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",c)),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",c))}})}},[]),Lt=n(function(){bt.current.length>0&&!O.current||(null!==Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){J.current(),Ct.current=null},50))},[]),Tt=n(function(t){if(null!==tt.current&&et.current&&Math.abs(t.currentTarget.scrollTop-tt.current)<=2){var e=et.current;tt.current=null,et.current=null,e()}if(!Rt.current&&!U.current){if(E&&W&&(j.current||I.size>0)){var n=t.currentTarget,r=a.current,c=d.current,o=n===r?c:n===c?r:null;if(n&&o){var l=function(){var t,e,n,r,c,o,l,u,a,d,v,s=z.current,h=K.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(i)){var g=s.split(i),f="".concat(g[0]).concat(i).concat(g[1]);return{leftAnchor:(null===(t=b.current[f])||void 0===t?void 0:t.current)||(null===(e=C.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=m.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(r=S.current[f])||void 0===r?void 0:r.current)||(null===(c=B.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=R.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(s),x=null!==h?Number(h):p;return{leftAnchor:(null===(l=b.current[p])||void 0===l?void 0:l.current)||(null===(u=M.current[p])||void 0===u?void 0:u.current)||(null===(a=m.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=S.current[x])||void 0===d?void 0:d.current)||(null===(v=R.current[x])||void 0===v?void 0:v.current)||null}}(),v=l.leftAnchor,s=l.rightAnchor,h=n===r?v:s,g=n===r?s:v,f=null;if(h&&g){var p=h.getBoundingClientRect(),x=g.getBoundingClientRect(),y=o.getBoundingClientRect(),L=p.top+p.height/2;f=x.top-y.top+o.scrollTop+x.height/2-(L-y.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),H=Math.max(0,o.scrollHeight-o.clientHeight);f=T>0?n.scrollTop/T*H:n.scrollTop}var A=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,A)),Math.abs(o.scrollTop-f)>1&&(Rt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){Rt.current=!1}))}}E||Lt(),mt.current||(mt.current=!0,requestAnimationFrame(function(){var t,e,n,r,c,o,l;if(j.current){var v=a.current,s=d.current;if(v&&s&&P.current){if(!F.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(i)){var f=h.split(i),p="".concat(f[0]).concat(i).concat(f[1]);g=null===(t=b.current[p])||void 0===t?void 0:t.current}else g=null===(e=b.current[h])||void 0===e?void 0:e.current;if(g){var x=g.getBoundingClientRect();F.current={badgeScreenY:x.top+x.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(r=null===(n=u.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==r?r:0}}}if(F.current){var y=F.current,m=v.scrollTop-y.initialScrollTop,R=y.badgeScreenY-m,C=((c=R,o=y.leftTop,l=y.leftBottom,Math.max(o,Math.min(l,c)))-y.cTop).toString(),B=R>=y.leftTop-4&&R<=y.leftBottom+4;P.current.setAttribute("y1",C),P.current.setAttribute("y2",C),P.current.setAttribute("visibility",B?"visible":"hidden")}}}bt.current.length>0&&Mt(),mt.current=!1}))}},[Mt,E,W,I,Lt]);return r(function(){J.current=St},[St]),r(function(){var t=setTimeout(Lt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Ct.current&&clearTimeout(Ct.current),null!==Q.current&&clearTimeout(Q.current),window.removeEventListener("resize",e)}},[Z,$,_,p,L,T,g,f,nt,Lt,H,A,N,I]),{lines:ct,setLines:ot,overallConnector:ut,setOverallConnector:at,connectedLines:ht,setConnectedLines:gt,svgDimensions:pt,cachedConnectedPositions:bt,calculateLines:St,calculateLinesRef:J,calculateLinesDebounced:Lt,handleColumnScroll:Tt}};export{l as useLinesCalculator};
|
|
1
|
+
import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r,hasValue as c,getBentArrowPath as o}from"../CognitiveComparehelpers.js";var l=function(l){var u=l.containerRef,a=l.leftContainerRef,d=l.rightContainerRef;l.svgContainerRef;var v=l.pathRefs,s=l.leftHeaderRef,h=l.rightHeaderRef,g=l.proposedSections,f=l.existingSections,p=l.visibleFields,y=l.leftRefs,x=l.rightRefs,m=l.sectionLeftRefs,R=l.sectionRightRefs,C=l.subSectionLeftRefs,b=l.subSectionRightRefs,B=l.lhsBadgeRefs,S=l.rhsBadgeRefs,M=l.sectionRowRefs,L=l.expandedSections,T=l.expandedSubSections,I=l.connectedSections,H=l.isSideBySide,A=l.activeSideBySideSection,E=l.maintainRelativeOrder,D=l.cognitiveMap,k=l.getSectionCompareStyle,Y=l.getSubSectionCompareStyle,w=l.getDeviationStyleByKey,N=l.isArrowVisible,O=l.isAnimatingRef,j=l.isSideBySideRef,F=l.sideBySideCacheRef,P=l.sideBySideLineRef,z=l.activeSideBySideSectionRef,K=l.activeSideBySideRightSectionRef,q=l.connectedLines,V=l.setConnectedLines,G=l.cachedConnectedPositions,J=l.calculateLinesRef,Q=l.resizeTimerRef,U=l.scrollLock,W=l.scrollSyncLocked,X=l.handleResizeRef,Z=l.activeProposed,$=l.existingRule,_=l.analysisData,tt=l.pendingScrollTargetRef,et=l.pendingScrollCallbackRef,nt=l.resolvedComparisonConfig,it=l.getFieldData,rt=t([]),ct=rt[0],ot=rt[1],lt=t(null),ut=lt[0],at=lt[1],dt=t([]),vt=dt[0],st=dt[1],ht=null!=q?q:vt,gt=null!=V?V:st,ft=t({width:0,height:0}),pt=ft[0],yt=ft[1],xt=e(!1),mt=e(!1),Rt=e(!1),Ct=e(null),bt=e([]),Bt=null!=G?G:bt,St=n(function(){var t,e,n,i,l,v,M,N,j,F,P,z,K,q,V,G,J,Q,U,W,X,Z,$;if(!xt.current&&!O.current){xt.current=!0;try{if(!u.current)return;var _=function(t){var e=t.split("-"),n=e[0];if(!L[n]&&!1===E)return!1;if(E&&!L["left-".concat(n)]&&!L["right-".concat(n)]&&!L[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!T[i])return!1;return!0},tt=u.current.getBoundingClientRect();yt({width:tt.width,height:tt.height});var et=[];if(p.forEach(function(t){var e,n,i=t.key,r=null===(e=y.current[i])||void 0===e?void 0:e.current,c=null===(n=x.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")}),!O.current){for(var nt=0;nt<Math.max(g.length,f.length);nt++){var it=null===(t=m.current[nt])||void 0===t?void 0:t.current,rt=null===(e=R.current[nt])||void 0===e?void 0:e.current;it&&(it.style.height="auto",it.style.minHeight="0px"),rt&&(rt.style.height="auto",rt.style.minHeight="0px")}E||Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var i=null===(e=C.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 ct={};p.forEach(function(t){var e,n,i=t.key,r=null===(e=y.current[i])||void 0===e?void 0:e.current,c=null===(n=x.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();ct[i]=Math.max(o.height,l.height)}});var lt={left:{},right:{}},ut={};if(!O.current)if(E){if(H&&null!==A)if("number"==typeof A){var dt=A,vt=g[dt],st=null===(l=m.current[dt])||void 0===l?void 0:l.current;st&&vt&&(vt.refIndexes||[]).forEach(function(t){var e,n=f.findIndex(function(e){return e.selfIndex===t}),i=null===(e=R.current[n])||void 0===e?void 0:e.current;if(i&&(L["left-".concat(dt)]||L["right-".concat(n)])){var r=Math.max(st.getBoundingClientRect().height,i.getBoundingClientRect().height);lt.left[dt]=Math.max(lt.left[dt]||0,r),lt.right[n]=Math.max(lt.right[n]||0,r)}})}else{var ht=A.split(r)[2];if(ht){it=null===(v=C.current[ht])||void 0===v?void 0:v.current,rt=null===(M=b.current[ht])||void 0===M?void 0:M.current;if(it&&rt){ft=Math.max(it.getBoundingClientRect().height,rt.getBoundingClientRect().height);ut[ht]=Math.max(ut[ht]||0,ft)}}}}else{Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var i=null===(e=C.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(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);ut[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(nt=0;nt<Math.min(g.length,f.length);nt++){var it=null===(n=m.current[nt])||void 0===n?void 0:n.current,rt=null===(i=R.current[nt])||void 0===i?void 0:i.current;if(it&&rt){var ft=Math.max(it.getBoundingClientRect().height,rt.getBoundingClientRect().height);lt.left[nt]=ft,lt.right[nt]=ft}}}if(p.forEach(function(t){var e,n,i=t.key,r=null===(e=y.current[i])||void 0===e?void 0:e.current,c=null===(n=x.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=ct[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(lt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=m.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(lt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=R.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),E||Object.keys(ut).forEach(function(t){var e,n,i=null===(e=C.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&&ut[t]){var c=ut[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),E)g.forEach(function(t,e){var n;(null===(n=m.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,i,r,c,o,l,u,v,s,h,g=f.findIndex(function(e){return e.selfIndex===t});if(-1!==g){var p=null===(n=B.current[e])||void 0===n?void 0:n.current,y=null===(i=S.current[g])||void 0===i?void 0:i.current;if(p&&y){var x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=x.right-tt.left,C=m.left-tt.left,b=x.top+x.height/2-tt.top,M=m.top+m.height/2-tt.top;if(H&&A===e){var L=null!==(c=null===(r=a.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==c?c:0,T=null!==(l=null===(o=d.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,I=L+(null!==(v=null===(u=a.current)||void 0===u?void 0:u.clientHeight)&&void 0!==v?v:1/0),E=T+(null!==(h=null===(s=d.current)||void 0===s?void 0:s.clientHeight)&&void 0!==h?h:1/0),D=x.top+x.height/2,Y=m.top+m.height/2,w=function(t,e,n){return Math.max(e,Math.min(n,t))};b=w(D,L,I)-tt.top,M=w(Y,T,E)-tt.top}var N=k(e);N&&et.push({id:"line-".concat(e,"-").concat(g),x1:R,y1:b,x2:C,y2:M,style:N,sectionIdx:e,targetRightIdx:g})}}})});else{for(nt=0;nt<Math.min(g.length,f.length);nt++){var pt=null===(N=m.current[nt])||void 0===N?void 0:N.current,mt=null===(j=R.current[nt])||void 0===j?void 0:j.current;if(pt&&mt){var Rt=pt.getBoundingClientRect(),Ct=mt.getBoundingClientRect(),bt=Math.max(Rt.top,Ct.top)+18-tt.top,St=(null===(F=f[nt])||void 0===F?void 0:F.id)||"sec-".concat(nt);(Dt=k(nt))&&et.push({id:St,x1:Rt.right-tt.left,y1:bt,x2:Ct.left-tt.left,y2:bt,style:Dt,sectionIdx:nt,hasCognitive:!!((null===(P=g[nt])||void 0===P?void 0:P.cognitiveData)||(null===(z=f[nt])||void 0===z?void 0:z.cognitiveData)||St&&D[St]),isSubSection:!1})}}Object.keys(C.current).forEach(function(t){var e,n,i,r,o,l;if(_(t)){var u=null===(e=C.current[t])||void 0===e?void 0:e.current,a=null===(n=b.current[t])||void 0===n?void 0:n.current;if(u&&a){for(var d=t.split("-").map(Number),v=g[d[0]],s=f[d[0]],h=1;h<d.length;h++)(null==v?void 0:v.subsections)&&(v=v.subsections[d[h]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[h]]);var p=!!v&&((null===(i=v.displayTitle)||void 0===i||i)&&c(v.title)),y=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&c(v.content)),x=!!s&&((null===(o=s.displayTitle)||void 0===o||o)&&c(s.title)),m=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&c(s.content));if(p&&y||x&&m){var R=u.getBoundingClientRect(),B=a.getBoundingClientRect(),S=Math.max(R.top,B.top)+16-tt.top,M=Y(t);M&&"Not Defined"!==M.label&&et.push({id:"subsec-".concat(t),x1:R.right-tt.left,y1:S,x2:B.left-tt.left,y2:S,style:M,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==v?void 0:v.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(H&&"string"==typeof A&&A.includes(r)){var Mt=A.split(r),Lt=Mt[0],Tt=Mt[1],It=Mt[2],Ht=(Mt[3],"".concat(Lt).concat(r).concat(Tt)),At=null===(K=B.current[Ht])||void 0===K?void 0:K.current,Et=null===(q=S.current[Ht])||void 0===q?void 0:q.current;if(At&&Et){var Dt,kt=At.getBoundingClientRect(),Yt=Et.getBoundingClientRect(),wt=kt.right-tt.left,Nt=Yt.left-tt.left,Ot=kt.top+kt.height/2-tt.top,jt=Yt.top+Yt.height/2-tt.top;if(E){var Ft=null!==(G=null===(V=a.current)||void 0===V?void 0:V.getBoundingClientRect().top)&&void 0!==G?G:0,Pt=null!==(Q=null===(J=d.current)||void 0===J?void 0:J.getBoundingClientRect().top)&&void 0!==Q?Q:0,zt=Ft+(null!==(W=null===(U=a.current)||void 0===U?void 0:U.clientHeight)&&void 0!==W?W:1/0),Kt=Pt+(null!==(Z=null===(X=d.current)||void 0===X?void 0:X.clientHeight)&&void 0!==Z?Z:1/0),qt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ot=qt(kt.top+kt.height/2,Ft,zt)-tt.top,jt=qt(Yt.top+Yt.height/2,Pt,Kt)-tt.top}(Dt=null!==($=w(Lt,Tt))&&void 0!==$?$:Y(It))&&et.push({id:"line-subsec-".concat(Ht),x1:wt,y1:Ot,x2:Nt,y2:jt,style:Dt,sectionIdx:Number(It.split("-")[0]),isSubSection:!0,subSectionKeyPath:A})}}if(ot(et),s.current&&h.current){var Vt=s.current.getBoundingClientRect(),Gt=h.current.getBoundingClientRect(),Jt=(Vt.top+Vt.height/2-tt.top+Gt.top+Gt.height/2-tt.top)/2;at({x1:Vt.right-tt.left,x2:Gt.left-tt.left,y:Jt})}else at(null);if(I.size>0){var Qt=[],Ut=a.current,Wt=d.current;if(Ut&&Wt){var Xt=[],Zt=Ut.getBoundingClientRect().top,$t=Wt.getBoundingClientRect().top,_t=Zt+Ut.clientHeight,te=$t+Wt.clientHeight,ee=Ut.scrollTop,ne=Wt.scrollTop,ie=tt.top,re=function(t,e,n){return Math.max(e,Math.min(n,t))};I.forEach(function(t){var e,n,i,c,l,u;if("string"==typeof t&&t.includes(r)){var a=t.split(r),d=a[0],v=a[1],s=a[2],h=(a[3],"".concat(d).concat(r).concat(v)),p=null===(e=B.current[h])||void 0===e?void 0:e.current,y=null===(n=S.current[h])||void 0===n?void 0:n.current;if(!p||!y)return;var x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=null!==(i=w(d,v))&&void 0!==i?i:Y(s),C=(q=x.right-tt.left)+.5*((V=m.left-tt.left-0)-q),b=x.top+x.height/2,M=m.top+m.height/2,L=b-Zt+ee,T=M-$t+ne,I="conn-subsec-".concat(h);Xt.push({lhsScrollY:L,rhsScrollY:T,x1:q,x2:V,containerTop:ie,leftIdx:t,rhsArrayIdx:t,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:I});var H=re(b,Zt,_t),A=re(M,$t,te),D=H-ie,N=A-ie,O=M>=$t-4&&M<=te+4,j="";j=(G=b>=Zt-4&&b<=_t+4)&&O?o(q,D,V,N):G&&!O?"M ".concat(q,",").concat(D," L ").concat(C,",").concat(D," L ").concat(C,",").concat(N):!G&&O?"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N," L ").concat(V,",").concat(N):"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N),Qt.push({id:I,pathD:j,style:R,leftIdx:t,rhsArrayIdx:t,x1:q,x2:V,y1:D,y2:N})}else if(E){var F=t,P=g[F];if(!(null===(u=null==P?void 0:P.refIndexes)||void 0===u?void 0:u.length))return;P.refIndexes.forEach(function(t){var e,n,i=f.findIndex(function(e){return e.selfIndex===t});if(-1!==i){var r=null===(e=B.current[F])||void 0===e?void 0:e.current,c=null===(n=S.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),u=c.getBoundingClientRect(),a=k(F),d=l.right-tt.left,v=u.left-tt.left-0,s=d+.5*(v-d),h=l.top+l.height/2,g=u.top+u.height/2,p=h-Zt+ee,y=g-$t+ne,x="conn-".concat(F,"-").concat(i);Xt.push({lhsScrollY:p,rhsScrollY:y,x1:d,x2:v,containerTop:ie,leftIdx:F,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=re(h,Zt,_t),R=re(g,$t,te),C=m-ie,b=R-ie,M=h>=Zt-4&&h<=_t+4,L=g>=$t-4&&g<=te+4,T="";T=M&&L?o(d,C,v,b):M&&!L?"M ".concat(d,",").concat(C," L ").concat(s,",").concat(C," L ").concat(s,",").concat(b):!M&&L?"M ".concat(s,",").concat(C," L ").concat(s,",").concat(b," L ").concat(v,",").concat(b):"M ".concat(s,",").concat(C," L ").concat(s,",").concat(b),Qt.push({id:x,pathD:T,style:a,leftIdx:F,rhsArrayIdx:i,x1:d,x2:v,y1:C,y2:b})}}})}else{var z=t,K=z;p=null===(c=B.current[z])||void 0===c?void 0:c.current,y=null===(l=S.current[K])||void 0===l?void 0:l.current;if(!p||!y)return;var q,V;x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=k(z),C=(q=x.right-tt.left)+.5*((V=m.left-tt.left-0)-q),b=x.top+x.height/2,M=m.top+m.height/2,L=b-Zt+ee,T=M-$t+ne,I="conn-".concat(z,"-").concat(K);Xt.push({lhsScrollY:L,rhsScrollY:T,x1:q,x2:V,containerTop:ie,leftIdx:z,rhsArrayIdx:K,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:I});var G;H=re(b,Zt,_t),A=re(M,$t,te),D=H-ie,N=A-ie,O=M>=$t-4&&M<=te+4,j="";j=(G=b>=Zt-4&&b<=_t+4)&&O?o(q,D,V,N):G&&!O?"M ".concat(q,",").concat(D," L ").concat(C,",").concat(D," L ").concat(C,",").concat(N):!G&&O?"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N," L ").concat(V,",").concat(N):"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N),Qt.push({id:I,pathD:j,style:R,leftIdx:z,rhsArrayIdx:K,x1:q,x2:V,y1:D,y2:N})}}),Bt.current=Xt}gt(Qt)}else gt([]),Bt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{xt.current=!1}}},[p,g,f,D,nt,it,k,w,E,H,A,I,L,T]),Mt=n(function(){var t,e,n,i,r,c,l,s,h,g,f,p,y,x,m=Bt.current;if(m.length&&!O.current){var R=null!==(e=null===(t=a.current)||void 0===t?void 0:t.scrollTop)&&void 0!==e?e:0,C=null!==(i=null===(n=d.current)||void 0===n?void 0:n.scrollTop)&&void 0!==i?i:0,b=null!==(c=null===(r=a.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,B=null!==(s=null===(l=d.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,S=null!==(g=null===(h=a.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,M=null!==(p=null===(f=d.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,L=S+b,T=M+B,I=null!==(x=null===(y=u.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,H=function(t,e,n){return Math.max(e,Math.min(n,t))};m.forEach(function(t){var e=t.lhsScrollY-R+S,n=t.rhsScrollY-C+M,i=v.current[t.styleId+"-stroke"],r=v.current[t.styleId+"-bg"],c=v.current[t.styleId+"-btn"];if(i||r){var l,u=H(e,S,L),a=H(n,M,T),d=u-I,s=a-I,h=e>=S-4&&e<=L+4,g=n>=M-4&&n<=T+4,f=t.x1+.5*(t.x2-t.x1);l=h&&g?o(t.x1,d,t.x2,s):h&&!g?"M ".concat(t.x1,",").concat(d," L ").concat(f,",").concat(d," L ").concat(f,",").concat(s):!h&&g?"M ".concat(f,",").concat(d," L ").concat(f,",").concat(s," L ").concat(t.x2,",").concat(s):"M ".concat(f,",").concat(d," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",l)),c&&(h?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden"))}})}},[]),Lt=n(function(){Bt.current.length>0&&!O.current||(null!==Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){J.current(),Ct.current=null},50))},[]),Tt=n(function(t){if(null!==tt.current&&et.current&&Math.abs(t.currentTarget.scrollTop-tt.current)<=2){var e=et.current;tt.current=null,et.current=null,e()}if(!Rt.current&&!U.current){if(E&&W&&(j.current||I.size>0)){var n=t.currentTarget,i=a.current,c=d.current,o=n===i?c:n===c?i:null;if(n&&o){var l=function(){var t,e,n,i,c,o,l,u,a,d,v,s=z.current,h=K.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(r)){var g=s.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=B.current[f])||void 0===t?void 0:t.current)||(null===(e=C.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=m.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=S.current[f])||void 0===i?void 0:i.current)||(null===(c=b.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=R.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(s),y=null!==h?Number(h):p;return{leftAnchor:(null===(l=B.current[p])||void 0===l?void 0:l.current)||(null===(u=M.current[p])||void 0===u?void 0:u.current)||(null===(a=m.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=S.current[y])||void 0===d?void 0:d.current)||(null===(v=R.current[y])||void 0===v?void 0:v.current)||null}}(),v=l.leftAnchor,s=l.rightAnchor,h=n===i?v:s,g=n===i?s:v,f=null;if(h&&g){var p=h.getBoundingClientRect(),y=g.getBoundingClientRect(),x=o.getBoundingClientRect(),L=p.top+p.height/2;f=y.top-x.top+o.scrollTop+y.height/2-(L-x.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),H=Math.max(0,o.scrollHeight-o.clientHeight);f=T>0?n.scrollTop/T*H:n.scrollTop}var A=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,A)),Math.abs(o.scrollTop-f)>1&&(Rt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){Rt.current=!1}))}}E||Lt(),mt.current||(mt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,o,l;if(j.current){var v=a.current,s=d.current;if(v&&s&&P.current){if(!F.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=B.current[p])||void 0===t?void 0:t.current}else g=null===(e=B.current[h])||void 0===e?void 0:e.current;if(g){var y=g.getBoundingClientRect();F.current={badgeScreenY:y.top+y.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(i=null===(n=u.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(F.current){var x=F.current,m=v.scrollTop-x.initialScrollTop,R=x.badgeScreenY-m,C=((c=R,o=x.leftTop,l=x.leftBottom,Math.max(o,Math.min(l,c)))-x.cTop).toString(),b=R>=x.leftTop-4&&R<=x.leftBottom+4;P.current.setAttribute("y1",C),P.current.setAttribute("y2",C),P.current.setAttribute("visibility",b?"visible":"hidden")}}}Bt.current.length>0&&Mt(),mt.current=!1}))}},[Mt,E,W,I,Lt]);return i(function(){J.current=St},[St]),i(function(){var t=setTimeout(Lt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Ct.current&&clearTimeout(Ct.current),null!==Q.current&&clearTimeout(Q.current),window.removeEventListener("resize",e)}},[Z,$,_,p,L,T,g,f,nt,Lt,H,A,N,I]),{lines:ct,setLines:ot,overallConnector:ut,setOverallConnector:at,connectedLines:ht,setConnectedLines:gt,svgDimensions:pt,cachedConnectedPositions:Bt,calculateLines:St,calculateLinesRef:J,calculateLinesDebounced:Lt,handleColumnScroll:Tt}};export{l as useLinesCalculator};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|