@viswa-test/test-citation 0.0.272 → 0.0.274
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/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
- package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
- package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts +8 -0
- package/dist/types/src/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),r=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw"),d=require("remark-gfm");function c(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=c(i),h=c(a),g=c(l),p=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},f=[p(c(d).default)],v=[p(g.default)],x=u.default.memo(function(a){var l=a.content,d=a.overlayContent,c=a.sxStyles,g=a.deviationBadges,p=void 0===g?[]:g,x=a.highlights,m=void 0===x?[]:x;a.maintainRelativeOrder;var _=a.highlightBg,b=a.suppressHighlightBg,y=void 0!==b&&b,B=a.collisionKey,E=i.useRef(null),j=!!d,w=i.useMemo(function(){return p.reduce(function(e,t){var i;return n.__assign(n.__assign({},e),((i={})[t.id]=t,i))},{})},[p]),k=i.useRef({badgeMap:w,highlightBg:_,hideHighlightBg:j,suppressHighlightBg:y});k.current={badgeMap:w,highlightBg:_,hideHighlightBg:j,suppressHighlightBg:y};var C=function(e,t){return u.default.Children.map(e,function(e){var i;if(!u.default.isValidElement(e))return e;var r=(null===(i=e.props)||void 0===i?void 0:i.children)?C(e.props.children,t):e.props.children,o=u.default.cloneElement(e,n.__assign(n.__assign({},e.props),{children:r}));return t(o)})},S=i.useMemo(function(){return{mark:function(t){var i,r,o,a,s=t.children,l=n.__rest(t,["children"]),d=k.current,c=d.badgeMap,u=d.highlightBg,h=d.hideHighlightBg,g=d.suppressHighlightBg,p=l["data-badge-id"],f=p?c[p]:null,v=l["data-highlight-color"],x=null!==(a=null!==(r=null!=v?v:null===(i=null==f?void 0:f.style)||void 0===i?void 0:i.highlightBg)&&void 0!==r?r:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m="true"===l["data-is-suggested-deviation-fix"]||g;return e.jsx("span",n.__assign({style:n.__assign(n.__assign(n.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:s}))},span:function(i){var a,s,l,d,c,u,h=i.children,g=n.__rest(i,["children"]),p=k.current.badgeMap,f=g["data-badge-id"];if(!f)return e.jsx("span",n.__assign({},g,{children:h}));var v=p[f];if(!v)return e.jsx("span",n.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return e.jsxs(t.Box,n.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[e.jsxs(t.Box,n.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:n.__assign(n.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=v.style)||void 0===s?void 0:s.badgeText)||r.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=v.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[e.jsxs(t.Box,n.__assign({onClick:function(n){n.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[e.jsx(t.Box,n.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&e.jsx(t.Box,n.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&e.jsx(t.Box,n.__assign({onClick:function(n){n.stopPropagation(),v.onClick&&v.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:e.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:e.jsx(t.Box,n.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"thead"},{children:r}))},tbody:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"tbody"},{children:r}))},tr:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(t){var i=t.children;return e.jsx("span",n.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:i}))},pre:function(t){var i=t.children;return e.jsx("span",n.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:i}))},updated:function(n){var t=n.children;return e.jsx(e.Fragment,{children:t})},deleted:function(t){var i=t.children,r=C(i,function(n){return u.default.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return e.jsx("span",n.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(t){var i=t.children,r=C(i,function(n){return u.default.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return e.jsx("span",n.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},o,{children:r}))},ol:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},o,{children:r}))},li:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"li",sx:{mb:.5,display:"list-item"}},o,{children:r}))}}},[]),F=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,i){return"".concat(e," ").concat(i)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var i=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})}).join("")).trim()},M=i.useMemo(function(){return p.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[p]),T=i.useMemo(function(){var e=F(l||""),t=(p||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:F((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||_}}).filter(function(n){return n.id&&n.highlight}),i={};t.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var r=function(n,e,t,i){void 0===e&&(e=""),void 0===i&&(i=[]);var r=!1,o=function(n){var o=function(n,e,t){var i,r,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var s=null!==(i=a[1])&&void 0!==i?i:"",l=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return l?s+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",i=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(i).concat(t,">")}(e,t)+l+"</mark>"+d:n}(n,e,t),a=o;if(!r&&i.length>0){r=!0;var s="",l="";i.forEach(function(n){s+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),l="</span>"+l}),a=s+o+l}return""+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},o=[];Object.entries(i).forEach(function(n){var t=n[0],i=n[1],r=s.findTextMatchRange(e,t,y);if(r){for(var a=e.slice(r.start,r.end)!==t,l=i[0].highlightColor,d=1;d<i.length;d++)l=s.mixHexColors(l,i[d].highlightColor||"");o.push({highlight:t,start:r.start,end:r.end,badges:i,color:l,usedLooseMatch:a})}});var a=new Set(Object.keys(i));(m||[]).forEach(function(n){if(n){var t=F(n);if(t&&!a.has(t)){var i=s.findTextMatchRange(e,t,y);if(i){var r=e.slice(i.start,i.end)!==t,l=e.slice(0,i.start);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&o.push({highlight:t,start:i.start,end:i.end,badges:[],color:_||"",usedLooseMatch:r})}}}}),o.sort(function(n,e){return n.start-e.start||e.end-n.end});var d=[],c={};o.forEach(function(n,e){for(var t=n.start,i=n.end,r=0,o=d;r<o.length;r++){var a=o[r],s=a.start,l=a.end,u=t<l&&i>l&&t>=s,h=t<s&&i>s&&i<=l;if(t>=s&&i<=l){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=l),h&&(i=s)}n.trimmedStart=t,n.trimmedEnd=i,!n.orphaned&&t<i&&d.push({start:t,end:i,matchIdx:e})});var u={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],i=Number(e);u[t]||(u[t]=[]),u[t].push(i)});var h=o.map(function(e,t){return n.__assign(n.__assign({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,i;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(i=n.trimmedStart)&&void 0!==i?i:n.start)});return h.forEach(function(n){var t,i,a,l,d=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,c=null!==(i=n.trimmedEnd)&&void 0!==i?i:n.end;if(!(d>=c)){var h=e.slice(d,c),g=function(n,e,t,i){if(!t.length)return n;var a=t.map(function(n){return o[n]}).sort(function(n,e){return n.start-e.start}),l="",d=0;return a.forEach(function(t){var o,a,c=Math.max(d,t.start-e),u=Math.max(c,t.end-e);if(!(c>=u)){var h=s.mixHexColors(i,t.color||"");l+=n.slice(d,c),l+=r(n.slice(c,u),(null===(a=null===(o=t.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",h,t.badges||[]),d=u}}),l+=n.slice(d)}(n.usedLooseMatch||d!==n.start||c!==n.end?h:n.highlight,n.start,u[n.idx]||[],n.color),p=r(g,(null===(l=null===(a=n.badges)||void 0===a?void 0:a[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,d)+p+e.slice(c)}}),e},[l,p,m,_,y]),z=i.useMemo(function(){return d?F(d||""):""},[d]),A=!!d,W={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},q=n.__assign(n.__assign(n.__assign(n.__assign({},c),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),A?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}),I=n.__assign(n.__assign(n.__assign({},c),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return i.useLayoutEffect(function(){if(E.current){var n=function(){var n=Array.from(E.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),i=E.current.getBoundingClientRect(),r=i.bottom-4,o=i.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],i=[];e.forEach(function(n){if(0===i.length)i.push(n);else{var e=i[i.length-1],r=e.currentTop+e.height;n.naturalTop<r+8?(n.currentTop=r+8,i.push(n)):(t.push(i),i=[n])}}),i.length>0&&t.push(i),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>r){var i=t-r,a=n[0].currentTop-o,s=Math.max(0,Math.min(i,a));n.forEach(function(n){n.currentTop-=s})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(E.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[T,B,M]),e.jsxs(t.Box,n.__assign({ref:E,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[e.jsx(t.Typography,n.__assign({component:"div",sx:n.__assign(n.__assign({},q),{padding:"3px"})},{children:e.jsx(h.default,n.__assign({components:S,remarkPlugins:f,rehypePlugins:v},{children:T.replace(/#{3}/g,"")}))})),A&&e.jsx(t.Typography,n.__assign({component:"div",sx:I},{children:e.jsx(h.default,n.__assign({components:S,remarkPlugins:f,rehypePlugins:v},{children:z}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=x;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),t=require("@mui/material"),i=require("react"),r=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw"),d=require("remark-gfm");function c(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=c(i),h=c(a),g=c(l),p=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},f=[p(c(d).default)],v=[p(g.default)],x=u.default.memo(function(a){var l=a.content,d=a.overlayContent,c=a.sxStyles,g=a.deviationBadges,p=void 0===g?[]:g,x=a.highlights,m=void 0===x?[]:x;a.maintainRelativeOrder;var _=a.highlightBg,b=a.suppressHighlightBg,y=void 0!==b&&b,B=a.collisionKey,E=i.useRef(null),j=!!d,w=i.useMemo(function(){return p.reduce(function(e,t){var i;return n.__assign(n.__assign({},e),((i={})[t.id]=t,i))},{})},[p]),k=i.useRef({badgeMap:w,highlightBg:_,hideHighlightBg:j,suppressHighlightBg:y});k.current={badgeMap:w,highlightBg:_,hideHighlightBg:j,suppressHighlightBg:y};var C=function(e,t){return u.default.Children.map(e,function(e){var i;if(!u.default.isValidElement(e))return e;var r=(null===(i=e.props)||void 0===i?void 0:i.children)?C(e.props.children,t):e.props.children,o=u.default.cloneElement(e,n.__assign(n.__assign({},e.props),{children:r}));return t(o)})},S=i.useMemo(function(){return{mark:function(t){var i,r,o,a,s=t.children,l=n.__rest(t,["children"]),d=k.current,c=d.badgeMap,u=d.highlightBg,h=d.hideHighlightBg,g=d.suppressHighlightBg,p=l["data-badge-id"],f=p?c[p]:null,v=l["data-highlight-color"],x=null!==(a=null!==(r=null!=v?v:null===(i=null==f?void 0:f.style)||void 0===i?void 0:i.highlightBg)&&void 0!==r?r:null===(o=null==f?void 0:f.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:u,m="true"===l["data-is-suggested-deviation-fix"]||g;return e.jsx("span",n.__assign({style:n.__assign(n.__assign(n.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:s}))},span:function(i){var a,s,l,d,c,u,h=i.children,g=n.__rest(i,["children"]),p=k.current.badgeMap,f=g["data-badge-id"];if(!f)return e.jsx("span",n.__assign({},g,{children:h}));var v=p[f];if(!v)return e.jsx("span",n.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return e.jsxs(t.Box,n.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[e.jsxs(t.Box,n.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:n.__assign(n.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=v.style)||void 0===s?void 0:s.badgeText)||r.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=v.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[e.jsxs(t.Box,n.__assign({onClick:function(n){n.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[e.jsx(t.Box,n.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&e.jsx(t.Box,n.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&e.jsx(t.Box,n.__assign({onClick:function(n){n.stopPropagation(),v.onClick&&v.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:e.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:e.jsx(t.Box,n.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"thead"},{children:r}))},tbody:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"tbody"},{children:r}))},tr:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(i){var r=i.children;return e.jsx(t.Box,n.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(t){var i=t.children;return e.jsx("span",n.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:i}))},pre:function(t){var i=t.children;return e.jsx("span",n.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:i}))},updated:function(n){var t=n.children;return e.jsx(e.Fragment,{children:t})},deleted:function(t){var i=t.children,r=C(i,function(n){return u.default.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return e.jsx("span",n.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(t){var i=t.children,r=C(i,function(n){return u.default.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return e.jsx("span",n.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},o,{children:r}))},ol:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},o,{children:r}))},li:function(i){var r=i.children,o=n.__rest(i,["children"]);return e.jsx(t.Box,n.__assign({component:"li",sx:{mb:.5,display:"list-item"}},o,{children:r}))}}},[]),F=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,i){return"".concat(e," ").concat(i)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g," ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var i=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(i)?"\n":" "})}).join("")).trim()},M=i.useMemo(function(){return p.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[p]),T=i.useMemo(function(){var e=F(l||""),t=(p||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:F((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||_}}).filter(function(n){return n.id&&n.highlight}),i={};t.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var r=function(n,e,t,i){void 0===e&&(e=""),void 0===i&&(i=[]);var r=!1,o=function(n){var o=function(n,e,t){var i,r,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var s=null!==(i=a[1])&&void 0!==i?i:"",l=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return l?s+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",i=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(i).concat(t,">")}(e,t)+l+"</mark>"+d:n}(n,e,t),a=o;if(!r&&i.length>0){r=!0;var s="",l="";i.forEach(function(n){s+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),l="</span>"+l}),a=s+o+l}return""+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},o=[];Object.entries(i).forEach(function(n){var t=n[0],i=n[1],r=s.findTextMatchRange(e,t,y);if(r){for(var a=e.slice(r.start,r.end)!==t,l=i[0].highlightColor,d=1;d<i.length;d++)l=s.mixHexColors(l,i[d].highlightColor||"");o.push({highlight:t,start:r.start,end:r.end,badges:i,color:l,usedLooseMatch:a})}});var a=new Set(Object.keys(i));(m||[]).forEach(function(n){if(n){var t=F(n);if(t&&!a.has(t)){var i=s.findTextMatchRange(e,t,y);if(i){var r=e.slice(i.start,i.end)!==t,l=e.slice(0,i.start);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&o.push({highlight:t,start:i.start,end:i.end,badges:[],color:_||"",usedLooseMatch:r})}}}}),o.sort(function(n,e){return n.start-e.start||e.end-n.end});var d=[],c={};o.forEach(function(n,e){for(var t=n.start,i=n.end,r=0,o=d;r<o.length;r++){var a=o[r],s=a.start,l=a.end,u=t<l&&i>l&&t>=s,h=t<s&&i>s&&i<=l;if(t>=s&&i<=l){n.orphaned=!0,c[e]=a.matchIdx;break}u&&(t=l),h&&(i=s)}n.trimmedStart=t,n.trimmedEnd=i,!n.orphaned&&t<i&&d.push({start:t,end:i,matchIdx:e})});var u={};Object.entries(c).forEach(function(n){var e=n[0],t=n[1],i=Number(e);u[t]||(u[t]=[]),u[t].push(i)});var h=o.map(function(e,t){return n.__assign(n.__assign({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,i;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(i=n.trimmedStart)&&void 0!==i?i:n.start)});return h.forEach(function(n){var t,i,a,l,d=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,c=null!==(i=n.trimmedEnd)&&void 0!==i?i:n.end;if(!(d>=c)){var h=e.slice(d,c),g=function(n,e,t,i){if(!t.length)return n;var a=t.map(function(n){return o[n]}).sort(function(n,e){return n.start-e.start}),l="",d=0;return a.forEach(function(t){var o,a,c=Math.max(d,t.start-e),u=Math.max(c,t.end-e);if(!(c>=u)){var h=s.mixHexColors(i,t.color||"");l+=n.slice(d,c),l+=r(n.slice(c,u),(null===(a=null===(o=t.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",h,t.badges||[]),d=u}}),l+=n.slice(d)}(n.usedLooseMatch||d!==n.start||c!==n.end?h:n.highlight,n.start,u[n.idx]||[],n.color),p=r(g,(null===(l=null===(a=n.badges)||void 0===a?void 0:a[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,d)+p+e.slice(c)}}),e},[l,p,m,_,y]),z=i.useMemo(function(){return d?F(d||""):""},[d]),A=!!d,W={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},q=n.__assign(n.__assign(n.__assign(n.__assign({},c),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),A?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}),I=n.__assign(n.__assign(n.__assign({},c),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return i.useLayoutEffect(function(){if(E.current){var n=function(){var n=Array.from(E.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),i=E.current.getBoundingClientRect(),r=i.bottom-4,o=i.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],i=[];e.forEach(function(n){if(0===i.length)i.push(n);else{var e=i[i.length-1],r=e.currentTop+e.height;n.naturalTop<r+8?(n.currentTop=r+8,i.push(n)):(t.push(i),i=[n])}}),i.length>0&&t.push(i),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>r){var i=t-r,a=n[0].currentTop-o,s=Math.max(0,Math.min(i,a));n.forEach(function(n){n.currentTop-=s})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(E.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[T,B,M]),e.jsxs(t.Box,n.__assign({ref:E,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[e.jsx(t.Typography,n.__assign({component:"div",sx:n.__assign(n.__assign({},q),{padding:"3px"})},{children:e.jsx(h.default,n.__assign({components:S,remarkPlugins:f,rehypePlugins:v},{children:T.replace(/#{3}/g,"")}))})),A&&e.jsx(t.Typography,n.__assign({component:"div",sx:I},{children:e.jsx(h.default,n.__assign({components:S,remarkPlugins:f,rehypePlugins:v},{children:z}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=x;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i=require("../utils/buildComparisonRows.js"),o={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(r,a,s,l,d,u){var v,c;void 0===d&&(d=!0);var f="string"==typeof s?s:JSON.stringify(s||{}),p=Boolean(u&&(u.learnings_data||(null===(c=null===(v=u.data)||void 0===v?void 0:v.artifactData)||void 0===c?void 0:c.userStorySnapshot))),_=e.useMemo(function(){if(!r||0===Object.keys(r).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var e=JSON.parse(f);try{var o=r.nodes||r,s=[],l=[],v=[],c=r.base_root_id,_=r.input_index_map||{0:"left",1:"right"},I=r[c]||o[c];if(!I||!1===I.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var g=r.content_mapping||{},h=function(n){return r[n]||o[n]},m=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),s={},l={},u=null;return a.forEach(function(n){var r,a,d,v,c,f,p,I=e[n];if(I&&"object"==typeof I){u||(u=I);var g="same"===t.safeStringify(null===(a=null==I?void 0:I.evaluation_outputs)||void 0===a?void 0:a.output_value).trim().toLowerCase(),h=!((null==I?void 0:I.status)&&"pending"!==I.status||g),m=(null==I?void 0:I.deviation_highlight)||(null===(d=null==I?void 0:I.web_search_answer)||void 0===d?void 0:d.deviation_highlight),y=function(n){var e,t=(null===(e=null==I?void 0:I.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==I?void 0:I.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},b=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},x=h?b((null===(v=null==I?void 0:I.deviation_highlights)||void 0===v?void 0:v[i])||(null===(c=null==I?void 0:I.deviation_highlights)||void 0===c?void 0:c[_[0]]),"string"==typeof m?[m]:[],y(i),y(_[0])):[],R=h?b((null===(f=null==I?void 0:I.deviation_highlights)||void 0===f?void 0:f[o])||(null===(p=null==I?void 0:I.deviation_highlights)||void 0===p?void 0:p[_[1]]),y(o),y(_[1])):[];s[n]=((r={})[_[0]]=x[0]||"",r[_[1]]=R[0]||"",r.deviation_summary=(null==I?void 0:I.deviation_summary)||"",r.deviation_title=null==I?void 0:I.deviation_title,r.deviation_impact=null==I?void 0:I.deviation_impact,r.deviation_explanation=null==I?void 0:I.deviation_explanation,r.evaluation_outputs=null==I?void 0:I.evaluation_outputs,r.cognitive_decisioning=null==I?void 0:I.cognitive_decisioning,r.deviation_highlights=null==I?void 0:I.deviation_highlights,r),l[n]=I}}),n.__assign(n.__assign({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:l})},y=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,l=n;s<l.length;s++){a(l[s])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},b=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=_[0],i=_[1];return e.length>0&&(t=e.includes(_[0])?_[0]:e[0],i=e.includes(_[1])?_[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},l=!1!==a.display_title,d=!1!==a.display_content,u=l?t.safeStringify(s.title||""):"",v=d?t.safeStringify(s.content||""):"",c=d?t.safeStringify(s.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:l,displayContent:d,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},R=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},C=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},S=function(i,o){var r,a=h(i);if(!a||!1===a.display_node)return[];if(p&&"1"===o)return[];var s=b(a),l=s.nodeLeftId,d=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==e?void 0:e[i])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=m(v,l,d),f=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:i}):c,I=t.resolveComparisonInputItems(a,o,_,g).map(function(n){return x(i,n,f,u)});if(a.next){var y=Object.values(a.next).flatMap(function(n){return S(n,o)});I.forEach(function(n){var e=y.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:y})}return I};if(a){var E=function(i,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!i)return{refSections:a,baseSections:s};var l={},d={},u=-1,v=-1,c=function(a){var s=i[a],c=h(s);if(!c||!1===c.display_node)return"continue";var f=b(c),I=f.nodeLeftId,y=f.nodeRightId,C=t.getRationale(c),S=(null===(r=null==e?void 0:e[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=m(S,I,y),j=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,N=E(c.next,o+1),w=N.refSections,A=N.baseSections,D=t.resolveComparisonInputItems(c,"0",_,g).map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),k=[];if(!p){var M=t.resolveComparisonInputItems(c,"1",_,g);k=M.map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}D.forEach(function(n){k.forEach(function(e){var t,i,o,r,a,s,l,d;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(l=n.refContentIds)||void 0===l?void 0:l.includes(e.contentId))&&(null===(d=n.refContentIds)||void 0===d||d.push(e.contentId))})}),k.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?R(l[t],n):n}),D.forEach(function(n){var e=A.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?R(d[t],n):n})};for(var f in i)c(f);return a=Object.values(l),s=Object.values(d),a.sort(C),s.sort(C),{refSections:a,baseSections:s}},O=E(I.next),j=O.refSections,N=O.baseSections;p||(l=y(j)),s=N}else I.next&&Object.values(I.next).forEach(function(n){var e=h(n);if(e&&!1!==e.display_node){var t=S(n,"0");if(p)s.push.apply(s,t);else{var o=y(S(n,"1"));v.push.apply(v,i.buildComparisonRows(n,t,o))}}}),p||(s=v.map(function(n){return n.left}),l=v.map(function(n){return n.right}));var w=t.getSideData(I,"0",_,g),A=t.getSideData(I,"1",_,g),D={title:w.title||"Uploaded Contract",description:I.decision_scope_description||"",sections:s},k={id:"tree-variant-1",title:p?function(){var n,e;if((null==u?void 0:u.learnings_data)&&Object.keys(u.learnings_data).length>0){var t=Object.keys(u.learnings_data)[0];return(null===(n=u.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return(null===(e=null==u?void 0:u.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():A.title||"Reference Template",similarity:0,sections:l,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:I.decision_scope_description||""},fields:{}}}};return{activeProposed:D,activeVariants:[k],comparisonRows:v,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[r,a,f,d,u]),I=_.activeProposed,g=_.activeVariants,h=_.comparisonRows,m=_.parseError,y=(null==g?void 0:g[0])||o,b=e.useMemo(function(){return(null==I?void 0:I.sections)||[]},[null==I?void 0:I.sections]),x=e.useMemo(function(){return y.sections||[]},[y.sections]),R=b.length>0||x.length>0,C=e.useMemo(function(){return l.fields.filter(function(n){var e=n.key;return(!R||"description"!==e)&&(t.hasValue(null==I?void 0:I[e])||t.hasValue(y[e]))})},[I,y,R,l.fields]),S=e.useMemo(function(){var n,e,i={},o={},s={},l=0,d=null===(n=null==r?void 0:r.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==r?void 0:r.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!a){var t="left"===e?b.indexOf(n):x.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:b.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,s=b.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(s){var l=s.selfIndex,d=void 0!==l&&l>=0?l+1:b.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:d}}var u=void 0!==r&&r>=0?r+1:x.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},f=function(n,e,r,a,v,p,_){if(e&&function(n,e,i){var r;((null===(r=null==n?void 0:n.evaluationResults)||void 0===r?void 0:r.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(r){var a=(null==r?void 0:r.deviations)||{};Object.keys(a).sort().forEach(function(l){var v=a[l];if(v){var c=!t.isMissingStr(v[d]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==r?void 0:r.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(l);void 0===o[_]&&(void 0===s[e]&&(s[e]=1),o[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,a,v),e&&!p){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(l++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==r?void 0:r.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),o=c(null==r?void 0:r.subsections,t);f(t,i,o,a,v,!1,e||_)})};b.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(a){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=x.find(function(n){return n.selfIndex===s})}else r=x[b.indexOf(n)];f(n,n,r,i,o,!0,n)}),p||x.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&f(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:_,deviationParentRegistry:I}},[b,x,a,r,p]),E=S.parentDeviationRecord,O=S.registry,j=S.deviationParentRegistry;return{isGuidelineMode:p,activeProposed:I,activeVariants:g,comparisonRows:h,existingRule:y,proposedSections:b,existingSections:x,visibleFields:C,parentDeviationRecord:E,deviationNumberRegistry:O,deviationParentRegistry:j,parseError:m}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i=require("../utils/buildComparisonRows.js"),o={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(r,a,s,l,d,u,v){void 0===d&&(d=!0);var c="string"==typeof s?s:JSON.stringify(s||{}),f=Boolean(v),p=e.useMemo(function(){if(!r||0===Object.keys(r).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var e=JSON.parse(c);try{var o=r.nodes||r,s=[],l=[],v=[],p=r.base_root_id,_=r.input_index_map||{0:"left",1:"right"},I=r[p]||o[p];if(!I||!1===I.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var g=r.content_mapping||{},h=function(n){return r[n]||o[n]},m=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),s={},l={},u=null;return a.forEach(function(n){var r,a,d,v,c,f,p,I=e[n];if(I&&"object"==typeof I){u||(u=I);var g="same"===t.safeStringify(null===(a=null==I?void 0:I.evaluation_outputs)||void 0===a?void 0:a.output_value).trim().toLowerCase(),h=!((null==I?void 0:I.status)&&"pending"!==I.status||g),m=(null==I?void 0:I.deviation_highlight)||(null===(d=null==I?void 0:I.web_search_answer)||void 0===d?void 0:d.deviation_highlight),y=function(n){var e,t=(null===(e=null==I?void 0:I.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==I?void 0:I.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},b=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},x=h?b((null===(v=null==I?void 0:I.deviation_highlights)||void 0===v?void 0:v[i])||(null===(c=null==I?void 0:I.deviation_highlights)||void 0===c?void 0:c[_[0]]),"string"==typeof m?[m]:[],y(i),y(_[0])):[],R=h?b((null===(f=null==I?void 0:I.deviation_highlights)||void 0===f?void 0:f[o])||(null===(p=null==I?void 0:I.deviation_highlights)||void 0===p?void 0:p[_[1]]),y(o),y(_[1])):[];s[n]=((r={})[_[0]]=x[0]||"",r[_[1]]=R[0]||"",r.deviation_summary=(null==I?void 0:I.deviation_summary)||"",r.deviation_title=null==I?void 0:I.deviation_title,r.deviation_impact=null==I?void 0:I.deviation_impact,r.deviation_explanation=null==I?void 0:I.deviation_explanation,r.evaluation_outputs=null==I?void 0:I.evaluation_outputs,r.cognitive_decisioning=null==I?void 0:I.cognitive_decisioning,r.deviation_highlights=null==I?void 0:I.deviation_highlights,r),l[n]=I}}),n.__assign(n.__assign({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:l})},y=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,l=n;s<l.length;s++){a(l[s])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},b=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=_[0],i=_[1];return e.length>0&&(t=e.includes(_[0])?_[0]:e[0],i=e.includes(_[1])?_[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},l=!1!==a.display_title,d=!1!==a.display_content,u=l?t.safeStringify(s.title||""):"",v=d?t.safeStringify(s.content||""):"",c=d?t.safeStringify(s.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:l,displayContent:d,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},R=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},C=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},E=function(i,o){var r,a=h(i);if(!a||!1===a.display_node)return[];if(f&&"1"===o)return[];var s=b(a),l=s.nodeLeftId,d=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==e?void 0:e[i])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=m(v,l,d),p=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:i}):c,I=t.resolveComparisonInputItems(a,o,_,g).map(function(n){return x(i,n,p,u)});if(a.next){var y=Object.values(a.next).flatMap(function(n){return E(n,o)});I.forEach(function(n){var e=y.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:y})}return I};if(a){var S=function(i,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!i)return{refSections:a,baseSections:s};var l={},d={},u=-1,v=-1,c=function(a){var s=i[a],c=h(s);if(!c||!1===c.display_node)return"continue";var p=b(c),I=p.nodeLeftId,y=p.nodeRightId,C=t.getRationale(c),E=(null===(r=null==e?void 0:e[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=m(E,I,y),j=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,N=S(c.next,o+1),w=N.refSections,A=N.baseSections,D=t.resolveComparisonInputItems(c,"0",_,g).map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),k=[];if(!f){var M=t.resolveComparisonInputItems(c,"1",_,g);k=M.map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}D.forEach(function(n){k.forEach(function(e){var t,i,o,r,a,s,l,d;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(l=n.refContentIds)||void 0===l?void 0:l.includes(e.contentId))&&(null===(d=n.refContentIds)||void 0===d||d.push(e.contentId))})}),k.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?R(l[t],n):n}),D.forEach(function(n){var e=A.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?R(d[t],n):n})};for(var p in i)c(p);return a=Object.values(l),s=Object.values(d),a.sort(C),s.sort(C),{refSections:a,baseSections:s}},O=S(I.next),j=O.refSections,N=O.baseSections;f||(l=y(j)),s=N}else I.next&&Object.values(I.next).forEach(function(n){var e=h(n);if(e&&!1!==e.display_node){var t=E(n,"0");if(f)s.push.apply(s,t);else{var o=y(E(n,"1"));v.push.apply(v,i.buildComparisonRows(n,t,o))}}}),f||(s=v.map(function(n){return n.left}),l=v.map(function(n){return n.right}));var w=t.getSideData(I,"0",_,g),A=t.getSideData(I,"1",_,g),D={title:w.title||"Uploaded Contract",description:I.decision_scope_description||"",sections:s},k={id:"tree-variant-1",title:f?function(){var n,e;if((null==u?void 0:u.learnings_data)&&Object.keys(u.learnings_data).length>0){var t=Object.keys(u.learnings_data)[0];return(null===(n=u.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return(null===(e=null==u?void 0:u.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():A.title||"Reference Template",similarity:0,sections:l,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:I.decision_scope_description||""},fields:{}}}};return{activeProposed:D,activeVariants:[k],comparisonRows:v,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[r,a,c,d,u]),_=p.activeProposed,I=p.activeVariants,g=p.comparisonRows,h=p.parseError,m=(null==I?void 0:I[0])||o,y=e.useMemo(function(){return(null==_?void 0:_.sections)||[]},[null==_?void 0:_.sections]),b=e.useMemo(function(){return m.sections||[]},[m.sections]),x=y.length>0||b.length>0,R=e.useMemo(function(){return l.fields.filter(function(n){var e=n.key;return(!x||"description"!==e)&&(t.hasValue(null==_?void 0:_[e])||t.hasValue(m[e]))})},[_,m,x,l.fields]),C=e.useMemo(function(){var n,e,i={},o={},s={},l=0,d=null===(n=null==r?void 0:r.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==r?void 0:r.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!a){var t="left"===e?y.indexOf(n):b.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:y.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,s=y.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(s){var l=s.selfIndex,d=void 0!==l&&l>=0?l+1:y.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:d}}var u=void 0!==r&&r>=0?r+1:b.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,r,a,v,f,_){if(e&&function(n,e,i){var r;((null===(r=null==n?void 0:n.evaluationResults)||void 0===r?void 0:r.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(r){var a=(null==r?void 0:r.deviations)||{};Object.keys(a).sort().forEach(function(l){var v=a[l];if(v){var c=!t.isMissingStr(v[d]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==r?void 0:r.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(l);void 0===o[_]&&(void 0===s[e]&&(s[e]=1),o[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,a,v),e&&!f){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(l++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==r?void 0:r.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),o=c(null==r?void 0:r.subsections,t);p(t,i,o,a,v,!1,e||_)})};y.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(a){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=b.find(function(n){return n.selfIndex===s})}else r=b[y.indexOf(n)];p(n,n,r,i,o,!0,n)}),f||b.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:_,deviationParentRegistry:I}},[y,b,a,r,f]),E=C.parentDeviationRecord,S=C.registry,O=C.deviationParentRegistry;return{isGuidelineMode:f,activeProposed:_,activeVariants:I,comparisonRows:g,existingRule:m,proposedSections:y,existingSections:b,visibleFields:R,parentDeviationRecord:E,deviationNumberRegistry:S,deviationParentRegistry:O,parseError:h}};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as k,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as G}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";var oe=function(oe){var re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,De,ke,Oe,Pe,je,Le,Ne,Me,He=oe.componentHeaderText,ze=void 0===He?P:He,We=oe.treeData,qe=oe.comparisonConfig,Ge=oe.leftColumnTitleText,Ve=oe.rightColumnTitleText,Ke=oe.markdownStyles,Je=oe.resetTrigger,Ye=oe.displayConfig,Xe=void 0===Ye?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ye,$e=oe.onMaintainRelativeOrderChange,Ue=oe.popupConfig,Qe=oe.deviationData,Ze=void 0===Qe?{}:Qe,en=oe.deviationNodeIdToView,nn=oe.resetDeviationNodeId,tn=oe.isProposingFix,on=void 0!==tn&&tn,rn=oe.proposingFixNodeId,ln=oe.isRedlineFlow,un=oe.badgeStyleOverride,cn=oe.guidelinesData,an=oe.gptWebCitationConfig,sn=l(Xe.maintainRelativeOrder),dn=sn[0],vn=sn[1],fn=null!==(re=null==Xe?void 0:Xe.expandLevels)&&void 0!==re?re:0,pn=!!(null==Xe?void 0:Xe.expandAllSections),gn=!!dn||!!(null==Xe?void 0:Xe.showDeviationBadges),hn=l(!1),mn=hn[0],Sn=hn[1],xn=l(null),Rn=xn[0],bn=xn[1],yn=l(null===(ue=null!==(le=null==We?void 0:We.newEvaluationResult)&&void 0!==le?le:null==Xe?void 0:Xe.enableDeviationSchemaBackwardCompatibility)||void 0===ue||ue)[0],Cn=l(new Set),wn=Cn[0],Bn=Cn[1],_n=l([]),In=_n[0],Fn=_n[1],Tn=l(!1),En=Tn[0],An=Tn[1],Dn=l(0),kn=Dn[0],On=Dn[1],Pn=u(null),jn=u(null),Ln=u(null),Nn=u(null),Mn=u(null),Hn=u(!1),zn=u(null),Wn=u({}),qn=u([]),Gn=u(function(){}),Vn=u(null),Kn=u(function(){}),Jn=c(function(){return JSON.stringify(Ze||{})},[JSON.stringify(Ze)]),Yn=c(function(){return Ze||{}},[Jn]),Xn=c(function(){return(null==We?void 0:We.cognitive_decisioning)||{}},[We]),$n=c(function(){return e(e({},E),Ke)},[Ke]),Un=u(null),Qn=u(null),Zn=u(null),ei=u(null),ni=u(null),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=z(Un),ci=ui.cognitivePopup,ai=ui.setCognitivePopup,si=ui.moreFunctions,di=ui.setMoreFunctions,vi=ui.position,fi=ui.setPosition,pi=ui.activeBadgeId,gi=ui.summaryPopup,hi=ui.setSummaryPopup,mi=ui.closeSummaryPopup,Si=ui.setActiveBadgeId,xi=ui.popupRef,Ri=ui.handleOpenCognitiveCompare,bi=ui.openCognitivePopupFromState,yi=ui.closeCognitivePopup,Ci=ui.closeMoreFunctionsPopup,wi=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==qe?void 0:qe.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==qe?void 0:qe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(t=null==qe?void 0:qe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==qe?void 0:qe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[qe]),Bi=l(null),_i=Bi[0];Bi[1];var Ii=null===(se=null===(ce=null==We?void 0:We.documents)||void 0===ce?void 0:ce[null===(ae=null==We?void 0:We.input_index_map)||void 0===ae?void 0:ae[0]])||void 0===se?void 0:se.title,Fi=null===(fe=null===(de=null==We?void 0:We.documents)||void 0===de?void 0:de[null===(ve=null==We?void 0:We.input_index_map)||void 0===ve?void 0:ve[1]])||void 0===fe?void 0:fe.title,Ti=b(Ge||Ii||"Uploaded Contract"),Ei=null===(me=null===(he=null===(pe=null==We?void 0:We.documents)||void 0===pe?void 0:pe[null===(ge=null==We?void 0:We.input_index_map)||void 0===ge?void 0:ge[0]])||void 0===he?void 0:he.metadata)||void 0===me?void 0:me.file_name,Ai=b(Ei),Di=null===(be=null===(Re=null===(Se=null==We?void 0:We.documents)||void 0===Se?void 0:Se[null===(xe=null==We?void 0:We.input_index_map)||void 0===xe?void 0:xe[1]])||void 0===Re?void 0:Re.metadata)||void 0===be?void 0:be.file_name,ki=b(Di),Oi=b(Ve||Fi||"Reference Template"),Pi=H(We,dn,Yn,wi,yn,cn),ji=Pi.isGuidelineMode,Li=Pi.activeProposed,Ni=Pi.existingRule,Mi=Pi.proposedSections,Hi=Pi.existingSections,zi=Pi.visibleFields,Wi=Pi.parentDeviationRecord,qi=Pi.deviationNumberRegistry,Gi=Pi.deviationParentRegistry,Vi=Pi.parseError;a(function(){Vi&&bn("Failed to load comparison: ".concat(Vi))},[Vi]);var Ki=Mi.length>0||Hi.length>0,Ji=c(function(){if(!ln)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";_(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(Mi),i(Hi),"".concat(e,":").concat(n)},[ln,Mi,Hi]);a(function(){if(Mi.length||Hi.length)if(pn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=dn?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(Mi,"left"),i(Hi,"right"),Tt(e),At(n)}else if(fn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=dn?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(Mi,"left",fn),r(Hi,"right",fn),Tt(t),At(o)}},[pn,fn,Mi,Hi,dn]);var Yi=W(zi.map(function(e){return e.key}),Math.max(Mi.length,Hi.length)),Xi=Yi.leftRefs,$i=Yi.rightRefs,Ui=Yi.sectionLeftRefs,Qi=Yi.sectionRightRefs,Zi=Yi.lhsBadgeRefs,et=Yi.rhsBadgeRefs,nt=Yi.sectionRightRowRefs,it=Yi.subSectionLeftRefs,tt=Yi.subSectionRightRefs,ot=Yi.sectionRowRefs,rt=Yi.getSectionRowRef,lt=Yi.getSubSectionRef,ut=Yi.getBadgeRef,ct=ee({isGuidelineMode:ji,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,leftContainerRef:oi,rightContainerRef:Zn,scrollContainerRef:Un,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,sectionRowRefs:ot,sectionRightRowRefs:nt,rhsTopSpacerRef:ei,rhsBottomSpacerRef:ni,lhsTopSpacerRef:ii,lhsBottomSpacerRef:ti,calculateLinesRef:Gn,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,closeMoreFunctionsPopup:Ci,setErrorToast:bn,moreFunctions:si,closeSummaryPopup:mi}),at=ct.isSideBySide,st=ct.isArrowVisible,dt=ct.setIsArrowVisible,vt=ct.isResizing,ft=ct.setIsResizing,pt=ct.isSideBySideLoading,gt=ct.activeSideBySideSection,ht=ct.scrollLock,mt=ct.sideBySideCacheRef,St=ct.isSideBySideRef,xt=ct.activeSideBySideRightSectionRef,Rt=ct.activeSideBySideSectionRef,bt=ct.sideBySideLineRef,yt=ct.highlightedClauseRefs,Ct=ct.clearClauseHighlight,wt=ct.resetSideBySide,Bt=ct.activateSideBySide,_t=u(Bt);a(function(){_t.current=Bt},[Bt]);var It=q({maintainRelativeOrder:!!dn,proposedSections:Mi,existingSections:Hi,activeSideBySideSection:gt,connectedSections:wn,resetSideBySide:wt,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,svgContainerRef:Pn,isAnimatingRef:Hn,animationTimerRef:zn,calculateLinesRef:Gn,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt}),Ft=It.expandedSections,Tt=It.setExpandedSections,Et=It.expandedSubSections,At=It.setExpandedSubSections,Dt=It.handleSubSectionToggle,kt=It.toggleSection,Ot=It.forceExpandCrossWiredSections,Pt=function(){var e,n;if(null!=gt){var i=null===(e=Ui.current[gt])||void 0===e?void 0:e.current,t=null===(n=Qi.current[gt])||void 0===n?void 0:n.current,o=Zn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},jt=s(function(e){null==e||e.stopPropagation(),An(function(e){var n=!e;return n&&requestAnimationFrame(function(){Pt()}),n})},[Pt]);a(function(){ln&&"off"!==Ji&&"0:0"!==Ji&&(mt.current=null,qn.current=[],requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)}))},[ln,Ji]);var Lt=c(function(){var e=new Map,n=new Map,i=1;if(dn)Mi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Hi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Mi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(Mi.length,Hi.length),o=0;o<t;o++){var r=Mi[o],l=Hi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[Mi,Hi,dn]),Nt=Ni.analysis,Mt=b(null===(Ce=null===(ye=null==Nt?void 0:Nt.rule_difference_comparison)||void 0===ye?void 0:ye.summary)||void 0===Ce?void 0:Ce.overall_summary),Ht=!!Mt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),zt=null!==(we=null==We?void 0:We.base_root_id)&&void 0!==we?we:"-1";null==We||We[zt];var Wt=yn?null!==(je=null!==(ke=Ze&&(null===(De=null==Ze?void 0:Ze[zt])||void 0===De?void 0:De.evaluation_result))&&void 0!==ke?ke:null===(Pe=null===(Oe=null==We?void 0:We.nodes)||void 0===Oe?void 0:Oe[zt])||void 0===Pe?void 0:Pe.evaluation_result)&&void 0!==je?je:null:null!==(Ae=null!==(Ie=Ze&&(null===(_e=null===(Be=null==Ze?void 0:Ze[zt])||void 0===Be?void 0:Be.evaluation_result)||void 0===_e?void 0:_e[0]))&&void 0!==Ie?Ie:null===(Ee=null===(Te=null===(Fe=null==We?void 0:We.nodes)||void 0===Fe?void 0:Fe[zt])||void 0===Te?void 0:Te.evaluation_result)||void 0===Ee?void 0:Ee[0])&&void 0!==Ae?Ae:null,qt=y(Wt),Gt=C(null!==(Me=null===(Ne=null===(Le=null==Wt?void 0:Wt.evaluation_outputs)||void 0===Le?void 0:Le.metadata)||void 0===Ne?void 0:Ne.label_color)&&void 0!==Me?Me:k);if(un){var Vt=un(qt);Vt&&(Gt=e(e({},Gt),{badgeBg:Vt.bg,badgeText:Vt.text,badgeBorder:Vt.border}))}var Kt=u(wt);a(function(){Kt.current=wt},[wt]);var Jt=u(yi);a(function(){Jt.current=yi},[yi]);var Yt=s(function(e,n,i,t,o,r){return rr.current(e,n,i,t,o,r)},[]),Xt=s(function(e,n,i,t,o){return ur.current(e,n,i,t,o)},[]),$t=s(function(){return cr.current()},[]),Ut=s(function(e,n){return ar.current(e,n)},[]),Qt=s(function(e){return sr.current(e)},[]),Zt=s(function(e){return dr.current(e)},[]),eo=s(function(){return vr.current()},[]),no=s(function(){var e,n;Ct(),null===(e=Kt.current)||void 0===e||e.call(Kt),An(!1),Bn(new Set),Fn([]),qn.current=[],Bo([]),Io(null),hi(O),null===(n=Jt.current)||void 0===n||n.call(Jt),requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)})},[]),io=u(no);a(function(){io.current=no},[no]),a(function(){Je&&io.current()},[Je]);var to=c(function(){return{documents:null==We?void 0:We.documents,input_index_map:null==We?void 0:We.input_index_map}},[JSON.stringify(null==We?void 0:We.documents),JSON.stringify(null==We?void 0:We.input_index_map)]),oo=l(""),ro=oo[0],lo=oo[1],uo=b(Fi),co=u(We);a(function(){var e,n,i;co.current=We;var t=null===(e=null==We?void 0:We.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==We?void 0:We.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;lo(o)},[We]);var ao=u(Xn);a(function(){ao.current=Xn},[Xn]);var so=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=ao.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},R=null!==(s=null===(a=ot.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(B)))return u(l);var c=o.split(B)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(d=null==y?void 0:y.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==Xe?void 0:Xe.isLoading)&&void 0!==m&&m,_=!0;if(ji){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:to,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[to,null==Xe?void 0:Xe.isLoading,ji]),vo=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),si.open&&si.sectionIdx===o)Ci();else{var u=e.currentTarget,c="left";(null===(l=Zn.current)||void 0===l?void 0:l.contains(u))&&(c="right");Ct(),St.current&&wt(),Bn(new Set),Fn([]),qn.current=[],yi(),gi.open?Ho():mi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=et.current[l])||void 0===e?void 0:e.current:null===(n=Zi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=et.current[o])||void 0===i?void 0:i.current:null===(t=Zi.current[o])||void 0===t?void 0:t.current}()||u;di(so(e,n,t,o,i,r))})}},[si.open,si.sectionIdx,Ci,mi,so]),fo=s(function(){var e=si.sectionIdx;si.isOrphan,Ci(),mi(),null!==e&&(Ot(e),Ct(),St.current&&wt(),Fn([]),qn.current=[],ji&&null!==e&&On(Lo(e)),Bn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Gn.current&&Gn.current()},50))},[si.sectionIdx,si.isOrphan,Ci,mi,wt]),po=s(function(){var e=Mn.current;if(e){Mn.current=null;var n=Mi.findIndex(function(n){return n.id===e}),i=Hi.findIndex(function(n){return n.id===e}),t=-1===n?w(Mi,e):null,o=-1===i?w(Hi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(yt.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(dn)-1!==r&&oi.current&&c(function(){return u(n,t,Ui,it)},oi.current),-1!==l&&Zn.current&&c(function(){return u(i,o,Qi,tt)},Zn.current);else{var a=Un.current;if(!a)return;c(function(){return-1!==r?u(n,t,Ui,it):u(i,o,Qi,tt)},a)}}},[Mi,Hi,dn,Ui,Qi,it,tt,oi,Zn,Un]),go=s(function(n){if(n){Ct(),wt(),Bn(new Set),Fn([]),qn.current=[],mi(),yi();var i=Mi.findIndex(function(e){return e.id===n}),t=Hi.findIndex(function(e){return e.id===n}),o=-1===i?w(Mi,n):null,r=-1===t?w(Hi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;Mn.current=n,Tt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=dn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=dn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),At(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){Mn.current===n&&ho.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Mi,Hi,dn,Tt,At,wt,mi,yi]),ho=u(po);a(function(){ho.current=po},[po]);var mo=u(null);a(function(){if(_i){var e=wi.fields.find(function(e){return e.analysisKey===_i||e.key===_i});if(e){var n=Xi.current[e.key]||$i.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[_i,wi.fields]);var So=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Nt?void 0:Nt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Nt]),xo=U({proposedSections:Mi,existingSections:Hi,maintainRelativeOrder:dn,cognitiveMap:Xn,deviationData:Yn,treeData:We,resolvedComparisonConfig:wi,badgeStyleOverride:un}),Ro=xo.getSectionCompareStyle,bo=xo.getSubSectionCompareStyle,yo=xo.getDeviationStyleByKey,Co=Z({containerRef:jn,leftContainerRef:oi,rightContainerRef:Zn,svgContainerRef:Pn,pathRefs:Wn,leftHeaderRef:Ln,rightHeaderRef:Nn,proposedSections:Mi,existingSections:Hi,visibleFields:zi,leftRefs:Xi,rightRefs:$i,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,sectionRowRefs:ot,expandedSections:Ft,expandedSubSections:Et,connectedSections:wn,isSideBySide:at,activeSideBySideSection:gt,maintainRelativeOrder:dn,isGuidelineMode:ji,cognitiveMap:Xn,getSectionCompareStyle:Ro,getSubSectionCompareStyle:bo,getDeviationStyleByKey:yo,isArrowVisible:st,isAnimatingRef:Hn,isSideBySideRef:St,sideBySideCacheRef:mt,sideBySideLineRef:bt,activeSideBySideSectionRef:Rt,activeSideBySideRightSectionRef:xt,connectedLines:In,setConnectedLines:Fn,cachedConnectedPositions:qn,calculateLinesRef:Gn,resizeTimerRef:Vn,scrollLock:ht,scrollSyncLocked:En,handleResizeRef:Kn,activeProposed:Li,existingRule:Ni,analysisData:Nt,pendingScrollTargetRef:ri,pendingScrollCallbackRef:li,resolvedComparisonConfig:wi,getFieldData:So}),wo=Co.lines,Bo=Co.setLines,_o=Co.overallConnector,Io=Co.setOverallConnector,Fo=Co.svgDimensions,To=Co.handleColumnScroll;a(function(){gi.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Gn.current)||void 0===e||e.call(Gn)})})},[gi.anchorEl,En]);var Eo=s(function(){Ct(),An(!1),Tt({}),At({}),wt(),Bn(new Set),Fn([]),qn.current=[],mi(),yi(),Ci(),requestAnimationFrame(function(){Gn.current&&Gn.current()})},[Tt,At,wt,mi,yi,Ci]);a(function(){at||0!==wn.size||An(!1)},[at,wn]);var Ao=c(function(){return Object.values(Ft).some(Boolean)||Object.values(Et).some(Boolean)},[Ft,Et]),Do=u(null),ko=u(0),Oo=u(0),Po=u(0),jo=Q({timerRef:Do,ruleComponentRef:Qn,scrollContainerRef:Un,containerRef:jn,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,isSideBySideRef:St,activeSideBySideSectionRef:Rt,activeSideBySideRightSectionRef:xt,sectionRowRefs:ot,sectionRightRowRefs:nt,sectionLeftRefs:Ui,sectionRightRefs:Qi,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,leftContainerRef:oi,rightContainerRef:Zn,calculateLinesRef:Gn,handleResizeRef:Kn,setIsResizing:ft,setIsArrowVisible:dt,sideBySideCacheRef:mt,cachedConnectedPositions:qn}).handleResize;a(function(){Kn.current=jo},[jo,Kn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Qn.current&&o.push(e(Qn.current,ko,n,function(){return Kn.current()},function(){})),Un.current&&o.push(e(Un.current,Oo,i,function(){return Kn.current()},function(){return Gn.current()})),jn.current&&o.push(e(jn.current,Po,t,function(){return Kn.current()},function(){return Gn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){St.current=at},[at]),a(function(){Rt.current=gt},[gt]);var Lo=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=Mi[e])||void 0===n?void 0:n.nodeId)||(null===(i=Mi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==Yn?void 0:Yn[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[Mi,Yn]),No=s(function(e){var n,i,t=oi.current,o=Zn.current;if(o){var r=o.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),l=Array.from(r).filter(function(e){var n=e.getBoundingClientRect();return n.width>0&&n.height>0}),u="string"==typeof e&&e.includes(B),c=e;if(u){var a=e.split(B);a.length>=2&&(c="".concat(a[0]).concat(B).concat(a[1]))}var s=(null===(n=Zi.current[c])||void 0===n?void 0:n.current)||(null===(i=Zi.current[e])||void 0===i?void 0:i.current);if(l.length>0&&s&&t&&o){var d=l[0];ii.current&&(ii.current.style.height="0px"),ei.current&&(ei.current.style.height="0px"),ti.current&&(ti.current.style.height="0px"),ni.current&&(ni.current.style.height="0px"),requestAnimationFrame(function(){var e=s.getBoundingClientRect(),n=d.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,c=l-i.height/2,a=Math.max(0,c),v=t.scrollHeight-t.clientHeight,f=a>v?a-v:0,p=i.top+l-a,g=r.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=o.scrollHeight-o.clientHeight+h,S=g>m?g-m:0;ti.current&&(ti.current.style.height="".concat(f,"px")),ei.current&&(ei.current.style.height="".concat(h,"px")),ni.current&&(ni.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:a,behavior:"smooth"}),o.scrollTo({top:g,behavior:"smooth"}),Gn.current&&setTimeout(function(){return Gn.current()},50)})})}}},[B]),Mo=s(function(){var e,n=si.sectionIdx,i=si.isOrphan;if(mi(),null!=n){var t="left";si.anchorEl&&(null===(e=Zn.current)||void 0===e?void 0:e.contains(si.anchorEl))&&(t="right"),Ot(n),ji&&(On(Lo(n)),Bn(new Set([n]))),Bt(n,i,{sourceSide:t,onReady:function(){ji&&setTimeout(function(){return No(String(n))},150)}})}},[Bt,si.isOrphan,si.sectionIdx,si.anchorEl,mi,Ot,ji,No,Lo]),Ho=s(function(){mi(),wt(),Bn(new Set),Fn([]),qn.current=[]},[mi,wt]),zo=null!==si.sectionIdx&&wn.has(si.sectionIdx),Wo=G({proposedSections:Mi,existingSections:Hi,parentDeviationRecord:Wi,expandedSections:Ft,maintainRelativeOrder:!!dn,scrollContainerRef:Un,leftContainerRef:oi,rightContainerRef:Zn,lhsBadgeRefs:Zi,rhsBadgeRefs:et}),qo=Wo.showDeviationNavigation,Go=Wo.showOpenNodeRef,Vo=Wo.adjustScrollForPopup,Ko=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;yi();var c="left";(null===(r=Zn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=et.current[l])||void 0===e?void 0:e.current:null===(i=Zi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=et.current[n])||void 0===t?void 0:t.current:null===(o=Zi.current[n])||void 0===o?void 0:o.current};if(i&&!ji)return wt(),Bn(new Set),Fn([]),qn.current=[],void(l&&(Ot(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));hi({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Ot(n),ji&&(On(Lo(n)),Bn(new Set([n]))),l?setTimeout(function(){Bt(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(ji)setTimeout(function(){return No(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;dn?(null===(e=oi.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=Zn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=Un.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}hi({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Bt(n,i,{toggleIfSame:!1,sourceSide:c}),ji&&setTimeout(function(){return No(n)},150)},350)},[Bt,yi,hi,wt,Ot,ji,dn,No,Yn]),Jo=c(function(){var e;if(!en)return null;var n=null===(e=null==en?void 0:en.id)||void 0===e?void 0:e.split(":")[0];for(var i in Wi){if((Wi[i]||[]).some(function(e){return e.id===n}))return i}return null},[en,Wi]),Yo=u({id:null,triggerMs:null}),Xo=u(null);a(function(){if(null==en?void 0:en.id){var o=Number(en.trigger),r=Yo.current;if((null==r?void 0:r.id)!==en.id||(null==r?void 0:r.triggerMs)!==o){if(en.id.includes(":")&&/:\d+$/.test(en.id)){var l=en.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(en.id,":").concat(o);Xo.current!==s&&(mi(),yi(),wt(),Bn(new Set),Fn([]),qn.current=[],Xo.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c;if(!d){var s=function(){Yo.current={id:en.id,triggerMs:o}},S=null,x=null;for(var R in Wi){var b=Wi[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=Mi.findIndex(function(e){return e.id===S}),w=Hi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(Mi,y),E=h(Hi,y);if(I&&!E&&!_){var A=I.split("-"),D=Number(A[0]);if(dn){var k=null===(c=null===(l=Mi[D])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Hi.findIndex(function(e){return e.selfIndex===k});-1!==O&&(D=O)}E=n([D],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=Mi[P],M=Hi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(dn?!!lr.current["right-".concat(j)]:!!lr.current[String(j)])&&j>=0)return kt(j,"right"),void(f=setTimeout(m,200))}else if(!(dn?!!lr.current["left-".concat(P)]:!!lr.current[String(P)])&&P>=0)return kt(P,"left"),void(f=setTimeout(m,200));var q=I||"",G=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=Zi.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=et.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(q).concat(B).concat(G)};if(!g){Ot(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=dn?ne?Zn.current:oi.current:Un.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||ji?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},dn?[4,Promise.all([oi.current?l(T(oi.current),600):Promise.resolve(),Zn.current?l(T(Zn.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=et.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=Zi.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Vo(r,function(){hi({open:!0,anchorEl:r,displayImpact:en.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==nn||nn(),[2]));case 1:t.sent(),t.label=2;case 2:return ji&&(On(Lo(ee)),Bn(new Set([ee]))),_t.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=et.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=Zi.current[U])||void 0===t?void 0:t.current)||Q;if(ji)setTimeout(function(){return No(ee)},150);else{var u=(null===(o=Zi.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=et.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}hi({open:!0,anchorEl:l,displayImpact:en.displayImpact,summary:e({},i)}),null==nn||nn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}Yo.current={id:en.id,triggerMs:o},go(en.id);var S=Mi.findIndex(function(e){return e.id===en.id}),x=Hi.findIndex(function(e){return e.id===en.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;ji&&On(Lo(e)),Bn(new Set([e])),_t.current(e,n,{sourceSide:n?"right":"left",onReady:function(){ji&&setTimeout(function(){return No(String(e))},150)}})},400)}}},[null==en?void 0:en.id,null==en?void 0:en.trigger,null==en?void 0:en.displayImpact,Wi,Mi,Hi,dn,hi,go,ji,Lo,No]),a(function(){var n,i,t;if(gi.open){var o=gi.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Zi.current)||r(et.current);if(l){var u=(null===(i=et.current[l])||void 0===i?void 0:i.current)||(null===(t=Zi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&hi(function(n){return e(e({},n),{anchorEl:u})})}}}},[gi.open,gi.anchorEl,En,wn,Ft]);var $o=ci.open,Uo=ci.sectionIdx,Qo=ci.isOrphan,Zo=ci.badgeStyle,er=ci.anchorEl,nr=ci.sectionAnchorEl;a(function(){var n;if(Xe.isStreamingEnabled&&$o&&null!=Uo&&Uo!==zt){var i="string"==typeof Uo?Uo.split(B)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(Mi,i):null,r=i&&"string"==typeof i?t(Hi,i):null,l="number"==typeof Uo?Mi[Uo]||null:o||i&&((null===(n=null==We?void 0:We.nodes)||void 0===n?void 0:n[i])||(null==We?void 0:We[i]))||null,u="number"==typeof Uo?Hi[Uo]||null:r,c=so(er,l,u,Uo,Qo,Zo);ai(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[$o,Uo,Qo,Zo,er,nr,Mi,Hi,so]);var ir=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),tr=c(function(){return Mi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&dn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[Mi,dn]),or=c(function(){return Hi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&dn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Hi,dn]),rr=u(vo);a(function(){rr.current=vo},[vo]);var lr=u(Ft);a(function(){lr.current=Ft},[Ft]);var ur=u(Ko);a(function(){ur.current=Ko},[Ko]);var cr=u(Ho);a(function(){cr.current=Ho},[Ho]);var ar=u(kt);a(function(){ar.current=kt},[kt]);var sr=u(Dt);a(function(){sr.current=Dt},[Dt]);var dr=u(ir);a(function(){dr.current=ir},[ir]);var vr=u(wt);a(function(){vr.current=wt},[wt]);var fr=c(function(){return{isGuidelineMode:ji,maintainRelativeOrder:!!dn,showDeviationBadges:gn,isProposingFix:on,proposingFixNodeId:rn,isRedlineFlow:ln,isSideBySide:at,activeSideBySideSection:gt,scrollSyncLocked:En,toggleScrollSyncLocked:jt,summaryPopupAnchorEl:gi.anchorEl,connectedSections:wn,proposedSections:Mi,existingSections:Hi,deviationNumberRegistry:qi,deviationParentRegistry:Gi,treeData:We,displayConfig:Xe,resolvedMarkdownStyles:$n,unifiedNumbering:Lt,expandedSections:Ft,expandedSubSections:Et,setExpandedSubSections:At,getSectionCompareStyle:Ro,getSubSectionCompareStyle:bo,getBadgeRef:ut,getSectionRowRef:rt,getSubSectionRef:lt,sectionLeftRefs:Ui,sectionRightRefs:Qi,sectionRowRefs:ot,sectionRightRowRefs:nt,subSectionLeftRefs:it,subSectionRightRefs:tt,lhsBadgeRefs:Zi,rhsBadgeRefs:et,openMoreFunctionsPopup:Yt,handleOpenSummaryPopup:Xt,openSummaryPopup:Xt,handleCloseSummaryPopup:$t,toggleSection:Ut,handleSubSectionToggle:Qt,renderSubSectionAccordion:Zt,resetSideBySide:eo,setConnectedSections:Bn,setConnectedLines:Fn,cachedConnectedPositions:qn,showDeviationNavigation:qo,showOpenNodeRef:Go,deviationNodeIdToView:null==en?void 0:en.id,deviationTargetParentId:Jo,guidelinesData:cn,gptWebCitationConfig:an}},[ji,dn,gn,on,rn,ln,at,gt,En,jt,gi.anchorEl,wn,Mi,Hi,qi,Xe,$n,Lt,Ft,Et,At,Ro,bo,ut,rt,lt,qo,Go,en,Jo,cn,an]),pr=b(ci.sectionTitle||Ai||Ti),gr=b(ji?ki||Oi||ci.refSectionTitle:ci.refSectionTitle||ki||Oi);return o($,e({value:fr},{children:r(d,e({ref:Qn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[mn&&o(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:o(N,{})})),gi.open&&o(X,{open:gi.open,anchorEl:gi.anchorEl,containerEl:mo.current,clipTopEl:Ln.current,scrollContainerEl:Un.current,onClose:Ho,summary:gi.summary,displayImpact:gi.displayImpact,isScrollLocked:En}),o(L,{open:si.open,anchorEl:si.anchorEl,maintainRelativeOrder:!!dn,sectionTitle:si.sectionTitle,referenceSectionTitle:si.refSectionTitle,onClose:Ci,onOpenCognitiveCompare:Ri,onOpenSideBySide:Mo,onConnect:fo,isConnected:zo,isOrphan:!ji&&!!si.isOrphan,isGuidelineMode:ji,hasGuidelineMatches:si.hasGuidelineMatches}),ci.open&&o(j,{open:ci.open,popupRef:xi,position:vi,popupConfig:Ue,onClose:function(){fi(null),ai(function(n){return e(e({},n),{open:!1})}),Si(null)},markdownStyles:Ke,sectionTitle:pr,referenceSectionTitle:gr,cognitiveData:ci.cognitiveData,anchorEl:ci.anchorEl,sectionAnchorEl:ci.sectionAnchorEl,scrollContainerEl:Un.current,badgeStyle:ci.badgeStyle,docData:ci.docData,deviationData:ci.deviationData,isLoading:ci.isLoading}),o(v,e({open:!!Rn,autoHideDuration:8e3,onClose:function(){return bn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return bn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Rn}))})),o(V,{componentHeaderText:ze,displayConfig:Xe,maintainRelativeOrder:dn,onCollapseAll:Eo,showCollapseAll:Ao,onToggleView:function(e){Sn(!0),setTimeout(function(){vn(!e),null==$e||$e(!e),An(!1),wt(),mi(),Bn(new Set),Fn([]),qn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Sn(!1)},600)})})},50)}}),o(d,e({ref:Un,onScroll:To,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:dn?"visible":"auto",borderTop:Mt&&Ht?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},dn?{flex:1}:{})},{children:r(d,e({ref:jn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},dn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Pn,svgDimensions:Fo,isResizing:vt,overallConnector:_o,rootDeviationStyle:Gt,lines:wo,isSideBySide:at,activeSideBySideSection:gt,isArrowVisible:st,maintainRelativeOrder:dn,proposedSections:Mi,existingSections:Hi,cognitivePopup:ci,activeBadgeId:pi,closeCognitivePopup:yi,setActiveBadgeId:Si,openCognitivePopupFromState:bi,buildSectionPopupState:so,connectedLines:In,isGuidelineMode:ji,pathRefs:Wn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},dn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Ln,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ti,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ti}))}))})),r(d,e({ref:oi,onScroll:To,sx:e({p:"12px",display:"flex",flexDirection:"column"},dn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:ii,style:{width:"100%",height:"0px",flexShrink:0}}),Ki&&tr,o("div",{ref:ti,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:mo,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),ci.open&&pi===zt?yi():(Si(zt),bi(so(n.currentTarget,{title:ro,content:"",evaluationResult:Wt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:uo,content:""},zt,!0,e(e({},Gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Gt.badgeBg,color:Gt.badgeText,border:"1px solid ".concat(Gt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=qt?qt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:ci.open&&pi===zt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},dn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[pt&&o(R,{sections:11}),o(d,e({ref:Nn,sx:e({p:"8px",bgcolor:ji?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},dn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ji?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:ji?r(h,e({value:kn,onChange:function(e,n){return On(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:Oi,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:Oi,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Oi}))}))})),r(d,e({ref:Zn,onScroll:To,sx:e({p:ji?"0px":"12px",display:"flex",flexDirection:"column"},dn?e(e({maxHeight:"calc(100vh - 250px)"},!ji&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ei,style:{width:"100%",height:"0px",flexShrink:0}}),ji?0===kn?o(ie,{guidelinesData:cn,deviationData:Ze,connectedSections:wn,proposedSections:Mi}):o(te,{deviationData:Ze,connectedSections:wn,proposedSections:Mi}):Ki&&or,o("div",{ref:ni,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{oe as default};
|
|
1
|
+
import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as k}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as D,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as G}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";import{GuidelineSkeleton as oe}from"./components/GuidelineSkeletonLoader.js";var re=function(re){var le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,ke,De,Oe,Pe,je,Le,Ne,Me,He,ze=re.componentHeaderText,We=void 0===ze?P:ze,qe=re.treeData,Ge=re.comparisonConfig,Ve=re.leftColumnTitleText,Ke=re.rightColumnTitleText,Je=re.markdownStyles,Ye=re.resetTrigger,Xe=re.displayConfig,$e=void 0===Xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Xe,Ue=re.onMaintainRelativeOrderChange,Qe=re.popupConfig,Ze=re.deviationData,en=void 0===Ze?{}:Ze,nn=re.deviationNodeIdToView,tn=re.resetDeviationNodeId,on=re.isProposingFix,rn=void 0!==on&&on,ln=re.proposingFixNodeId,un=re.isRedlineFlow,cn=re.badgeStyleOverride,an=re.guidelinesData,sn=re.isGuidelineMode,dn=re.gptWebCitationConfig,vn=l($e.maintainRelativeOrder),fn=vn[0],pn=vn[1],gn=null!==(le=null==$e?void 0:$e.expandLevels)&&void 0!==le?le:0,hn=!!(null==$e?void 0:$e.expandAllSections),mn=!!fn||!!(null==$e?void 0:$e.showDeviationBadges),Sn=l(!1),xn=Sn[0],Rn=Sn[1],bn=l(null),yn=bn[0],Cn=bn[1],wn=l(null===(ce=null!==(ue=null==qe?void 0:qe.newEvaluationResult)&&void 0!==ue?ue:null==$e?void 0:$e.enableDeviationSchemaBackwardCompatibility)||void 0===ce||ce)[0],Bn=l(new Set),_n=Bn[0],In=Bn[1],Fn=l([]),Tn=Fn[0],En=Fn[1],An=l(!1),kn=An[0],Dn=An[1],On=l(0),Pn=On[0],jn=On[1],Ln=u(null),Nn=u(null),Mn=u(null),Hn=u(null),zn=u(null),Wn=u(!1),qn=u(null),Gn=u({}),Vn=u([]),Kn=u(function(){}),Jn=u(null),Yn=u(function(){}),Xn=c(function(){return JSON.stringify(en||{})},[JSON.stringify(en)]),$n=c(function(){return en||{}},[Xn]),Un=c(function(){return(null==qe?void 0:qe.cognitive_decisioning)||{}},[qe]),Qn=c(function(){return e(e({},E),Je)},[Je]),Zn=u(null),ei=u(null),ni=u(null),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=u(null),ci=u(null),ai=z(Zn),si=ai.cognitivePopup,di=ai.setCognitivePopup,vi=ai.moreFunctions,fi=ai.setMoreFunctions,pi=ai.position,gi=ai.setPosition,hi=ai.activeBadgeId,mi=ai.summaryPopup,Si=ai.setSummaryPopup,xi=ai.closeSummaryPopup,Ri=ai.setActiveBadgeId,bi=ai.popupRef,yi=ai.handleOpenCognitiveCompare,Ci=ai.openCognitivePopupFromState,wi=ai.closeCognitivePopup,Bi=ai.closeMoreFunctionsPopup,_i=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Ge?void 0:Ge.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==Ge?void 0:Ge.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:k.thresholds.high,medium:null!==(o=null===(t=null==Ge?void 0:Ge.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:k.thresholds.medium,exact:null!==(l=null===(r=null==Ge?void 0:Ge.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:k.thresholds.exact}}},[Ge]),Ii=l(null),Fi=Ii[0];Ii[1];var Ti=null===(de=null===(ae=null==qe?void 0:qe.documents)||void 0===ae?void 0:ae[null===(se=null==qe?void 0:qe.input_index_map)||void 0===se?void 0:se[0]])||void 0===de?void 0:de.title,Ei=null===(pe=null===(ve=null==qe?void 0:qe.documents)||void 0===ve?void 0:ve[null===(fe=null==qe?void 0:qe.input_index_map)||void 0===fe?void 0:fe[1]])||void 0===pe?void 0:pe.title,Ai=b(Ve||Ti||"Uploaded Contract"),ki=null===(Se=null===(me=null===(ge=null==qe?void 0:qe.documents)||void 0===ge?void 0:ge[null===(he=null==qe?void 0:qe.input_index_map)||void 0===he?void 0:he[0]])||void 0===me?void 0:me.metadata)||void 0===Se?void 0:Se.file_name,Di=b(ki),Oi=null===(ye=null===(be=null===(xe=null==qe?void 0:qe.documents)||void 0===xe?void 0:xe[null===(Re=null==qe?void 0:qe.input_index_map)||void 0===Re?void 0:Re[1]])||void 0===be?void 0:be.metadata)||void 0===ye?void 0:ye.file_name,Pi=b(Oi),ji=b(Ke||Ei||"Reference Template"),Li=H(qe,fn,$n,_i,wn,an,sn),Ni=Li.isGuidelineMode,Mi=Li.activeProposed,Hi=Li.existingRule,zi=Li.proposedSections,Wi=Li.existingSections,qi=Li.visibleFields,Gi=Li.parentDeviationRecord,Vi=Li.deviationNumberRegistry,Ki=Li.deviationParentRegistry,Ji=Li.parseError;a(function(){Ji&&Cn("Failed to load comparison: ".concat(Ji))},[Ji]);var Yi=zi.length>0||Wi.length>0,Xi=c(function(){if(!un)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";_(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(zi),i(Wi),"".concat(e,":").concat(n)},[un,zi,Wi]);a(function(){if(zi.length||Wi.length)if(hn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=fn?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(zi,"left"),i(Wi,"right"),At(e),Dt(n)}else if(gn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=fn?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(zi,"left",gn),r(Wi,"right",gn),At(t),Dt(o)}},[hn,gn,zi,Wi,fn]);var $i=W(qi.map(function(e){return e.key}),Math.max(zi.length,Wi.length)),Ui=$i.leftRefs,Qi=$i.rightRefs,Zi=$i.sectionLeftRefs,et=$i.sectionRightRefs,nt=$i.lhsBadgeRefs,it=$i.rhsBadgeRefs,tt=$i.sectionRightRowRefs,ot=$i.subSectionLeftRefs,rt=$i.subSectionRightRefs,lt=$i.sectionRowRefs,ut=$i.getSectionRowRef,ct=$i.getSubSectionRef,at=$i.getBadgeRef,st=ee({isGuidelineMode:Ni,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,leftContainerRef:li,rightContainerRef:ni,scrollContainerRef:Zn,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,sectionRowRefs:lt,sectionRightRowRefs:tt,rhsTopSpacerRef:ii,rhsBottomSpacerRef:ti,lhsTopSpacerRef:oi,lhsBottomSpacerRef:ri,calculateLinesRef:Kn,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,closeMoreFunctionsPopup:Bi,setErrorToast:Cn,moreFunctions:vi,closeSummaryPopup:xi}),dt=st.isSideBySide,vt=st.isArrowVisible,ft=st.setIsArrowVisible,pt=st.isResizing,gt=st.setIsResizing,ht=st.isSideBySideLoading,mt=st.activeSideBySideSection,St=st.scrollLock,xt=st.sideBySideCacheRef,Rt=st.isSideBySideRef,bt=st.activeSideBySideRightSectionRef,yt=st.activeSideBySideSectionRef,Ct=st.sideBySideLineRef,wt=st.highlightedClauseRefs,Bt=st.clearClauseHighlight,_t=st.resetSideBySide,It=st.activateSideBySide,Ft=u(It);a(function(){Ft.current=It},[It]);var Tt=q({maintainRelativeOrder:!!fn,proposedSections:zi,existingSections:Wi,activeSideBySideSection:mt,connectedSections:_n,resetSideBySide:_t,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,svgContainerRef:Ln,isAnimatingRef:Wn,animationTimerRef:qn,calculateLinesRef:Kn,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt}),Et=Tt.expandedSections,At=Tt.setExpandedSections,kt=Tt.expandedSubSections,Dt=Tt.setExpandedSubSections,Ot=Tt.handleSubSectionToggle,Pt=Tt.toggleSection,jt=Tt.forceExpandCrossWiredSections,Lt=function(){var e,n;if(null!=mt){var i=null===(e=Zi.current[mt])||void 0===e?void 0:e.current,t=null===(n=et.current[mt])||void 0===n?void 0:n.current,o=ni.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},Nt=s(function(e){null==e||e.stopPropagation(),Dn(function(e){var n=!e;return n&&requestAnimationFrame(function(){Lt()}),n})},[Lt]);a(function(){un&&"off"!==Xi&&"0:0"!==Xi&&(xt.current=null,Vn.current=[],requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)}))},[un,Xi]);var Mt=c(function(){var e=new Map,n=new Map,i=1;if(fn)zi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Wi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=zi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(zi.length,Wi.length),o=0;o<t;o++){var r=zi[o],l=Wi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[zi,Wi,fn]),Ht=Hi.analysis,zt=b(null===(we=null===(Ce=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===Ce?void 0:Ce.summary)||void 0===we?void 0:we.overall_summary),Wt=!!zt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),qt=null!==(Be=null==qe?void 0:qe.base_root_id)&&void 0!==Be?Be:"-1";null==qe||qe[qt];var Gt=wn?null!==(Le=null!==(Oe=en&&(null===(De=null==en?void 0:en[qt])||void 0===De?void 0:De.evaluation_result))&&void 0!==Oe?Oe:null===(je=null===(Pe=null==qe?void 0:qe.nodes)||void 0===Pe?void 0:Pe[qt])||void 0===je?void 0:je.evaluation_result)&&void 0!==Le?Le:null:null!==(ke=null!==(Fe=en&&(null===(Ie=null===(_e=null==en?void 0:en[qt])||void 0===_e?void 0:_e.evaluation_result)||void 0===Ie?void 0:Ie[0]))&&void 0!==Fe?Fe:null===(Ae=null===(Ee=null===(Te=null==qe?void 0:qe.nodes)||void 0===Te?void 0:Te[qt])||void 0===Ee?void 0:Ee.evaluation_result)||void 0===Ae?void 0:Ae[0])&&void 0!==ke?ke:null,Vt=y(Gt),Kt=C(null!==(He=null===(Me=null===(Ne=null==Gt?void 0:Gt.evaluation_outputs)||void 0===Ne?void 0:Ne.metadata)||void 0===Me?void 0:Me.label_color)&&void 0!==He?He:D);if(cn){var Jt=cn(Vt);Jt&&(Kt=e(e({},Kt),{badgeBg:Jt.bg,badgeText:Jt.text,badgeBorder:Jt.border}))}var Yt=u(_t);a(function(){Yt.current=_t},[_t]);var Xt=u(wi);a(function(){Xt.current=wi},[wi]);var $t=s(function(e,n,i,t,o,r){return ur.current(e,n,i,t,o,r)},[]),Ut=s(function(e,n,i,t,o){return ar.current(e,n,i,t,o)},[]),Qt=s(function(){return sr.current()},[]),Zt=s(function(e,n){return dr.current(e,n)},[]),eo=s(function(e){return vr.current(e)},[]),no=s(function(e){return fr.current(e)},[]),io=s(function(){return pr.current()},[]),to=s(function(){var e,n;Bt(),null===(e=Yt.current)||void 0===e||e.call(Yt),Dn(!1),In(new Set),En([]),Vn.current=[],Io([]),To(null),Si(O),null===(n=Xt.current)||void 0===n||n.call(Xt),requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)})},[]),oo=u(to);a(function(){oo.current=to},[to]),a(function(){Ye&&oo.current()},[Ye]);var ro=c(function(){return{documents:null==qe?void 0:qe.documents,input_index_map:null==qe?void 0:qe.input_index_map}},[JSON.stringify(null==qe?void 0:qe.documents),JSON.stringify(null==qe?void 0:qe.input_index_map)]),lo=l(""),uo=lo[0],co=lo[1],ao=b(Ei),so=u(qe);a(function(){var e,n,i;so.current=qe;var t=null===(e=null==qe?void 0:qe.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==qe?void 0:qe.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;co(o)},[qe]);var vo=u(Un);a(function(){vo.current=Un},[Un]);var fo=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=vo.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},R=null!==(s=null===(a=lt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(B)))return u(l);var c=o.split(B)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(d=null==y?void 0:y.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==$e?void 0:$e.isLoading)&&void 0!==m&&m,_=!0;if(Ni){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:ro,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[ro,null==$e?void 0:$e.isLoading,Ni]),po=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),vi.open&&vi.sectionIdx===o)Bi();else{var u=e.currentTarget,c="left";(null===(l=ni.current)||void 0===l?void 0:l.contains(u))&&(c="right");Bt(),Rt.current&&_t(),In(new Set),En([]),Vn.current=[],wi(),mi.open?Wo():xi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=it.current[l])||void 0===e?void 0:e.current:null===(n=nt.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=it.current[o])||void 0===i?void 0:i.current:null===(t=nt.current[o])||void 0===t?void 0:t.current}()||u;fi(fo(e,n,t,o,i,r))})}},[vi.open,vi.sectionIdx,Bi,xi,fo]),go=s(function(){var e=vi.sectionIdx;vi.isOrphan,Bi(),xi(),null!==e&&(jt(e),Bt(),Rt.current&&_t(),En([]),Vn.current=[],Ni&&null!==e&&jn(Mo(e)),In(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Kn.current&&Kn.current()},50))},[vi.sectionIdx,vi.isOrphan,Bi,xi,_t]),ho=s(function(){var e=zn.current;if(e){zn.current=null;var n=zi.findIndex(function(n){return n.id===e}),i=Wi.findIndex(function(n){return n.id===e}),t=-1===n?w(zi,e):null,o=-1===i?w(Wi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(wt.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(fn)-1!==r&&li.current&&c(function(){return u(n,t,Zi,ot)},li.current),-1!==l&&ni.current&&c(function(){return u(i,o,et,rt)},ni.current);else{var a=Zn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Zi,ot):u(i,o,et,rt)},a)}}},[zi,Wi,fn,Zi,et,ot,rt,li,ni,Zn]),mo=s(function(n){if(n){Bt(),_t(),In(new Set),En([]),Vn.current=[],xi(),wi();var i=zi.findIndex(function(e){return e.id===n}),t=Wi.findIndex(function(e){return e.id===n}),o=-1===i?w(zi,n):null,r=-1===t?w(Wi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;zn.current=n,At(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=fn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=fn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Dt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){zn.current===n&&So.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[zi,Wi,fn,At,Dt,_t,xi,wi]),So=u(ho);a(function(){So.current=ho},[ho]);var xo=u(null);a(function(){if(Fi){var e=_i.fields.find(function(e){return e.analysisKey===Fi||e.key===Fi});if(e){var n=Ui.current[e.key]||Qi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fi,_i.fields]);var Ro=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Ht]),bo=U({proposedSections:zi,existingSections:Wi,maintainRelativeOrder:fn,cognitiveMap:Un,deviationData:$n,treeData:qe,resolvedComparisonConfig:_i,badgeStyleOverride:cn}),yo=bo.getSectionCompareStyle,Co=bo.getSubSectionCompareStyle,wo=bo.getDeviationStyleByKey,Bo=Z({containerRef:Nn,leftContainerRef:li,rightContainerRef:ni,svgContainerRef:Ln,pathRefs:Gn,leftHeaderRef:Mn,rightHeaderRef:Hn,proposedSections:zi,existingSections:Wi,visibleFields:qi,leftRefs:Ui,rightRefs:Qi,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,sectionRowRefs:lt,expandedSections:Et,expandedSubSections:kt,connectedSections:_n,isSideBySide:dt,activeSideBySideSection:mt,maintainRelativeOrder:fn,isGuidelineMode:Ni,cognitiveMap:Un,getSectionCompareStyle:yo,getSubSectionCompareStyle:Co,getDeviationStyleByKey:wo,isArrowVisible:vt,isAnimatingRef:Wn,isSideBySideRef:Rt,sideBySideCacheRef:xt,sideBySideLineRef:Ct,activeSideBySideSectionRef:yt,activeSideBySideRightSectionRef:bt,connectedLines:Tn,setConnectedLines:En,cachedConnectedPositions:Vn,calculateLinesRef:Kn,resizeTimerRef:Jn,scrollLock:St,scrollSyncLocked:kn,handleResizeRef:Yn,activeProposed:Mi,existingRule:Hi,analysisData:Ht,pendingScrollTargetRef:ui,pendingScrollCallbackRef:ci,resolvedComparisonConfig:_i,getFieldData:Ro}),_o=Bo.lines,Io=Bo.setLines,Fo=Bo.overallConnector,To=Bo.setOverallConnector,Eo=Bo.svgDimensions,Ao=Bo.handleColumnScroll;a(function(){mi.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Kn.current)||void 0===e||e.call(Kn)})})},[mi.anchorEl,kn]);var ko=s(function(){Bt(),Dn(!1),At({}),Dt({}),_t(),In(new Set),En([]),Vn.current=[],xi(),wi(),Bi(),requestAnimationFrame(function(){Kn.current&&Kn.current()})},[At,Dt,_t,xi,wi,Bi]);a(function(){dt||0!==_n.size||Dn(!1)},[dt,_n]);var Do=c(function(){return Object.values(Et).some(Boolean)||Object.values(kt).some(Boolean)},[Et,kt]),Oo=u(null),Po=u(0),jo=u(0),Lo=u(0),No=Q({timerRef:Oo,ruleComponentRef:ei,scrollContainerRef:Zn,containerRef:Nn,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,isSideBySideRef:Rt,activeSideBySideSectionRef:yt,activeSideBySideRightSectionRef:bt,sectionRowRefs:lt,sectionRightRowRefs:tt,sectionLeftRefs:Zi,sectionRightRefs:et,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,leftContainerRef:li,rightContainerRef:ni,calculateLinesRef:Kn,handleResizeRef:Yn,setIsResizing:gt,setIsArrowVisible:ft,sideBySideCacheRef:xt,cachedConnectedPositions:Vn}).handleResize;a(function(){Yn.current=No},[No,Yn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return ei.current&&o.push(e(ei.current,Po,n,function(){return Yn.current()},function(){})),Zn.current&&o.push(e(Zn.current,jo,i,function(){return Yn.current()},function(){return Kn.current()})),Nn.current&&o.push(e(Nn.current,Lo,t,function(){return Yn.current()},function(){return Kn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){Rt.current=dt},[dt]),a(function(){yt.current=mt},[mt]);var Mo=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=zi[e])||void 0===n?void 0:n.nodeId)||(null===(i=zi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==$n?void 0:$n[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[zi,$n]),Ho=s(function(e){var n,i,t=li.current,o=ni.current;if(o){var r=o.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),l=Array.from(r).filter(function(e){var n=e.getBoundingClientRect();return n.width>0&&n.height>0}),u="string"==typeof e&&e.includes(B),c=e;if(u){var a=e.split(B);a.length>=2&&(c="".concat(a[0]).concat(B).concat(a[1]))}var s=(null===(n=nt.current[c])||void 0===n?void 0:n.current)||(null===(i=nt.current[e])||void 0===i?void 0:i.current);if(l.length>0&&s&&t&&o){var d=l[0];oi.current&&(oi.current.style.height="0px"),ii.current&&(ii.current.style.height="0px"),ri.current&&(ri.current.style.height="0px"),ti.current&&(ti.current.style.height="0px"),requestAnimationFrame(function(){var e=s.getBoundingClientRect(),n=d.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,c=l-i.height/2,a=Math.max(0,c),v=t.scrollHeight-t.clientHeight,f=a>v?a-v:0,p=i.top+l-a,g=r.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=o.scrollHeight-o.clientHeight+h,S=g>m?g-m:0;ri.current&&(ri.current.style.height="".concat(f,"px")),ii.current&&(ii.current.style.height="".concat(h,"px")),ti.current&&(ti.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:a,behavior:"smooth"}),o.scrollTo({top:g,behavior:"smooth"}),Kn.current&&setTimeout(function(){return Kn.current()},50)})})}}},[B]),zo=s(function(){var e,n=vi.sectionIdx,i=vi.isOrphan;if(xi(),null!=n){var t="left";vi.anchorEl&&(null===(e=ni.current)||void 0===e?void 0:e.contains(vi.anchorEl))&&(t="right"),jt(n),Ni&&(jn(Mo(n)),In(new Set([n]))),It(n,i,{sourceSide:t,onReady:function(){Ni&&setTimeout(function(){return Ho(String(n))},150)}})}},[It,vi.isOrphan,vi.sectionIdx,vi.anchorEl,xi,jt,Ni,Ho,Mo]),Wo=s(function(){xi(),_t(),In(new Set),En([]),Vn.current=[]},[xi,_t]),qo=null!==vi.sectionIdx&&_n.has(vi.sectionIdx),Go=G({proposedSections:zi,existingSections:Wi,parentDeviationRecord:Gi,expandedSections:Et,maintainRelativeOrder:!!fn,scrollContainerRef:Zn,leftContainerRef:li,rightContainerRef:ni,lhsBadgeRefs:nt,rhsBadgeRefs:it}),Vo=Go.showDeviationNavigation,Ko=Go.showOpenNodeRef,Jo=Go.adjustScrollForPopup,Yo=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;wi();var c="left";(null===(r=ni.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=it.current[l])||void 0===e?void 0:e.current:null===(i=nt.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=it.current[n])||void 0===t?void 0:t.current:null===(o=nt.current[n])||void 0===o?void 0:o.current};if(i&&!Ni)return _t(),In(new Set),En([]),Vn.current=[],void(l&&(jt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Si({open:!0,anchorEl:e,summary:t,displayImpact:o})})));jt(n),Ni&&(jn(Mo(n)),In(new Set([n]))),l?setTimeout(function(){It(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(Ni)setTimeout(function(){return Ho(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;fn?(null===(e=li.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=ni.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=Zn.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}Si({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){It(n,i,{toggleIfSame:!1,sourceSide:c}),Ni&&setTimeout(function(){return Ho(n)},150)},350)},[It,wi,Si,_t,jt,Ni,fn,Ho,$n]),Xo=c(function(){var e;if(!nn)return null;var n=null===(e=null==nn?void 0:nn.id)||void 0===e?void 0:e.split(":")[0];for(var i in Gi){if((Gi[i]||[]).some(function(e){return e.id===n}))return i}return null},[nn,Gi]),$o=u({id:null,triggerMs:null}),Uo=u(null);a(function(){if(null==nn?void 0:nn.id){var o=Number(nn.trigger),r=$o.current;if((null==r?void 0:r.id)!==nn.id||(null==r?void 0:r.triggerMs)!==o){if(nn.id.includes(":")&&/:\d+$/.test(nn.id)){var l=nn.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(nn.id,":").concat(o);Uo.current!==s&&(xi(),wi(),_t(),In(new Set),En([]),Vn.current=[],Uo.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c;if(!d){var s=function(){$o.current={id:nn.id,triggerMs:o}},S=null,x=null;for(var R in Gi){var b=Gi[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=zi.findIndex(function(e){return e.id===S}),w=Wi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(zi,y),E=h(Wi,y);if(I&&!E&&!_){var A=I.split("-"),k=Number(A[0]);if(fn){var D=null===(c=null===(l=zi[k])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Wi.findIndex(function(e){return e.selfIndex===D});-1!==O&&(k=O)}E=n([k],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=zi[P],M=Wi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(fn?!!cr.current["right-".concat(j)]:!!cr.current[String(j)])&&j>=0)return Pt(j,"right"),void(f=setTimeout(m,200))}else if(!(fn?!!cr.current["left-".concat(P)]:!!cr.current[String(P)])&&P>=0)return Pt(P,"left"),void(f=setTimeout(m,200));var q=I||"",G=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=nt.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=it.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(q).concat(B).concat(G)};if(!g){jt(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=fn?ne?ni.current:li.current:Zn.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||Ni?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},fn?[4,Promise.all([li.current?l(T(li.current),600):Promise.resolve(),ni.current?l(T(ni.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=it.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=nt.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Jo(r,function(){Si({open:!0,anchorEl:r,displayImpact:nn.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==tn||tn(),[2]));case 1:t.sent(),t.label=2;case 2:return Ni&&(jn(Mo(ee)),In(new Set([ee]))),Ft.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=it.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=nt.current[U])||void 0===t?void 0:t.current)||Q;if(Ni)setTimeout(function(){return Ho(ee)},150);else{var u=(null===(o=nt.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=it.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}Si({open:!0,anchorEl:l,displayImpact:nn.displayImpact,summary:e({},i)}),null==tn||tn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}$o.current={id:nn.id,triggerMs:o},mo(nn.id);var S=zi.findIndex(function(e){return e.id===nn.id}),x=Wi.findIndex(function(e){return e.id===nn.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;Ni&&jn(Mo(e)),In(new Set([e])),Ft.current(e,n,{sourceSide:n?"right":"left",onReady:function(){Ni&&setTimeout(function(){return Ho(String(e))},150)}})},400)}}},[null==nn?void 0:nn.id,null==nn?void 0:nn.trigger,null==nn?void 0:nn.displayImpact,Gi,zi,Wi,fn,Si,mo,Ni,Mo,Ho]),a(function(){var n,i,t;if(mi.open){var o=mi.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(nt.current)||r(it.current);if(l){var u=(null===(i=it.current[l])||void 0===i?void 0:i.current)||(null===(t=nt.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&Si(function(n){return e(e({},n),{anchorEl:u})})}}}},[mi.open,mi.anchorEl,kn,_n,Et]);var Qo=si.open,Zo=si.sectionIdx,er=si.isOrphan,nr=si.badgeStyle,ir=si.anchorEl,tr=si.sectionAnchorEl;a(function(){var n;if($e.isStreamingEnabled&&Qo&&null!=Zo&&Zo!==qt){var i="string"==typeof Zo?Zo.split(B)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(zi,i):null,r=i&&"string"==typeof i?t(Wi,i):null,l="number"==typeof Zo?zi[Zo]||null:o||i&&((null===(n=null==qe?void 0:qe.nodes)||void 0===n?void 0:n[i])||(null==qe?void 0:qe[i]))||null,u="number"==typeof Zo?Wi[Zo]||null:r,c=fo(ir,l,u,Zo,er,nr);di(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Qo,Zo,er,nr,ir,tr,zi,Wi,fo]);var or=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),rr=c(function(){return zi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&fn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[zi,fn]),lr=c(function(){return Wi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&fn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Wi,fn]),ur=u(po);a(function(){ur.current=po},[po]);var cr=u(Et);a(function(){cr.current=Et},[Et]);var ar=u(Yo);a(function(){ar.current=Yo},[Yo]);var sr=u(Wo);a(function(){sr.current=Wo},[Wo]);var dr=u(Pt);a(function(){dr.current=Pt},[Pt]);var vr=u(Ot);a(function(){vr.current=Ot},[Ot]);var fr=u(or);a(function(){fr.current=or},[or]);var pr=u(_t);a(function(){pr.current=_t},[_t]);var gr=c(function(){return{isGuidelineMode:Ni,maintainRelativeOrder:!!fn,showDeviationBadges:mn,isProposingFix:rn,proposingFixNodeId:ln,isRedlineFlow:un,isSideBySide:dt,activeSideBySideSection:mt,scrollSyncLocked:kn,toggleScrollSyncLocked:Nt,summaryPopupAnchorEl:mi.anchorEl,connectedSections:_n,proposedSections:zi,existingSections:Wi,deviationNumberRegistry:Vi,deviationParentRegistry:Ki,treeData:qe,displayConfig:$e,resolvedMarkdownStyles:Qn,unifiedNumbering:Mt,expandedSections:Et,expandedSubSections:kt,setExpandedSubSections:Dt,getSectionCompareStyle:yo,getSubSectionCompareStyle:Co,getBadgeRef:at,getSectionRowRef:ut,getSubSectionRef:ct,sectionLeftRefs:Zi,sectionRightRefs:et,sectionRowRefs:lt,sectionRightRowRefs:tt,subSectionLeftRefs:ot,subSectionRightRefs:rt,lhsBadgeRefs:nt,rhsBadgeRefs:it,openMoreFunctionsPopup:$t,handleOpenSummaryPopup:Ut,openSummaryPopup:Ut,handleCloseSummaryPopup:Qt,toggleSection:Zt,handleSubSectionToggle:eo,renderSubSectionAccordion:no,resetSideBySide:io,setConnectedSections:In,setConnectedLines:En,cachedConnectedPositions:Vn,showDeviationNavigation:Vo,showOpenNodeRef:Ko,deviationNodeIdToView:null==nn?void 0:nn.id,deviationTargetParentId:Xo,guidelinesData:an,gptWebCitationConfig:dn}},[Ni,fn,mn,rn,ln,un,dt,mt,kn,Nt,mi.anchorEl,_n,zi,Wi,Vi,$e,Qn,Mt,Et,kt,Dt,yo,Co,at,ut,ct,Vo,Ko,nn,Xo,an,dn]),hr=b(si.sectionTitle||Di||Ai),mr=b(Ni?Pi||ji||si.refSectionTitle:si.refSectionTitle||Pi||ji);return o($,e({value:gr},{children:r(d,e({ref:ei,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[xn&&o(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:o(N,{})})),mi.open&&o(X,{open:mi.open,anchorEl:mi.anchorEl,containerEl:xo.current,clipTopEl:Mn.current,scrollContainerEl:Zn.current,onClose:Wo,summary:mi.summary,displayImpact:mi.displayImpact,isScrollLocked:kn}),o(L,{open:vi.open,anchorEl:vi.anchorEl,maintainRelativeOrder:!!fn,sectionTitle:vi.sectionTitle,referenceSectionTitle:vi.refSectionTitle,onClose:Bi,onOpenCognitiveCompare:yi,onOpenSideBySide:zo,onConnect:go,isConnected:qo,isOrphan:!Ni&&!!vi.isOrphan,isGuidelineMode:Ni,hasGuidelineMatches:vi.hasGuidelineMatches}),si.open&&o(j,{open:si.open,popupRef:bi,position:pi,popupConfig:Qe,onClose:function(){gi(null),di(function(n){return e(e({},n),{open:!1})}),Ri(null)},markdownStyles:Je,sectionTitle:hr,referenceSectionTitle:mr,cognitiveData:si.cognitiveData,anchorEl:si.anchorEl,sectionAnchorEl:si.sectionAnchorEl,scrollContainerEl:Zn.current,badgeStyle:si.badgeStyle,docData:si.docData,deviationData:si.deviationData,isLoading:si.isLoading}),o(v,e({open:!!yn,autoHideDuration:8e3,onClose:function(){return Cn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return Cn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:yn}))})),o(V,{componentHeaderText:We,displayConfig:$e,maintainRelativeOrder:fn,onCollapseAll:ko,showCollapseAll:Do,onToggleView:function(e){Rn(!0),setTimeout(function(){pn(!e),null==Ue||Ue(!e),Dn(!1),_t(),xi(),In(new Set),En([]),Vn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Rn(!1)},600)})})},50)}}),o(d,e({ref:Zn,onScroll:Ao,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:fn?"visible":"auto",borderTop:zt&&Wt?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},fn?{flex:1}:{})},{children:r(d,e({ref:Nn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},fn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Ln,svgDimensions:Eo,isResizing:pt,overallConnector:Fo,rootDeviationStyle:Kt,lines:_o,isSideBySide:dt,activeSideBySideSection:mt,isArrowVisible:vt,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,cognitivePopup:si,activeBadgeId:hi,closeCognitivePopup:wi,setActiveBadgeId:Ri,openCognitivePopupFromState:Ci,buildSectionPopupState:fo,connectedLines:Tn,isGuidelineMode:Ni,pathRefs:Gn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},fn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Mn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ai,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ai}))}))})),r(d,e({ref:li,onScroll:Ao,sx:e({p:"12px",display:"flex",flexDirection:"column"},fn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:oi,style:{width:"100%",height:"0px",flexShrink:0}}),Yi&&rr,o("div",{ref:ri,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:xo,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),si.open&&hi===qt?wi():(Ri(qt),Ci(fo(n.currentTarget,{title:uo,content:"",evaluationResult:Gt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:ao,content:""},qt,!0,e(e({},Kt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Kt.badgeBg,color:Kt.badgeText,border:"1px solid ".concat(Kt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Vt?Vt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:si.open&&hi===qt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},fn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ht&&o(R,{sections:11}),o(d,e({ref:Hn,sx:e({p:"8px",bgcolor:Ni?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},fn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},Ni?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:Ni?r(h,e({value:Pn,onChange:function(e,n){return jn(n)},variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:ji,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:ji,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ji}))}))})),r(d,e({ref:ni,onScroll:Ao,sx:e({p:Ni?"0px":"12px",display:"flex",flexDirection:"column"},fn?e(e({maxHeight:"calc(100vh - 250px)"},!Ni&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ii,style:{width:"100%",height:"0px",flexShrink:0}}),Ni?an?0===Pn?o(ie,{guidelinesData:an,deviationData:en,connectedSections:_n,proposedSections:zi}):o(te,{deviationData:en,connectedSections:_n,proposedSections:zi}):o(oe,{}):Yi&&lr,o("div",{ref:ti,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{re as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))},o=function(t){for(var n=t+1,e="";n>0;){n-=1;e=String.fromCharCode(97+n%26)+e,n=Math.floor(n/26)}return e},r=function(t){var n=t.section,e=t.proposedSections,r=t.leftNums,i=t.fallbackNumber,u=t.firstOnly,l=void 0!==u&&u;if(!(null==n?void 0:n.id))return i;var a=(e||[]).map(function(t){var e=Array.isArray(null==t?void 0:t.refIndexes)?t.refIndexes:[],i=e.findIndex(function(t){return t===n.selfIndex});if(-1===i)return null;var u=(null==t?void 0:t.id)?r.get(t.id):void 0;return null==u?null:e.length>1?"".concat(u).concat(o(i)):String(u)}).filter(Boolean);return 0===a.length?i:l?a[0]:a.join(", ")},i=function(t,n){return null!=(null==t?void 0:t.selfIndex)&&1===(n||[]).filter(function(n){return Array.isArray(null==n?void 0:n.refIndexes)&&n.refIndexes.includes(t.selfIndex)}).length},u=function(t,n,e,o){var r;void 0===o&&(o={});var i=e[n],u=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return u?(Array.isArray(u)?u:[u]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=o[t];return e&&"object"==typeof e&&e?{contentId:t,data:e,attributes:e.additional_attributes||{}}:null}return t&&"object"==typeof t?{contentId:t.content_id||t.id||"".concat(i,"-direct-").concat(n),data:t,attributes:t.additional_attributes||{}}:null}).filter(Boolean):[]},l=function(t,e,o,r){var i,l,a;void 0===r&&(r={});var s=u(t,e,o,r),c=(null===(i=s[0])||void 0===i?void 0:i.data)||{},d=(null===(l=s[0])||void 0===l?void 0:l.attributes)||null;return{title:n((null==c?void 0:c.title)||""),content:n((null==c?void 0:c.content)||""),change_history:n((null==c?void 0:c.change_history)||""),attributes:d,subsections:(null==c?void 0:c.subsections)||[],contentId:null===(a=s[0])||void 0===a?void 0:a.contentId,allItems:s}},a=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}};function s(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}}function c(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}}var d=function(t,n){var e,o,r,i,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if(d[c].showScrollLockToggle!==v[c].showScrollLockToggle)return!1;if(d[c].scrollSyncLocked!==v[c].scrollSyncLocked)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=v[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=d[c].style)||void 0===u?void 0:u.badgeText)!==(null===(l=v[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},v="::",f=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},g=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},h=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},p=function(t,n){for(var e="",o=[],r=[],i=0;i<t.length;i+=1){var u=t[i],l=n&&/[\.,;:]/.test(u),a=/\s/.test(u)||l?" ":/[’‘`]/.test(u)?"'":/[”“]/.test(u)?'"':/[—–]/.test(u)?"-":u;" "===a&&e.endsWith(" ")?r[r.length-1]=i+1:(e+=a,o.push(i),r.push(i+1))}return{text:e,starts:o,ends:r}},b=function(t,n,e){if(void 0===e&&(e=!1),!t||!n)return null;var o=t.indexOf(n);if(-1!==o)return{start:o,end:o+n.length};var r=p(t,e),i=p(n,e).text.trim();if(!i)return null;var u=r.text.indexOf(i);if(-1===u)return null;var l=u+i.length-1,a=r.starts[u],s=r.ends[l];return void 0===a||void 0===s?null:{start:a,end:s}},m=function(t,e,o){var r=new Map;if(!e)return r;var i=function(t){var e=g(t)?h(t):n(t||"");return n(e).replace(/\\n/g,"\n")};return(t||[]).forEach(function(t){var n=new Map,u=function(t){var r;if(t){var l=i(t.content);((null===(r=t.evaluationResults)||void 0===r?void 0:r.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(r){var u=(null==r?void 0:r.nodeId)||t.nodeId||t.id;Object.entries((null==r?void 0:r.deviations)||{}).forEach(function(t){var r=t[0],a=t[1][e],s=i(a);if(s&&!f(a)&&b(l,s)){var c="".concat(u).concat("::").concat(r),d=o[c];null!=d&&n.set(c,d)}})}),(t.subsections||[]).forEach(u)}};if(u(t),0!==n.size){var l=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){r.set(n,t-l+1)})}}),r},y=function(t,n){var e,o,r,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},_=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),u=o-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=u>0?1:-1,a=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*a),"V ".concat(o-l*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},x=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(c){null===a&&(a=c);var d,v=c-a;v<e?(t.scrollTop=(d=v,d/=e,l*(--d*d*d+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},T=["#B91C1C","#A16207","#1D4ED8","#000000"],I=function(t){var n=T.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?T.length:n},A=function(n){for(var e,o,r,i,u,l,a,s,c,d,v,f,g,h=[],p=0,b=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});p<b.length;p++){var m=b[p];(A=null===(i=null===(r=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[m])||void 0===o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&h.push(A)}for(var y=0,_=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});y<_.length;y++){m=_[y];(A=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[m])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&h.push(A)}for(var x=0,T=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});x<T.length;x++){var A;m=T[x];(A=null===(v=null===(d=null===(c=null==n?void 0:n[m])||void 0===c?void 0:c.evaluation_outputs)||void 0===d?void 0:d.metadata)||void 0===v?void 0:v.label_color)&&h.push(A)}return 0===h.length?(null===(g=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t:h.sort(function(t,n){return I(t)-I(n)})[0]},B=function(t){for(var n,e,o,r,i,u,l,a,s,c=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<d.length;c++){var v=d[c];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[v])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){v=g[f];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var h=0,p=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});h<p.length;h++){var b;v=p[h];if(b=null===(a=null===(l=null==t?void 0:t[v])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},M=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),u=(r[0]+i[0])/2*.95,l=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(u)).concat(o(l)).concat(o(a))}catch(t){return"#FDE68A"}},C=function(t,n,e){if(!t)return null;if(t.id===e||t.nodeId===e||t.contentId===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=C(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},S=function(t,n){for(var e=0;e<t.length;e++){var o=C(t[e],String(e),n);if(o)return o}return null},w=new WeakMap,N=function(t){if(t){var n=w.get(t);null!=n&&(clearTimeout(n),w.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},j=function(t){if(t){var n=w.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){N(t)},3e3);w.set(t,e)}},O=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return j(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?i():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}},k=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",u),e())},u=function(){return i()};t.addEventListener("scrollend",u),t.scrollTo({top:n,behavior:"smooth"}),o=setTimeout(i,800)}},E=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",u),e())},u=function(){clearTimeout(o),o=setTimeout(i,n)};t.addEventListener("scroll",u),o=setTimeout(i,n)})};export{v as DEVIATION_BADGE_SEPARATOR,d as areMarkdownPropsEqual,c as debounce,y as extractDeviationScore,S as findKeyPathByNodeId,b as findTextMatchRange,s as generateColorPalette,o as getAlphabeticSuffix,_ as getBentArrowPath,A as getFirstDeviationColor,B as getFirstDeviationOutputValue,m as getLhsDeviationDisplayIndexes,a as getRationale,r as getRhsMappedSectionNumber,l as getSideData,g as hasMeaningfulRedlineTags,i as hasSingleMappedLhsSection,e as hasValue,j as highlightClause,f as isMissingStr,M as mixHexColors,C as recursivelyFindSubSectionIdxById,N as resetClauseHighlight,u as resolveComparisonInputItems,n as safeStringify,O as scrollAndHighlightClause,k as scrollAndWait,x as smoothScrollTo,h as stripRedlineTags,E as waitForScrollIdle};
|
|
1
|
+
import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))},o=function(t){for(var n=t+1,e="";n>0;){n-=1;e=String.fromCharCode(97+n%26)+e,n=Math.floor(n/26)}return e},r=function(t){var n=t.section,e=t.proposedSections,r=t.leftNums,i=t.fallbackNumber,u=t.firstOnly,l=void 0!==u&&u;if(!(null==n?void 0:n.id))return i;var a=(e||[]).map(function(t){var e=Array.isArray(null==t?void 0:t.refIndexes)?t.refIndexes:[],i=e.findIndex(function(t){return t===n.selfIndex});if(-1===i)return null;var u=(null==t?void 0:t.id)?r.get(t.id):void 0;return null==u?null:e.length>1?"".concat(u).concat(o(i)):String(u)}).filter(Boolean);return 0===a.length?i:l?a[0]:a.join(", ")},i=function(t,n){return null!=(null==t?void 0:t.selfIndex)&&1===(n||[]).filter(function(n){return Array.isArray(null==n?void 0:n.refIndexes)&&n.refIndexes.includes(t.selfIndex)}).length},u=function(t,n,e,o){var r;void 0===o&&(o={});var i=e[n],u=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return u?(Array.isArray(u)?u:[u]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=o[t];return e&&"object"==typeof e&&e?{contentId:t,data:e,attributes:e.additional_attributes||{}}:null}return t&&"object"==typeof t?{contentId:t.content_id||t.id||"".concat(i,"-direct-").concat(n),data:t,attributes:t.additional_attributes||{}}:null}).filter(Boolean):[]},l=function(t,e,o,r){var i,l,a;void 0===r&&(r={});var s=u(t,e,o,r),c=(null===(i=s[0])||void 0===i?void 0:i.data)||{},d=(null===(l=s[0])||void 0===l?void 0:l.attributes)||null;return{title:n((null==c?void 0:c.title)||""),content:n((null==c?void 0:c.content)||""),change_history:n((null==c?void 0:c.change_history)||""),attributes:d,subsections:(null==c?void 0:c.subsections)||[],contentId:null===(a=s[0])||void 0===a?void 0:a.contentId,allItems:s}},a=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}};function s(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}}function c(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}}var d=function(t,n){var e,o,r,i,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if(d[c].showScrollLockToggle!==v[c].showScrollLockToggle)return!1;if(d[c].scrollSyncLocked!==v[c].scrollSyncLocked)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=v[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=d[c].style)||void 0===u?void 0:u.badgeText)!==(null===(l=v[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},v="::",f=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},g=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},h=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},p=function(t,n){for(var e="",o=[],r=[],i=0;i<t.length;i+=1){var u=t[i],l=n&&/[\.,;:]/.test(u),a=/\s/.test(u)||l?" ":/[’‘`]/.test(u)?"'":/[”“]/.test(u)?'"':/[—–]/.test(u)?"-":u;" "===a&&e.endsWith(" ")?r[r.length-1]=i+1:(e+=a,o.push(i),r.push(i+1))}return{text:e,starts:o,ends:r}},b=function(t,n,e){if(void 0===e&&(e=!1),!t||!n)return null;var o=t.toLowerCase().indexOf(n.toLowerCase());if(-1!==o)return{start:o,end:o+n.length};var r=p(t,e),i=p(n,e).text.trim().toLowerCase();if(!i)return null;var u=r.text.toLowerCase().indexOf(i);if(-1===u)return null;var l=u+i.length-1,a=r.starts[u],s=r.ends[l];return void 0===a||void 0===s?null:{start:a,end:s}},m=function(t,e,o){var r=new Map;if(!e)return r;var i=function(t){var e=g(t)?h(t):n(t||"");return n(e).replace(/\\n/g,"\n")};return(t||[]).forEach(function(t){var n=new Map,u=function(t){var r;if(t){var l=i(t.content);((null===(r=t.evaluationResults)||void 0===r?void 0:r.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(r){var u=(null==r?void 0:r.nodeId)||t.nodeId||t.id;Object.entries((null==r?void 0:r.deviations)||{}).forEach(function(t){var r=t[0],a=t[1][e],s=i(a);if(s&&!f(a)&&b(l,s)){var c="".concat(u).concat("::").concat(r),d=o[c];null!=d&&n.set(c,d)}})}),(t.subsections||[]).forEach(u)}};if(u(t),0!==n.size){var l=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){r.set(n,t-l+1)})}}),r},y=function(t,n){var e,o,r,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},_=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),u=o-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=u>0?1:-1,a=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*a),"V ".concat(o-l*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},x=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(c){null===a&&(a=c);var d,v=c-a;v<e?(t.scrollTop=(d=v,d/=e,l*(--d*d*d+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},T=["#B91C1C","#A16207","#1D4ED8","#000000"],I=function(t){var n=T.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?T.length:n},A=function(n){for(var e,o,r,i,u,l,a,s,c,d,v,f,g,h=[],p=0,b=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});p<b.length;p++){var m=b[p];(A=null===(i=null===(r=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[m])||void 0===o?void 0:o.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&h.push(A)}for(var y=0,_=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});y<_.length;y++){m=_[y];(A=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[m])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&h.push(A)}for(var x=0,T=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});x<T.length;x++){var A;m=T[x];(A=null===(v=null===(d=null===(c=null==n?void 0:n[m])||void 0===c?void 0:c.evaluation_outputs)||void 0===d?void 0:d.metadata)||void 0===v?void 0:v.label_color)&&h.push(A)}return 0===h.length?(null===(g=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t:h.sort(function(t,n){return I(t)-I(n)})[0]},C=function(t){for(var n,e,o,r,i,u,l,a,s,c=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<d.length;c++){var v=d[c];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[v])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){v=g[f];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var h=0,p=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});h<p.length;h++){var b;v=p[h];if(b=null===(a=null===(l=null==t?void 0:t[v])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},w=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),u=(r[0]+i[0])/2*.95,l=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(u)).concat(o(l)).concat(o(a))}catch(t){return"#FDE68A"}},B=function(t,n,e){if(!t)return null;if(t.id===e||t.nodeId===e||t.contentId===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=B(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},M=function(t,n){for(var e=0;e<t.length;e++){var o=B(t[e],String(e),n);if(o)return o}return null},S=new WeakMap,N=function(t){if(t){var n=S.get(t);null!=n&&(clearTimeout(n),S.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},L=function(t){if(t){var n=S.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){N(t)},3e3);S.set(t,e)}},j=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return L(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?i():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}},O=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",u),e())},u=function(){return i()};t.addEventListener("scrollend",u),t.scrollTo({top:n,behavior:"smooth"}),o=setTimeout(i,800)}},k=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",u),e())},u=function(){clearTimeout(o),o=setTimeout(i,n)};t.addEventListener("scroll",u),o=setTimeout(i,n)})};export{v as DEVIATION_BADGE_SEPARATOR,d as areMarkdownPropsEqual,c as debounce,y as extractDeviationScore,M as findKeyPathByNodeId,b as findTextMatchRange,s as generateColorPalette,o as getAlphabeticSuffix,_ as getBentArrowPath,A as getFirstDeviationColor,C as getFirstDeviationOutputValue,m as getLhsDeviationDisplayIndexes,a as getRationale,r as getRhsMappedSectionNumber,l as getSideData,g as hasMeaningfulRedlineTags,i as hasSingleMappedLhsSection,e as hasValue,L as highlightClause,f as isMissingStr,w as mixHexColors,B as recursivelyFindSubSectionIdxById,N as resetClauseHighlight,u as resolveComparisonInputItems,n as safeStringify,j as scrollAndHighlightClause,O as scrollAndWait,x as smoothScrollTo,h as stripRedlineTags,k as waitForScrollIdle};
|
|
2
2
|
//# sourceMappingURL=CognitiveComparehelpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as o,__assign as i}from"tslib";import{jsx as r}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as t}from"@mui/material";import l from"react-markdown";import a from"rehype-raw";import{SHARED_MARKDOWN_STYLES as n}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as d}from"../../CognitiveComparehelpers.js";import{processGuidelinesMarkdown as s}from"../utils/processGuidelinesMarkdown.js";var g=function(g){var
|
|
1
|
+
import{__spreadArray as o,__assign as i}from"tslib";import{jsx as r}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as t}from"@mui/material";import l from"react-markdown";import a from"rehype-raw";import{SHARED_MARKDOWN_STYLES as n}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as d}from"../../CognitiveComparehelpers.js";import{processGuidelinesMarkdown as s}from"../utils/processGuidelinesMarkdown.js";var g=function(g){var p=g.guidelinesData,v=g.deviationData,m=g.connectedSections,f=g.proposedSections,h=Array.from(m)[0],c=e(function(){var i;if(null==h||!v)return{targetHighlights:[],labelColor:""};var r="";"number"==typeof h?r=(null===(i=f[h])||void 0===i?void 0:i.nodeId)||"":"string"==typeof h&&(r=h.includes(u)?h.split(u)[0]:h.split("::")[0].split(":")[0]);var e=v[r];if(!e)return{targetHighlights:[],labelColor:""};var t=[],l=e.evaluation_result||{},a="";return Object.values(l).forEach(function(i){var r,e,l,n,u;(null===(r=null==i?void 0:i.deviation_highlights)||void 0===r?void 0:r.rulebook_guidelines)&&(t=o(o([],t,!0),i.deviation_highlights.rulebook_guidelines,!0),a=(null===(l=null===(e=i.evaluation_outputs)||void 0===e?void 0:e.metadata)||void 0===l?void 0:l.label_color)?d(null===(u=null===(n=i.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===u?void 0:u.label_color).bg:"")}),{targetHighlights:t.filter(Boolean),labelColor:a}},[h,v,f]),b=c.targetHighlights,C=c.labelColor,_=e(function(){return s({guidelinesData:p,targetHighlights:b,labelColor:C||"#FEF08A"})},[p,b,C]);return r(t,i({sx:i(i({padding:"0px 12px",marginTop:"12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},n),{overflow:"visible"})},{children:r(l,i({rehypePlugins:[a]},{children:_}))}))};export{g as default};
|
|
2
2
|
//# sourceMappingURL=GuidelinePanel.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as r}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import i from"react";import{Box as e,Divider as o,Stack as a,Skeleton as c}from"@mui/material";var m=["96%","88%","92%","72%","60%"],l=function(i){var o=i.index,l=i.lineCount;return n(e,{children:[t(a,r({direction:"row",alignItems:"center",spacing:1,sx:{mb:1.25}},{children:t(c,{variant:"text",width:"".concat(50+13*o%30,"%"),height:22,sx:{borderRadius:1}})})),t(a,r({spacing:.75},{children:Array.from({length:l}).map(function(r,n){return t(c,{variant:"text",width:m[(o+n)%m.length],height:16,sx:{borderRadius:.5}},n)})}))]})},d=function(a){var c=a.sectionCount,m=void 0===c?3:c;return t(e,r({sx:{p:2,display:"flex",flexDirection:"column",gap:2}},{children:Array.from({length:m}).map(function(r,e){return n(i.Fragment,{children:[t(l,{index:e,lineCount:3+e%3}),e<m-1&&t(o,{sx:{my:.5,borderColor:"#EEF0F4"}})]},e)})}))};export{d as GuidelineSkeleton};
|
|
2
|
+
//# sourceMappingURL=GuidelineSkeletonLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuidelineSkeletonLoader.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,safeStringify as x,stripRedlineTags as m,hasSingleMappedLhsSection as I,generateColorPalette as y,getLhsDeviationDisplayIndexes as b,isMissingStr as w,getRhsMappedSectionNumber as S,findTextMatchRange as R,DEVIATION_BADGE_SEPARATOR as _}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as F}from"../CognitiveCompareConstants.js";var M=function(M){var k,N,B,C,E,A,O,j,W,T,D,P,K,z,G,L=M.section,X=M.idx,H=M.columnKey,V=M.colRef,Y=M.mb,q=void 0===Y?1:Y,J=M.isExpanded,Q=M.onToggle,U=M.navigation,Z=M.parentNodeId,$=void 0===Z?"":Z,nn=p(),en=nn.showOpenNodeRef,on=nn.resolvedMarkdownStyles,tn=nn.maintainRelativeOrder,ln=nn.showDeviationBadges,rn=void 0!==ln&&ln,dn=nn.renderSubSectionAccordion,an=nn.treeData,un=nn.proposedSections,cn=nn.existingSections,sn=nn.deviationNumberRegistry,vn=nn.deviationParentRegistry,fn=nn.getBadgeRef,pn=nn.openSummaryPopup,hn=nn.getSectionCompareStyle,gn=nn.connectedSections,xn=nn.openMoreFunctionsPopup,mn=nn.isProposingFix,In=nn.proposingFixNodeId,yn=nn.isRedlineFlow,bn=nn.isSideBySide,wn=nn.activeSideBySideSection,Sn=nn.scrollSyncLocked,Rn=nn.unifiedNumbering,_n=nn.toggleScrollSyncLocked,Fn=nn.summaryPopupAnchorEl,Mn="".concat(bn?"1":"0","-").concat(String(null!=wn?wn:"")),kn=(null===(k=L.displayTitle)||void 0===k||k)&&h(L.title),Nn=!(!mn||!In||"left"!==H||L.id!==In&&L.nodeId!==In),Bn=g(L.content),Cn="boolean"==typeof yn?yn:Bn,En=Bn,An=Cn&&Bn,On=An?h(L.change_history)?x(L.change_history):m(L.content):L.content,jn=An?L.content:void 0,Wn=(null===(N=L.displayContent)||void 0===N||N||Bn)&&h(L.content),Tn=!kn&&!Wn,Dn=L.title;kn||(Dn=Wn?"No Title Found":"No Matching Section Found");var Pn="left"===H&&(L.isMultipleMapping||(null!==(C=null===(B=L.refContentIds)||void 0===B?void 0:B.length)&&void 0!==C?C:1)>1),Kn="left"===H&&Dn.length>29?"".concat(Dn.slice(0,29).trimEnd(),"..."):Dn,zn=L.evaluationResult;if(!zn&&"right"===H)if(tn){var Gn=null===(E=L.refIndexes)||void 0===E?void 0:E[0],Ln=un.find(function(n){return n.selfIndex===Gn});zn=null==Ln?void 0:Ln.evaluationResult}else zn=null===(A=un[X])||void 0===A?void 0:A.evaluationResult;var Xn=null===(O=null==an?void 0:an.input_index_map)||void 0===O?void 0:O[0],Hn=null===(j=null==an?void 0:an.input_index_map)||void 0===j?void 0:j[1],Vn="left"===H?Hn:Xn,Yn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Yn(l.subsections,e);if(r)return r}}return null},qn="left"===H?L:Yn(un,L.id),Jn="right"===H?L:Yn(cn,L.id),Qn=o.useMemo(function(){if(!tn)return 0;var n=1/0,e=function(n){var e=g(n)?m(n):n;return x(e||"").replace(/\\n/g,"\n")},i=function(o,t,l,r){if(o){var d=o.nodeId||o.id;if(r&&"right"===H){var a=un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(d=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var r,a=null===(r=s[i])||void 0===r?void 0:r[$];if(function(n,i){if("string"!=typeof i||w(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&!!R(o,t)}("left"===H?t||o:l||o,a)){var c="".concat(d).concat(_).concat(i),v=null==sn?void 0:sn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(_).concat(i),p=null==sn?void 0:sn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===H?un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(L.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return cn.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(L,qn,Jn,!0);return n!==1/0?n-1:0},[L,qn,Jn,H,$,sn,tn,un,cn]);if(tn)if("left"===H){var Un=null===(W=L.refIndexes)||void 0===W?void 0:W[0],Zn=cn.findIndex(function(n){return n.selfIndex===Un});Jn=-1!==Zn?cn[Zn]:Yn(cn,L.id)}else{var $n=null===(T=L.refIndexes)||void 0===T?void 0:T[0],ne=un.findIndex(function(n){return n.selfIndex===$n});qn=-1!==ne?un[ne]:Yn(un,L.id)}var ee="left"===H?!Jn:!qn,ie=tn&&"right"===H&&I(L,un),oe=zn||(null==qn?void 0:qn.evaluationResult)||(null==Jn?void 0:Jn.evaluationResult),te=null!==(K=null===(P=null===(D=null==oe?void 0:oe.evaluation_outputs)||void 0===D?void 0:D.metadata)||void 0===P?void 0:P.label_color)&&void 0!==K?K:F,le=y(te).highlightBg,re=(null==oe?void 0:oe.deviations)||{},de=o.useMemo(function(){return tn&&"right"===H?b(un,Xn,sn):new Map},[tn,H,un,Xn,sn]),ae=L.nodeId||L.id;if(tn&&"left"!==H){var ue=un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(L.selfIndex)});ue.length>0?ae=ue[0].nodeId||ue[0].id:(null==qn?void 0:qn.id)&&(ae=qn.nodeId||qn.id)}var ce=o.useMemo(function(){var n,e=new Map;if(!tn||"right"!==H)return e;var i=1,o=un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(L.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return x(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?o[0]:Yn(un,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var d=function(n,e){if(void 0===e&&(e=!1),n){var o=r(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],r=o[$],d=l(r);if(!!t&&!w(o[Vn])&&d&&R(c,d)){var a="".concat(u).concat(_).concat(e),s=sn[a];null!=s&&(i=Math.max(i,Math.max(1,s-(Qn||0))+1))}}),(n.subsections||[]).forEach(function(n){return d(n)})}};d(L,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=r(n,o),d=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i,o,t=n[0],r=n[1],a=r[$],u=!d||w(r[Vn]),s=l(a),f=s&&null!==(i=null===(e=R(v,s))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(_).concat(t);return{refId:p,isRenderable:u&&!!s&&!w(a),position:f,registryIndex:null!==(o=sn[p])&&void 0!==o?o:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(L,!0),e},[tn,H,L,un,$,Vn,sn,Qn]),se=Object.keys(re)[0],ve=se?"".concat(ae).concat(_).concat(se):null,fe=ve?null==vn?void 0:vn[ve]:null,pe=X+1;if(tn&&Rn){var he="left"===H?Rn.leftNums.get(null==L?void 0:L.id):Rn.rightNums.get(null==L?void 0:L.id);ee&&void 0!==he?pe=he:null!=fe&&fe>=0?pe=fe:void 0!==he&&(pe=he)}else null!=fe&&fe>=0&&(pe=fe);var ge=Object.entries(re).map(function(n){var e=n[0],i=n[1],o="".concat(ae).concat(_).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:sn[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ge.sort(function(n,e){return n.currentIndex-e.currentIndex});var xe,me,Ie=ge.map(function(e){var i,o,t,l,r,d,a=e.deviationKey,u=e.deviationMap,c=e.refId,s=e.currentIndex,v=u[$],f=w(v);if(f)v="";else if(!v)return null;var p=X,h=X;if(tn)if("left"===H){var g=null===(i=L.refIndexes)||void 0===i?void 0:i[0],x=cn.findIndex(function(n){return n.selfIndex===g});if(-1!==x)h=x;else{var m=cn.findIndex(function(n){return n.id===L.id||n.nodeId===L.nodeId||n.contentId===L.contentId});h=-1!==m?m:X}}else{var I=null===(o=L.refIndexes)||void 0===o?void 0:o[0],b=un.findIndex(function(n){return n.selfIndex===I});if(-1!==b)p=b;else p=-1!==(A=un.findIndex(function(n){return n.id===L.id||n.nodeId===L.nodeId||n.contentId===L.contentId}))?A:X}var R="".concat(ae).concat(_).concat(a).concat(_).concat(p).concat(_).concat(h),F=u[Vn],M=ee||w(F),k=ce.get(c),N=de.get(c);tn&&"right"===H&&M&&void 0!==k?s=k:tn&&"right"===H&&!M&&void 0!==N?s=N:tn&&void 0!==Qn&&("right"!==H||M||ie)&&(s-=Qn),s=Math.max(1,s);var B=tn&&"right"===H&&M&&Rn?S({section:L,proposedSections:un,leftNums:Rn.leftNums,fallbackNumber:String(pe),firstOnly:!0}):pe,C="".concat(B,".").concat(s),E=X;if("right"===H&&tn){var A,O=null===(t=L.refIndexes)||void 0===t?void 0:t[0],j=un.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=un.findIndex(function(n){return n.id===L.id||n.nodeId===L.nodeId||n.contentId===L.contentId}))&&(E=A)}var W=hn?hn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==oe?void 0:oe.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(d=null===(r=null==T?void 0:T.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:te,K=y(P),z=W?n(n({},W),{badgeBg:K.badgeBg,badgeBorder:K.badgeBorder,badgeText:K.badgeText}):n({},K),G=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==oe?void 0:oe.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==oe?void 0:oe.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==oe?void 0:oe.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==oe?void 0:oe.cognitive_decisioning)}:null,V=0,Y=On||"";if(v&&Y){var q=Y.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(re).filter(function(n){n[0];var e=n[1][$];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][$])-q[J].indexOf(e[1][$])}),U=Q.filter(function(n){n[0];var e=n[1][$];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(V=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var Z=fn(H,c);return{id:c,actionId:R,label:C,highlight:v,side:H,style:z,stackIndex:V,score:D,isConnected:null==gn?void 0:gn.has(R),showScrollLockToggle:(null==gn?void 0:gn.has(R))||bn&&wn===R||!!Fn&&Fn===Z.current,scrollSyncLocked:Sn,toggleScrollSyncLocked:_n,isOrphan:M,isMissingClause:f,badgeRef:Z,onClick:function(n){n.stopPropagation(),xn&&xn(n,qn||{id:"orphan-left",title:"",content:""},M,Jn||{id:"orphan-right",title:"",content:""},R,z)},onSummaryClick:function(n){n.stopPropagation(),pn(n,R,M,G)}}}).filter(Boolean),ye=rn||!Cn&&Nn?Ie:[],be=Ie.map(function(n){return n.highlight}).filter(Boolean),we=L.id&&H===(null==U?void 0:U.columnKey)?U:null,Se=o.useRef(!1);return t(function(){J||(Se.current=!1)},[J]),e(l,n({ref:V,sx:{mb:q,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[J&&(null==we?void 0:we.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==we?void 0:we.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===H?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===H?{right:"-20px"}:{left:"-20px"})},{children:i(s,{color:(null===(z=null==we?void 0:we.showAboveRef)||void 0===z?void 0:z.current)?window.getComputedStyle(we.showAboveRef.current).color:void 0})}))})),e(r,n({disableGutters:!0,expanded:!Tn&&J,onChange:function(){Tn||(Q(),en.current=L.id)},sx:{boxShadow:"none",border:Tn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Tn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[i(d,n({expandIcon:Tn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Tn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:kn&&i(a,n({title:Dn,placement:"top"},{children:i(u,n({component:"div",sx:{fontSize:"12px",color:Tn?"#94A3B8":"#19213D",fontWeight:Tn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(xe=Kn,me=Pn,void 0===me&&(me=!1),xe?x(xe).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(o,t){return o.startsWith("**")&&o.endsWith("**")?i("strong",{children:o.slice(2,-2)},t):e("div",n({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[i("span",n({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:o})),me&&i("span",n({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!Tn&&e(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Wn&&i(f,{content:On,overlayContent:jn,sxStyles:on,highlights:be,maintainRelativeOrder:tn,highlightBg:le,suppressHighlightBg:En,deviationBadges:ye,collisionKey:Mn}),(L.subsections||[]).map(function(n,e){return dn({section:n,keyPath:"".concat(X,"-").concat(e),depth:0,columnKey:H,parentNodeId:$,sectionOffset:Qn,rhsOrphanVisualIndexes:ce})})]}))]})),J&&(null==we?void 0:we.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==we?void 0:we.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===H?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===H?{right:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(G=null==we?void 0:we.showBelowRef)||void 0===G?void 0:G.current)?window.getComputedStyle(we.showBelowRef.current).color:void 0})}))}))]}),"".concat(H,"-sec-").concat(X))};export{M as default};
|
|
1
|
+
import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,stripRedlineTags as x,hasSingleMappedLhsSection as m,generateColorPalette as I,getLhsDeviationDisplayIndexes as y,isMissingStr as b,getRhsMappedSectionNumber as w,safeStringify as S,findTextMatchRange as R,DEVIATION_BADGE_SEPARATOR as _}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as F}from"../CognitiveCompareConstants.js";var M=function(M){var k,N,B,C,E,A,O,j,W,T,D,P,K,z,G,L=M.section,X=M.idx,H=M.columnKey,V=M.colRef,Y=M.mb,q=void 0===Y?1:Y,J=M.isExpanded,Q=M.onToggle,U=M.navigation,Z=M.parentNodeId,$=void 0===Z?"":Z,nn=p(),en=nn.showOpenNodeRef,on=nn.resolvedMarkdownStyles,tn=nn.maintainRelativeOrder,ln=nn.showDeviationBadges,rn=void 0!==ln&&ln,dn=nn.renderSubSectionAccordion,an=nn.treeData,un=nn.proposedSections,cn=nn.existingSections,sn=nn.deviationNumberRegistry,vn=nn.deviationParentRegistry,fn=nn.getBadgeRef,pn=nn.openSummaryPopup,hn=nn.getSectionCompareStyle,gn=nn.connectedSections,xn=nn.openMoreFunctionsPopup,mn=nn.isProposingFix,In=nn.proposingFixNodeId,yn=nn.isRedlineFlow,bn=nn.isSideBySide,wn=nn.activeSideBySideSection,Sn=nn.scrollSyncLocked,Rn=nn.unifiedNumbering,_n=nn.toggleScrollSyncLocked,Fn=nn.summaryPopupAnchorEl,Mn="".concat(bn?"1":"0","-").concat(String(null!=wn?wn:"")),kn=(null===(k=L.displayTitle)||void 0===k||k)&&h(L.title),Nn=!(!mn||!In||"left"!==H||L.id!==In&&L.nodeId!==In),Bn=g(L.content),Cn="boolean"==typeof yn?yn:Bn,En=Bn,An=Cn&&Bn,On=An?x(L.content):L.content,jn=An?L.content:void 0,Wn=(null===(N=L.displayContent)||void 0===N||N||Bn)&&h(L.content),Tn=!kn&&!Wn,Dn=L.title;kn||(Dn=Wn?"No Title Found":"No Matching Section Found");var Pn="left"===H&&(L.isMultipleMapping||(null!==(C=null===(B=L.refContentIds)||void 0===B?void 0:B.length)&&void 0!==C?C:1)>1),Kn="left"===H&&Dn.length>29?"".concat(Dn.slice(0,29).trimEnd(),"..."):Dn,zn=L.evaluationResult;if(!zn&&"right"===H)if(tn){var Gn=null===(E=L.refIndexes)||void 0===E?void 0:E[0],Ln=un.find(function(n){return n.selfIndex===Gn});zn=null==Ln?void 0:Ln.evaluationResult}else zn=null===(A=un[X])||void 0===A?void 0:A.evaluationResult;var Xn=null===(O=null==an?void 0:an.input_index_map)||void 0===O?void 0:O[0],Hn=null===(j=null==an?void 0:an.input_index_map)||void 0===j?void 0:j[1],Vn="left"===H?Hn:Xn,Yn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Yn(l.subsections,e);if(r)return r}}return null},qn="left"===H?L:Yn(un,L.id),Jn="right"===H?L:Yn(cn,L.id),Qn=o.useMemo(function(){if(!tn)return 0;var n=1/0,e=function(n){var e=g(n)?x(n):n;return S(e||"").replace(/\\n/g,"\n")},i=function(o,t,l,r){if(o){var d=o.nodeId||o.id;if(r&&"right"===H){var a=un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(d=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var r,a=null===(r=s[i])||void 0===r?void 0:r[$];if(function(n,i){if("string"!=typeof i||b(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&!!R(o,t)}("left"===H?t||o:l||o,a)){var c="".concat(d).concat(_).concat(i),v=null==sn?void 0:sn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(_).concat(i),p=null==sn?void 0:sn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===H?un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(L.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return cn.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(L,qn,Jn,!0);return n!==1/0?n-1:0},[L,qn,Jn,H,$,sn,tn,un,cn]);if(tn)if("left"===H){var Un=null===(W=L.refIndexes)||void 0===W?void 0:W[0],Zn=cn.findIndex(function(n){return n.selfIndex===Un});Jn=-1!==Zn?cn[Zn]:Yn(cn,L.id)}else{var $n=null===(T=L.refIndexes)||void 0===T?void 0:T[0],ne=un.findIndex(function(n){return n.selfIndex===$n});qn=-1!==ne?un[ne]:Yn(un,L.id)}var ee="left"===H?!Jn:!qn,ie=tn&&"right"===H&&m(L,un),oe=zn||(null==qn?void 0:qn.evaluationResult)||(null==Jn?void 0:Jn.evaluationResult),te=null!==(K=null===(P=null===(D=null==oe?void 0:oe.evaluation_outputs)||void 0===D?void 0:D.metadata)||void 0===P?void 0:P.label_color)&&void 0!==K?K:F,le=I(te).highlightBg,re=(null==oe?void 0:oe.deviations)||{},de=o.useMemo(function(){return tn&&"right"===H?y(un,Xn,sn):new Map},[tn,H,un,Xn,sn]),ae=L.nodeId||L.id;if(tn&&"left"!==H){var ue=un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(L.selfIndex)});ue.length>0?ae=ue[0].nodeId||ue[0].id:(null==qn?void 0:qn.id)&&(ae=qn.nodeId||qn.id)}var ce=o.useMemo(function(){var n,e=new Map;if(!tn||"right"!==H)return e;var i=1,o=un.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(L.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return S(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?o[0]:Yn(un,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var d=function(n,e){if(void 0===e&&(e=!1),n){var o=r(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],r=o[$],d=l(r);if(!!t&&!b(o[Vn])&&d&&R(c,d)){var a="".concat(u).concat(_).concat(e),s=sn[a];null!=s&&(i=Math.max(i,Math.max(1,s-(Qn||0))+1))}}),(n.subsections||[]).forEach(function(n){return d(n)})}};d(L,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=r(n,o),d=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i,o,t=n[0],r=n[1],a=r[$],u=!d||b(r[Vn]),s=l(a),f=s&&null!==(i=null===(e=R(v,s))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(_).concat(t);return{refId:p,isRenderable:u&&!!s&&!b(a),position:f,registryIndex:null!==(o=sn[p])&&void 0!==o?o:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(L,!0),e},[tn,H,L,un,$,Vn,sn,Qn]),se=Object.keys(re)[0],ve=se?"".concat(ae).concat(_).concat(se):null,fe=ve?null==vn?void 0:vn[ve]:null,pe=X+1;if(tn&&Rn){var he="left"===H?Rn.leftNums.get(null==L?void 0:L.id):Rn.rightNums.get(null==L?void 0:L.id);ee&&void 0!==he?pe=he:null!=fe&&fe>=0?pe=fe:void 0!==he&&(pe=he)}else null!=fe&&fe>=0&&(pe=fe);var ge=Object.entries(re).map(function(n){var e=n[0],i=n[1],o="".concat(ae).concat(_).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:sn[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ge.sort(function(n,e){return n.currentIndex-e.currentIndex});var xe,me,Ie=ge.map(function(e){var i,o,t,l,r,d,a=e.deviationKey,u=e.deviationMap,c=e.refId,s=e.currentIndex,v=u[$],f=b(v);if(f)v="";else if(!v)return null;var p=X,h=X;if(tn)if("left"===H){var g=null===(i=L.refIndexes)||void 0===i?void 0:i[0],x=cn.findIndex(function(n){return n.selfIndex===g});if(-1!==x)h=x;else{var m=cn.findIndex(function(n){return n.id===L.id||n.nodeId===L.nodeId||n.contentId===L.contentId});h=-1!==m?m:X}}else{var y=null===(o=L.refIndexes)||void 0===o?void 0:o[0],S=un.findIndex(function(n){return n.selfIndex===y});if(-1!==S)p=S;else p=-1!==(A=un.findIndex(function(n){return n.id===L.id||n.nodeId===L.nodeId||n.contentId===L.contentId}))?A:X}var R="".concat(ae).concat(_).concat(a).concat(_).concat(p).concat(_).concat(h),F=u[Vn],M=ee||b(F),k=ce.get(c),N=de.get(c);tn&&"right"===H&&M&&void 0!==k?s=k:tn&&"right"===H&&!M&&void 0!==N?s=N:tn&&void 0!==Qn&&("right"!==H||M||ie)&&(s-=Qn),s=Math.max(1,s);var B=tn&&"right"===H&&M&&Rn?w({section:L,proposedSections:un,leftNums:Rn.leftNums,fallbackNumber:String(pe),firstOnly:!0}):pe,C="".concat(B,".").concat(s),E=X;if("right"===H&&tn){var A,O=null===(t=L.refIndexes)||void 0===t?void 0:t[0],j=un.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=un.findIndex(function(n){return n.id===L.id||n.nodeId===L.nodeId||n.contentId===L.contentId}))&&(E=A)}var W=hn?hn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==oe?void 0:oe.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(d=null===(r=null==T?void 0:T.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:te,K=I(P),z=W?n(n({},W),{badgeBg:K.badgeBg,badgeBorder:K.badgeBorder,badgeText:K.badgeText}):n({},K),G=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==oe?void 0:oe.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==oe?void 0:oe.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==oe?void 0:oe.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==oe?void 0:oe.cognitive_decisioning)}:null,V=0,Y=On||"";if(v&&Y){var q=Y.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(re).filter(function(n){n[0];var e=n[1][$];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][$])-q[J].indexOf(e[1][$])}),U=Q.filter(function(n){n[0];var e=n[1][$];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(V=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var Z=fn(H,c);return{id:c,actionId:R,label:C,highlight:v,side:H,style:z,stackIndex:V,score:D,isConnected:null==gn?void 0:gn.has(R),showScrollLockToggle:(null==gn?void 0:gn.has(R))||bn&&wn===R||!!Fn&&Fn===Z.current,scrollSyncLocked:Sn,toggleScrollSyncLocked:_n,isOrphan:M,isMissingClause:f,badgeRef:Z,onClick:function(n){n.stopPropagation(),xn&&xn(n,qn||{id:"orphan-left",title:"",content:""},M,Jn||{id:"orphan-right",title:"",content:""},R,z)},onSummaryClick:function(n){n.stopPropagation(),pn(n,R,M,G)}}}).filter(Boolean),ye=rn||!Cn&&Nn?Ie:[],be=Ie.map(function(n){return n.highlight}).filter(Boolean),we=L.id&&H===(null==U?void 0:U.columnKey)?U:null,Se=o.useRef(!1);return t(function(){J||(Se.current=!1)},[J]),e(l,n({ref:V,sx:{mb:q,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[J&&(null==we?void 0:we.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==we?void 0:we.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===H?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===H?{right:"-20px"}:{left:"-20px"})},{children:i(s,{color:(null===(z=null==we?void 0:we.showAboveRef)||void 0===z?void 0:z.current)?window.getComputedStyle(we.showAboveRef.current).color:void 0})}))})),e(r,n({disableGutters:!0,expanded:!Tn&&J,onChange:function(){Tn||(Q(),en.current=L.id)},sx:{boxShadow:"none",border:Tn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Tn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[i(d,n({expandIcon:Tn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Tn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:kn&&i(a,n({title:Dn,placement:"top"},{children:i(u,n({component:"div",sx:{fontSize:"12px",color:Tn?"#94A3B8":"#19213D",fontWeight:Tn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(xe=Kn,me=Pn,void 0===me&&(me=!1),xe?S(xe).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(o,t){return o.startsWith("**")&&o.endsWith("**")?i("strong",{children:o.slice(2,-2)},t):e("div",n({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[i("span",n({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:o})),me&&i("span",n({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!Tn&&e(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Wn&&i(f,{content:On,overlayContent:jn,sxStyles:on,highlights:be,maintainRelativeOrder:tn,highlightBg:le,suppressHighlightBg:En,deviationBadges:ye,collisionKey:Mn}),(L.subsections||[]).map(function(n,e){return dn({section:n,keyPath:"".concat(X,"-").concat(e),depth:0,columnKey:H,parentNodeId:$,sectionOffset:Qn,rhsOrphanVisualIndexes:ce})})]}))]})),J&&(null==we?void 0:we.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==we?void 0:we.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===H?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===H?{right:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(G=null==we?void 0:we.showBelowRef)||void 0===G?void 0:G.current)?window.getComputedStyle(we.showBelowRef.current).color:void 0})}))}))]}),"".concat(H,"-sec-").concat(X))};export{M as default};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|