@viswa-test/test-citation 0.0.285 → 0.0.286

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.
Files changed (32) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  7. package/dist/cjs/features/GptWebCitation/GptWebCitation.js +1 -1
  8. package/dist/cjs/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  9. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  10. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  11. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  12. package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  13. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  14. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  15. package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
  16. package/dist/features/GptWebCitation/utils/fixedHeight.utils.js +1 -1
  17. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  18. package/dist/types/src/features/CognitiveCompare/CognitiveCompareConstants.d.ts +0 -1
  19. package/dist/types/src/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
  20. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts +5 -0
  21. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts.map +1 -1
  22. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  23. package/dist/types/src/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
  24. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  25. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +0 -11
  26. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  27. package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
  28. package/dist/types/src/features/GptWebCitation/types.d.ts +7 -0
  29. package/dist/types/src/features/GptWebCitation/types.d.ts.map +1 -1
  30. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts +2 -0
  31. package/dist/types/src/features/GptWebCitation/utils/fixedHeight.utils.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),r=require("react"),i=require("../CognitiveCompareConstants.js"),a=require("lucide-react"),o=require("react-markdown"),s=require("../CognitiveComparehelpers.js"),l=require("rehype-raw"),d=require("remark-gfm"),c=require("../utils/normalizeRedlineMarkdown.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=u(r),g=u(o),h=u(l),f=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},v=[f(u(d).default)],x=[f(h.default)],m=new Set(["address","article","aside","blockquote","br","caption","dd","div","dl","dt","figcaption","figure","footer","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]),_=new Set(["updated","deleted","changed","change"]),b=function(e){return function(e){var n={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:'"'};return e.replace(/&#(\d+);/g,function(e,n){return String.fromCodePoint(Number(n))}).replace(/&#x([\da-f]+);/gi,function(e,n){return String.fromCodePoint(parseInt(n,16))}).replace(/&([a-z]+);/gi,function(e,t){var r;return null!==(r=n[t.toLowerCase()])&&void 0!==r?r:e})}(c.normalizeRedlineMarkdown(e||"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/<[^>]+>/g," ").split(/\r?\n/).filter(function(e){return!/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}).map(function(e){return e.replace(/\|/g," ")}).join("\n").replace(/^\s{0,3}(?:#{1,6}|>|[-+*]|\d+[.)])\s+/gm,"").replace(/(\*\*|__|~~|`)/g,"").replace(/\\([\\`*{}\[\]()#+\-.!_>])/g,"$1")).normalize("NFC")},y=function(e){for(var n=[],t=0;t<e.length;){var r=e.codePointAt(t);if(void 0===r)break;var i=String.fromCodePoint(r),a=t+i.length;if(/\p{M}/u.test(i)&&n.length>0){var o=n[n.length-1];o.value="".concat(o.value).concat(i).normalize("NFC"),o.end=a}else n.push({value:i.normalize("NFC"),start:t,end:a});t=a}var s="",l=[],d=[];return n.forEach(function(e){var n=e.value,t=e.start,r=e.end,i=/\s/.test(n)||/[\.,;:]/.test(n)?" ":/[’‘`]/.test(n)?"'":/[”“]/.test(n)?'"':/[—–]/.test(n)?"-":n;if(" "===i&&s.endsWith(" "))d[d.length-1]=r;else{s+=i;for(var a=0;a<i.length;a+=1)l.push(t),d.push(r)}}),{text:s.toLowerCase(),starts:l,ends:d}},w=function(n){return void 0===n&&(n={}),function(t){var r=n.specs||[];if(r.length&&t){var i="",a=[],o=function(){i&&!/\s$/.test(i)&&(i+="\n")},l=function(e,n,t,r){if(e){if("text"===e.type){var s=String(e.value||"");if(!s)return;var d=i.length;return i+=s,void a.push({node:e,parent:n,index:t,start:d,end:i.length,eligible:!r})}var c=String(e.tagName||"").toLowerCase();if("script"!==c&&"style"!==c){var u=m.has(c);u&&o();var p=r||_.has(c);(e.children||[]).forEach(function(n,t){return l(n,e,t,p)}),u&&o()}}};l(t,null,0,!1);var d=r.flatMap(function(t){var r=function(e,n){var t=y(e),r=y(n).text.trim();if(!r)return[];for(var i=[],a=0;a<t.text.length;){var o=t.text.indexOf(r,a);if(-1===o)break;var s=o+r.length-1,l=t.starts[o],d=t.ends[s];void 0!==l&&void 0!==d&&i.push({start:l,end:d}),a=o+1}return i}(i,t.text).find(function(e){var t=e.start,r=e.end,i=a.filter(function(e){return t<e.end&&r>e.start});return i.length>0&&(!n.excludeRedlines||i.every(function(e){return e.eligible}))});return r?[e.__assign(e.__assign({},r),{spec:t})]:[]});if(d.length){d.sort(function(e,n){return e.start-n.start||n.end-e.end});var c=new Set,u=[];a.forEach(function(t){var r=d.filter(function(e){return e.start<t.end&&e.end>t.start});if(r.length){var i=new Set([0,t.end-t.start]);r.forEach(function(e){i.add(Math.max(0,e.start-t.start)),i.add(Math.min(t.end-t.start,e.end-t.start))});for(var a=Array.from(i).sort(function(e,n){return e-n}),o=[],l=function(i){var l=a[i],d=a[i+1];if(l>=d)return"continue";var u=t.start+l,p=t.start+d,g=String(t.node.value||"").slice(l,d),h=r.filter(function(e){return e.start<p&&e.end>u});if(!h.length)return o.push({type:"text",value:g}),"continue";var f=h.map(function(e){return e.spec.color}).reduce(function(e,n){return e?s.mixHexColors(e,n):n},""),v={type:"element",tagName:"mark",properties:e.__assign({"data-highlight-color":f},n.overlay?{"data-overlay-highlight":"true"}:{}),children:[{type:"text",value:g}]};n.overlay||h.forEach(function(e){e.spec.badgeIds.forEach(function(e){c.has(e)||(c.add(e),v={type:"element",tagName:"span",properties:{"data-badge-id":e},children:[v]})})}),o.push(v)},p=0;p<a.length-1;p+=1)l(p);u.push({parent:t.parent,index:t.index,children:o})}});var p=new Map;u.forEach(function(e){var n=p.get(e.parent)||[];n.push(e),p.set(e.parent,n)}),p.forEach(function(n,t){n.sort(function(e,n){return n.index-e.index}).forEach(function(n){var r,i=n.index,a=n.children;(null==t?void 0:t.children)&&(r=t.children).splice.apply(r,e.__spreadArray([i,1],a,!1))})})}}}},B=p.default.memo(function(o){var l=o.content,d=o.overlayContent,u=o.sxStyles,h=o.deviationBadges,f=void 0===h?[]:h,m=o.highlights,_=void 0===m?[]:m;o.maintainRelativeOrder;var y=o.highlightBg,B=o.suppressHighlightBg,E=void 0!==B&&B,C=o.collisionKey,S=r.useRef(null),k=!!d,j=r.useMemo(function(){return f.reduce(function(n,t){var r;return e.__assign(e.__assign({},n),((r={})[t.id]=t,r))},{})},[f]),F=r.useRef({badgeMap:j,highlightBg:y,hideHighlightBg:k,suppressHighlightBg:E});F.current={badgeMap:j,highlightBg:y,hideHighlightBg:k,suppressHighlightBg:E};var z=function(n,t){return p.default.Children.map(n,function(n){var r;if(!p.default.isValidElement(n))return n;var i=(null===(r=n.props)||void 0===r?void 0:r.children)?z(n.props.children,t):n.props.children,a=p.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:i}));return t(a)})},A=r.useMemo(function(){return{mark:function(t){var r,i,a,o,s=t.children,l=e.__rest(t,["children"]),d=F.current,c=d.badgeMap,u=d.highlightBg,p=d.hideHighlightBg,g=d.suppressHighlightBg,h=l["data-badge-id"],f=h?c[h]:null,v=l["data-highlight-color"],x=null!==(o=null!==(i=null!=v?v:null===(r=null==f?void 0:f.style)||void 0===r?void 0:r.highlightBg)&&void 0!==i?i:null===(a=null==f?void 0:f.style)||void 0===a?void 0:a.badgeBg)&&void 0!==o?o:u,m=!0===l["data-overlay-highlight"]||"true"===l["data-overlay-highlight"],_="true"===l["data-is-suggested-deviation-fix"]||g&&!m;return n.jsx("span",e.__assign({style:e.__assign(e.__assign(e.__assign({},_?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p&&!m?{color:"transparent"}:{})},{children:s}))},span:function(r){var o,s,l,d,c,u,p=r.children,g=e.__rest(r,["children"]),h=F.current.badgeMap,f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:p}));var v=h[f];if(!v)return n.jsx("span",e.__assign({},g,{children:p}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return n.jsxs(t.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(t.Box,e.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(o=v.style)||void 0===o?void 0:o.badgeBg)||"#EEF2FF",color:(null===(s=v.style)||void 0===s?void 0:s.badgeText)||i.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=v.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===v.side?{right:"-16px",transform:"".concat(m," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(m," translateX(calc(-100% - 8px))")}),v.isConnected&&v.style&&{outline:"2px solid ".concat(v.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&n.jsx(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onClick&&v.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(a.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),p]}))},table:function(r){var i=r.children;return n.jsx(t.Box,e.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:n.jsx(t.Box,e.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:i}))}))},thead:function(r){var i=r.children;return n.jsx(t.Box,e.__assign({component:"thead"},{children:i}))},tbody:function(r){var i=r.children;return n.jsx(t.Box,e.__assign({component:"tbody"},{children:i}))},tr:function(r){var i=r.children;return n.jsx(t.Box,e.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:i}))},th:function(r){var i=r.children;return n.jsx(t.Box,e.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:i}))},td:function(r){var i=r.children;return n.jsx(t.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:i}))},code:function(t){var r=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(t){var r=t.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(e){var t=e.children;return n.jsx(n.Fragment,{children:t})},deleted:function(t){var r=t.children,i=z(r,function(e){return p.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(t){var r=t.children,i=z(r,function(e){return p.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e.__rest(r,["children"]);return n.jsx(t.Box,e.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e.__rest(r,["children"]);return n.jsx(t.Box,e.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e.__rest(r,["children"]);return n.jsx(t.Box,e.__assign({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),M=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,r){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,r){return"".concat(n," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var r=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},T=r.useMemo(function(){return f.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[f]),I=r.useMemo(function(){var e=new Map;return(_||[]).forEach(function(n){var t=b(n||"");t&&!e.has(t)&&e.set(t,{text:t,color:y,badgeIds:[]})}),(f||[]).forEach(function(n){var t,r,i=b((null==n?void 0:n.highlight)||"");if(i){var a=(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.highlightBg)||(null===(r=null==n?void 0:n.style)||void 0===r?void 0:r.badgeBg)||y,o=e.get(i);o?(o.color=o.badgeIds.length?s.mixHexColors(o.color,a):a,(null==n?void 0:n.id)&&!o.badgeIds.includes(n.id)&&o.badgeIds.push(n.id)):e.set(i,{text:i,color:a,badgeIds:(null==n?void 0:n.id)?[n.id]:[]})}}),Array.from(e.values())},[f,_,y]),q=r.useMemo(function(){return M(c.normalizeRedlineMarkdown(l||""))},[l]),R=r.useMemo(function(){return d?M(c.normalizeRedlineMarkdown(d)):""},[d]),W=r.useMemo(function(){return e.__spreadArray(e.__spreadArray([],x,!0),[[w,{specs:I,excludeRedlines:!1,overlay:!1}]],!1)},[I]),N=r.useMemo(function(){return e.__spreadArray(e.__spreadArray([],x,!0),[[w,{specs:I,excludeRedlines:!0,overlay:!0}]],!1)},[I]),P=!!d,$={"& *":{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"}},O=e.__assign(e.__assign(e.__assign(e.__assign({},u),$),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),P?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden",margin:"0 !important"},"& p:empty":{display:"none"}}:{}),H=e.__assign(e.__assign(e.__assign({},u),$),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return r.useLayoutEffect(function(){if(S.current){var e=function(){var e=Array.from(S.current.querySelectorAll(".deviation-badge"));if(0!==e.length){e.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var n=e.filter(function(e){return"left"===e.dataset.side}),t=e.filter(function(e){return"left"!==e.dataset.side}),r=S.current.getBoundingClientRect(),i=r.bottom-4,a=r.top+4,o=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],r=[];n.forEach(function(e){if(0===r.length)r.push(e);else{var n=r[r.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,r.push(e)):(t.push(r),r=[e])}}),r.length>0&&t.push(r),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>i){var r=t-i,o=e[0].currentTop-a,s=Math.max(0,Math.min(r,o));e.forEach(function(e){e.currentTop-=s})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};o(n),o(t)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(S.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[q,C,T]),n.jsxs(t.Box,e.__assign({ref:S,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},O),{padding:"3px"})},{children:n.jsx(g.default,e.__assign({components:A,remarkPlugins:v,rehypePlugins:W},{children:q}))})),P&&n.jsx(t.Typography,e.__assign({component:"div",sx:H},{children:n.jsx(g.default,e.__assign({components:A,remarkPlugins:v,rehypePlugins:N},{children:R}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=B,exports.rehypeStructuredHighlights=w;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("@mui/material"),t=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"),c=require("../utils/normalizeRedlineMarkdown.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=u(t),g=u(a),p=u(l),f=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},v=[f(u(d).default)],x=[f(p.default)],m=h.default.memo(function(a){var l=a.content,d=a.overlayContent,u=a.sxStyles,p=a.deviationBadges,f=void 0===p?[]:p,m=a.highlights,_=void 0===m?[]:m;a.maintainRelativeOrder;var b=a.highlightBg,y=a.suppressHighlightBg,B=void 0!==y&&y,w=a.collisionKey,E=t.useRef(null),j=!!d,k=t.useMemo(function(){return f.reduce(function(n,i){var t;return e.__assign(e.__assign({},n),((t={})[i.id]=i,t))},{})},[f]),S=t.useRef({badgeMap:k,highlightBg:b,hideHighlightBg:j,suppressHighlightBg:B});S.current={badgeMap:k,highlightBg:b,hideHighlightBg:j,suppressHighlightBg:B};var C=function(n,i){return h.default.Children.map(n,function(n){var t;if(!h.default.isValidElement(n))return n;var r=(null===(t=n.props)||void 0===t?void 0:t.children)?C(n.props.children,i):n.props.children,o=h.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:r}));return i(o)})},F=t.useMemo(function(){return{mark:function(i){var t,r,o,a,s=i.children,l=e.__rest(i,["children"]),d=S.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===(t=null==f?void 0:f.style)||void 0===t?void 0:t.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 n.jsx("span",e.__assign({style:e.__assign(e.__assign(e.__assign({},m?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),h?{color:"transparent"}:{})},{children:s}))},span:function(t){var a,s,l,d,c,u,h=t.children,g=e.__rest(t,["children"]),p=S.current.badgeMap,f=g["data-badge-id"];if(!f)return n.jsx("span",e.__assign({},g,{children:h}));var v=p[f];if(!v)return n.jsx("span",e.__assign({},g,{children:h}));var x="number"==typeof v.stackIndex?v.stackIndex:0,m="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(i.Box,e.__assign({ref:v.badgeRef,className:"deviation-badge","data-side":v.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=v.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(s=v.style)||void 0===s?void 0:s.badgeText)||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:[n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onSummaryClick&&v.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:v.label})),("left"===v.side||v.isOrphan)&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=v.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=v.score&&"N/A"!==v.score&&"NA"!==v.score&&0!==v.score?"".concat(v.score):"N/A"===v.score||"NA"===v.score?"N/A":"Same"}))]})),("left"===v.side||v.isOrphan)&&n.jsx(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),v.onClick&&v.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(c=v.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(o.EllipsisVertical,{size:12,color:(null===(u=v.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),h]}))},table:function(t){var r=t.children;return n.jsx(i.Box,e.__assign({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:n.jsx(i.Box,e.__assign({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(t){var r=t.children;return n.jsx(i.Box,e.__assign({component:"thead"},{children:r}))},tbody:function(t){var r=t.children;return n.jsx(i.Box,e.__assign({component:"tbody"},{children:r}))},tr:function(t){var r=t.children;return n.jsx(i.Box,e.__assign({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(t){var r=t.children;return n.jsx(i.Box,e.__assign({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(t){var r=t.children;return n.jsx(i.Box,e.__assign({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(i){var t=i.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:t}))},pre:function(i){var t=i.children;return n.jsx("span",e.__assign({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:t}))},updated:function(e){var i=e.children;return n.jsx(n.Fragment,{children:i})},deleted:function(i){var t=i.children,r=C(t,function(e){return h.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:r}))},changed:function(i){var t=i.children,r=C(t,function(e){return h.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return n.jsx("span",e.__assign({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:r}))},ul:function(t){var r=t.children,o=e.__rest(t,["children"]);return n.jsx(i.Box,e.__assign({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},o,{children:r}))},ol:function(t){var r=t.children,o=e.__rest(t,["children"]);return n.jsx(i.Box,e.__assign({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},o,{children:r}))},li:function(t){var r=t.children,o=e.__rest(t,["children"]);return n.jsx(i.Box,e.__assign({component:"li",sx:{mb:.5,display:"list-item"}},o,{children:r}))}}},[]),M=function(e){if(!e||"string"!=typeof e)return"";var n=e,i=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,i,t){return"".concat(n).concat(i.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,i,t){return"".concat(n," ").concat(t)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(n=i.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,i){var t=e.slice(i+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(t)?"\n":" "})}).join("")).trim()},z=t.useMemo(function(){return f.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[f]),T=function(e){return M(c.normalizeRedlineMarkdown(e||""))},A=t.useMemo(function(){var n=M(c.normalizeRedlineMarkdown(l||"")),i=(f||[]).map(function(e){var n,i;return{id:null==e?void 0:e.id,highlight:T((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(i=null==e?void 0:e.style)||void 0===i?void 0:i.badgeBg)||b}}).filter(function(e){return e.id&&e.highlight}),t={};i.forEach(function(e){t[e.highlight]||(t[e.highlight]=[]),t[e.highlight].push(e)});var r=function(e,n,i,t){void 0===n&&(n=""),void 0===t&&(t=[]);var r=!1,o=function(e){var o=function(e,n,i){var t,r,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var s=null!==(t=a[1])&&void 0!==t?t:"",l=null!==(r=a[2])&&void 0!==r?r:"",d=null!==(o=a[3])&&void 0!==o?o:"";return l?s+function(e,n){void 0===e&&(e="");var i=n?' data-highlight-color="'.concat(n,'"'):"",t=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(t).concat(i,">")}(n,i)+l+"</mark>"+d:e}(e,n,i),a=o;if(!r&&t.length>0){r=!0;var s="",l="";t.forEach(function(e){s+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),l="</span>"+l}),a=s+o+l}return"​"+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},o=[];Object.entries(t).forEach(function(e){var i=e[0],t=e[1],r=B?s.findRedlineTextAnchorRange(n,i):s.findTextMatchRange(n,i,!1);if(r){for(var a=n.slice(r.start,r.end)!==i,l=t[0].highlightColor,d=1;d<t.length;d++)l=s.mixHexColors(l,t[d].highlightColor||"");o.push({highlight:i,start:r.start,end:r.end,badges:t,color:l,usedLooseMatch:a})}});var a=new Set(Object.keys(t));(_||[]).forEach(function(e){if(e){var i=T(e);if(i&&!a.has(i)){var t=B?s.findRedlineTextAnchorRange(n,i):s.findTextMatchRange(n,i,!1);if(t){var r=n.slice(t.start,t.end)!==i,l=n.slice(0,t.start);(l.match(/</g)||[]).length===(l.match(/>/g)||[]).length&&o.push({highlight:i,start:t.start,end:t.end,badges:[],color:b||"",usedLooseMatch:r})}}}}),o.sort(function(e,n){return e.start-n.start||n.end-e.end});var d=[],u={};o.forEach(function(e,n){for(var i=e.start,t=e.end,r=0,o=d;r<o.length;r++){var a=o[r],s=a.start,l=a.end,c=i<l&&t>l&&i>=s,h=i<s&&t>s&&t<=l;if(i>=s&&t<=l){e.orphaned=!0,u[n]=a.matchIdx;break}c&&(i=l),h&&(t=s)}e.trimmedStart=i,e.trimmedEnd=t,!e.orphaned&&i<t&&d.push({start:i,end:t,matchIdx:n})});var h={};Object.entries(u).forEach(function(e){var n=e[0],i=e[1],t=Number(n);h[i]||(h[i]=[]),h[i].push(t)});var g=o.map(function(n,i){return e.__assign(e.__assign({},n),{idx:i})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var i,t;return(null!==(i=n.trimmedStart)&&void 0!==i?i:n.start)-(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)});return g.forEach(function(e){var i,t,a,l,d=null!==(i=e.trimmedStart)&&void 0!==i?i:e.start,c=null!==(t=e.trimmedEnd)&&void 0!==t?t:e.end;if(!(d>=c)){var u=n.slice(d,c),g=function(e,n,i,t){if(!i.length)return e;var a=i.map(function(e){return o[e]}).sort(function(e,n){return e.start-n.start}),l="",d=0;return a.forEach(function(i){var o,a,c=Math.max(d,i.start-n),u=Math.max(c,i.end-n);if(!(c>=u)){var h=s.mixHexColors(t,i.color||"");l+=e.slice(d,c),l+=r(e.slice(c,u),(null===(a=null===(o=i.badges)||void 0===o?void 0:o[0])||void 0===a?void 0:a.id)||"",h,i.badges||[]),d=u}}),l+=e.slice(d)}(e.usedLooseMatch||d!==e.start||c!==e.end?u:e.highlight,e.start,h[e.idx]||[],e.color),p=r(g,(null===(l=null===(a=e.badges)||void 0===a?void 0:a[0])||void 0===l?void 0:l.id)||"",e.color,e.badges||[]);n=n.slice(0,d)+p+n.slice(c)}}),n},[l,f,_,b,B]),R=t.useMemo(function(){return d?M(c.normalizeRedlineMarkdown(d||"")):""},[d]),q=!!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"}},I=e.__assign(e.__assign(e.__assign(e.__assign({},u),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),q?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden",margin:"0 !important"},"& p:empty":{display:"none"}}:{}),O=e.__assign(e.__assign(e.__assign({},u),W),{position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return t.useLayoutEffect(function(){if(E.current){var e=function(){var e=Array.from(E.current.querySelectorAll(".deviation-badge"));if(0!==e.length){e.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var n=e.filter(function(e){return"left"===e.dataset.side}),i=e.filter(function(e){return"left"!==e.dataset.side}),t=E.current.getBoundingClientRect(),r=t.bottom-4,o=t.top+4,a=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var i=[],t=[];n.forEach(function(e){if(0===t.length)t.push(e);else{var n=t[t.length-1],r=n.currentTop+n.height;e.naturalTop<r+8?(e.currentTop=r+8,t.push(e)):(i.push(t),t=[e])}}),t.length>0&&i.push(t),i.forEach(function(e){var n=e[e.length-1],i=n.currentTop+n.height;if(i>r){var t=i-r,a=e[0].currentTop-o,s=Math.max(0,Math.min(t,a));e.forEach(function(e){e.currentTop-=s})}}),i.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};a(n),a(i)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),i=new ResizeObserver(function(){requestAnimationFrame(e)});return i.observe(E.current),function(){i.disconnect(),cancelAnimationFrame(n)}}},[A,w,z]),n.jsxs(i.Box,e.__assign({ref:E,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},I),{padding:"3px"})},{children:n.jsx(g.default,e.__assign({components:F,remarkPlugins:v,rehypePlugins:x},{children:A.replace(/#{3}/g,"")}))})),q&&n.jsx(i.Typography,e.__assign({component:"div",sx:O},{children:n.jsx(g.default,e.__assign({components:F,remarkPlugins:v,rehypePlugins:x},{children:R}))}))]}))},s.areMarkdownPropsEqual);exports.MemoizedMarkdown=m;
2
2
  //# sourceMappingURL=memoizedMarkdown.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react"),o=require("../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js"),l=require("./GptWebCitationImageCitation.js"),a=require("./GptWebCitationSkeleton.js"),s=require("./types.js"),r=require("./utils/citationData.utils.js"),u=require("./utils/styleOverrides.utils.js"),d=require("./utils/fixedHeight.utils.js"),g=require("./GptWebCitation.module.css.js"),c=require("../../assests/svg/NeuralNetworkIcon.js"),v=function(t){var o=t.variant,l=t.disabled,a=t.onClick,s=t.title,r=t.style;return i.jsx("button",e.__assign({type:"button",className:g.default.webCitationButton,onClick:a,disabled:l,title:s,style:r},{children:"gpt"===o?i.jsxs(i.Fragment,{children:[i.jsx(c.default,{className:g.default.webCitationButtonIcon}),"View GPT Citation"]}):i.jsxs(i.Fragment,{children:[i.jsx(n.Globe,{size:24,className:g.default.webCitationButtonIcon}),"View Web Citation"]})}))};exports.default=function(c){var p,C,b,_,w=c.gptCitation,f=c.defaultCitationUrl,m=c.citationType,x=c.webCitationData,h=c.topic,y=c.sourceLabel,k=c.relevanceScore,j=c.learnedFrom,F=c.webCitationStatus,S=c.onGenerateWebCitation,I=c.showWebCitation,L=c.onToggleCitationView,W=c.showExpandImageButton,B=void 0===W||W,H=c.onFullscreenChange,T=c.showGptMaximizeButton,N=c.iconsConfig,V=c.isFixedHeight,M=void 0!==V&&V,q=c.styles,E=t.useMemo(function(){return function(i){var t,n,o,l,a,s,r,d,g,c,v;return{container:null==i?void 0:i.container,gptWrapper:e.__assign(e.__assign({},null===(t=null==i?void 0:i.gptCitation)||void 0===t?void 0:t.wrapper),null==i?void 0:i.gptCitationWrapper),gptFooterAction:e.__assign(e.__assign({},null===(n=null==i?void 0:i.gptCitation)||void 0===n?void 0:n.footerAction),null==i?void 0:i.footerAction),gptToggleButton:e.__assign(e.__assign({},null===(o=null==i?void 0:i.gptCitation)||void 0===o?void 0:o.toggleButton),null==i?void 0:i.webCitationButton),webPanel:e.__assign(e.__assign({},null==i?void 0:i.container),null===(l=null==i?void 0:i.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==i?void 0:i.webCitation)||void 0===a?void 0:a.header,webContent:null===(s=null==i?void 0:i.webCitation)||void 0===s?void 0:s.content,webFooter:null===(r=null==i?void 0:i.webCitation)||void 0===r?void 0:r.footer,webToggleButton:e.__assign(e.__assign({},null===(d=null==i?void 0:i.webCitation)||void 0===d?void 0:d.toggleButton),null==i?void 0:i.webCitationButton),webLearnedFrom:null===(g=null==i?void 0:i.webCitation)||void 0===g?void 0:g.learnedFrom,webImage:null===(c=null==i?void 0:i.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==i?void 0:i.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:u.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"image"),webSkeletonVisitLink:u.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"skeleton")}}(q)},[q]),G=s.allowsGptCitationView(m),z=s.allowsWebCitationView(m),U=s.showsCitationViewToggle(m),A=t.useMemo(function(){return M?d.resolveFixedHeightLayout(w.bodyHeight,U):null},[M,w.bodyHeight,U]),D=t.useMemo(function(){return A?d.getFixedPanelStyle(A.panelHeight):void 0},[A]),P=t.useMemo(function(){var e,i;return{MaximizeIcon:null!==(e=null==N?void 0:N.MaximizeIcon)&&void 0!==e?e:null===(i=w.iconsConfig)||void 0===i?void 0:i.MaximizeIcon,ExternalLinkIcon:null==N?void 0:N.ExternalLinkIcon}},[N,null===(p=w.iconsConfig)||void 0===p?void 0:p.MaximizeIcon]),O=t.useMemo(function(){return e.__assign(e.__assign(e.__assign(e.__assign({},w),M&&A?{bodyHeight:A.gptBodyHeight}:{}),{disableMaximize:void 0!==T?!T:w.disableMaximize}),U||m===s.CitationType.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[w,T,U,m,M,A]),R=t.useState(m!==s.CitationType.GPT),J=R[0],K=R[1],Q=m!==s.CitationType.GPT&&(m===s.CitationType.WEB||(null!=I?I:J)),X=void 0!==I,Y=t.useMemo(function(){return x?r.mapCitationDataToDisplay(x):null},[x]),Z=null!==(C=null!=h?h:null==Y?void 0:Y.topic)&&void 0!==C?C:"Web Citation",$=null!==(b=null!=k?k:null==Y?void 0:Y.relevanceScore)&&void 0!==b?b:0,ee=null!=j?j:null==Y?void 0:Y.learnedFrom,ie=r.resolveSkeletonVisitUrl(null==Y?void 0:Y.highlightedUrl,null!==(_=null==Y?void 0:Y.citationUrl)&&void 0!==_?_:f),te=r.getWebCitationImageUrl(x),ne=t.useMemo(function(){return function(e,i,t){return t?"success":e||(i?"error":"pending")}(F,x,te)},[F,x,te]),oe=t.useCallback(function(){L?L():X||K(!1)},[L,X]),le=t.useCallback(function(){L?L():X||K(!0),te||"success"===ne||null==S||S()},[L,X,te,ne,S]),ae=null!=y?y:"Source: Web Citation > ".concat(Z),se=function(t){var n=!!O.DocumentTitle,l=[g.default.gptCitationWrapper,n?g.default.gptCitationWrapperWithSource:"",M?g.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return i.jsxs("div",e.__assign({className:l,style:e.__assign(e.__assign({},E.gptWrapper),D)},{children:[i.jsx(o.default,e.__assign({},O,{splitterCustomStyle:!0,onFullscreenChange:H})),t&&(n?i.jsx("div",e.__assign({className:g.default.gptCitationFooterAction,style:E.gptFooterAction},{children:t})):i.jsx("div",e.__assign({className:[g.default.gptCitationToggleFooter,M?g.default.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:E.gptFooterAction},{children:t})))]}))};return G&&!Q?i.jsx("div",e.__assign({className:g.default.overlay,style:E.container},{children:se(U?i.jsx(v,{variant:"web",onClick:le,title:"View web-based citation for this source.",style:E.gptToggleButton}):void 0)})):z?i.jsxs("div",e.__assign({className:[g.default.panel,M?g.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},E.webPanel),D)},{children:[i.jsxs("div",e.__assign({className:g.default.panelHeader,style:E.webHeader},{children:[i.jsx("span",e.__assign({className:g.default.panelSource},{children:ae})),i.jsx("div",e.__assign({className:g.default.panelHeaderActions},{children:$>0&&i.jsxs("div",e.__assign({className:g.default.confidenceBadge,title:"Decision strength"},{children:[i.jsx(n.Sparkles,{size:14}),$,"%"]}))}))]})),i.jsx("div",e.__assign({className:[g.default.panelContent,g.default.panelContentExpanded,M?g.default.panelContentFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},E.webContent),M?d.getFixedWebContentStyle():void 0)},{children:"pending"===ne?i.jsx(a.default,{status:"pending",citationUrl:ie,ExternalLinkIcon:P.ExternalLinkIcon,styles:E.webSkeleton,visitLinkStyles:E.webSkeletonVisitLink,isFixedHeight:M}):"success"===ne&&te?i.jsx(l.default,{citationImage:te,citationUrl:ie,showExpandImageButton:B,iconsConfig:P,styles:E.webImage,visitLinkStyles:E.webImageVisitLink,skeletonStyles:E.webSkeleton,skeletonVisitLinkStyles:E.webSkeletonVisitLink,isFixedHeight:M,onFullscreenChange:H}):i.jsx(a.default,{status:"error",citationUrl:ie,ExternalLinkIcon:P.ExternalLinkIcon,styles:E.webSkeleton,visitLinkStyles:E.webSkeletonVisitLink,isFixedHeight:M})})),i.jsxs("div",e.__assign({className:g.default.panelFooter,style:E.webFooter},{children:[U?i.jsx(v,{variant:"gpt",onClick:oe,style:E.webToggleButton}):null,ee&&i.jsxs("span",e.__assign({className:g.default.learnedFrom,style:E.webLearnedFrom},{children:["Learned From ",ee]}))]}))]})):i.jsx("div",e.__assign({className:g.default.overlay,style:E.container},{children:se()}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react"),o=require("../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js"),l=require("./GptWebCitationImageCitation.js"),a=require("./GptWebCitationSkeleton.js"),s=require("./types.js"),r=require("./utils/citationData.utils.js"),u=require("./utils/styleOverrides.utils.js"),d=require("./utils/fixedHeight.utils.js"),g=require("./GptWebCitation.module.css.js"),c=require("../../assests/svg/NeuralNetworkIcon.js"),v=function(t){var o=t.variant,l=t.disabled,a=t.onClick,s=t.title,r=t.style;return i.jsx("button",e.__assign({type:"button",className:g.default.webCitationButton,onClick:a,disabled:l,title:s,style:r},{children:"gpt"===o?i.jsxs(i.Fragment,{children:[i.jsx(c.default,{className:g.default.webCitationButtonIcon}),"View GPT Citation"]}):i.jsxs(i.Fragment,{children:[i.jsx(n.Globe,{size:24,className:g.default.webCitationButtonIcon}),"View Web Citation"]})}))};exports.default=function(c){var p,_,C,b,w=c.gptCitation,f=c.defaultCitationUrl,m=c.citationType,x=c.webCitationData,h=c.topic,y=c.sourceLabel,k=c.relevanceScore,j=c.learnedFrom,F=c.webCitationStatus,S=c.onGenerateWebCitation,H=c.showWebCitation,I=c.onToggleCitationView,B=c.showExpandImageButton,L=void 0===B||B,W=c.onFullscreenChange,T=c.showGptMaximizeButton,N=c.iconsConfig,V=c.isFixedHeight,M=void 0!==V&&V,q=c.useParentHeight,E=void 0!==q&&q,G=c.styles,P=t.useMemo(function(){return function(i){var t,n,o,l,a,s,r,d,g,c,v;return{container:null==i?void 0:i.container,gptWrapper:e.__assign(e.__assign({},null===(t=null==i?void 0:i.gptCitation)||void 0===t?void 0:t.wrapper),null==i?void 0:i.gptCitationWrapper),gptFooterAction:e.__assign(e.__assign({},null===(n=null==i?void 0:i.gptCitation)||void 0===n?void 0:n.footerAction),null==i?void 0:i.footerAction),gptToggleButton:e.__assign(e.__assign({},null===(o=null==i?void 0:i.gptCitation)||void 0===o?void 0:o.toggleButton),null==i?void 0:i.webCitationButton),webPanel:e.__assign(e.__assign({},null==i?void 0:i.container),null===(l=null==i?void 0:i.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==i?void 0:i.webCitation)||void 0===a?void 0:a.header,webContent:null===(s=null==i?void 0:i.webCitation)||void 0===s?void 0:s.content,webFooter:null===(r=null==i?void 0:i.webCitation)||void 0===r?void 0:r.footer,webToggleButton:e.__assign(e.__assign({},null===(d=null==i?void 0:i.webCitation)||void 0===d?void 0:d.toggleButton),null==i?void 0:i.webCitationButton),webLearnedFrom:null===(g=null==i?void 0:i.webCitation)||void 0===g?void 0:g.learnedFrom,webImage:null===(c=null==i?void 0:i.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==i?void 0:i.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:u.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"image"),webSkeletonVisitLink:u.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"skeleton")}}(G)},[G]),z=s.allowsGptCitationView(m),U=s.allowsWebCitationView(m),A=s.showsCitationViewToggle(m),D=M||E,O=t.useMemo(function(){return M?d.resolveFixedHeightLayout(w.bodyHeight,A):null},[M,w.bodyHeight,A]),R=t.useMemo(function(){return O?d.getFixedPanelStyle(O.panelHeight):void 0},[O]),J=t.useMemo(function(){return E?d.getParentHeightPanelStyle():void 0},[E]),K=null!=J?J:R,Q=t.useMemo(function(){var e,i;return{MaximizeIcon:null!==(e=null==N?void 0:N.MaximizeIcon)&&void 0!==e?e:null===(i=w.iconsConfig)||void 0===i?void 0:i.MaximizeIcon,ExternalLinkIcon:null==N?void 0:N.ExternalLinkIcon}},[N,null===(p=w.iconsConfig)||void 0===p?void 0:p.MaximizeIcon]),X=t.useMemo(function(){var i=E?{bodyHeight:d.getParentHeightGptBodyHeight(A)}:M&&O?{bodyHeight:O.gptBodyHeight}:{};return e.__assign(e.__assign(e.__assign(e.__assign({},w),i),{disableMaximize:void 0!==T?!T:w.disableMaximize}),A||m===s.CitationType.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[w,T,A,m,E,M,O]),Y=t.useState(m!==s.CitationType.GPT),Z=Y[0],$=Y[1],ee=m!==s.CitationType.GPT&&(m===s.CitationType.WEB||(null!=H?H:Z)),ie=void 0!==H,te=t.useMemo(function(){return x?r.mapCitationDataToDisplay(x):null},[x]),ne=null!==(_=null!=h?h:null==te?void 0:te.topic)&&void 0!==_?_:"Web Citation",oe=null!==(C=null!=k?k:null==te?void 0:te.relevanceScore)&&void 0!==C?C:0,le=null!=j?j:null==te?void 0:te.learnedFrom,ae=r.resolveSkeletonVisitUrl(null==te?void 0:te.highlightedUrl,null!==(b=null==te?void 0:te.citationUrl)&&void 0!==b?b:f),se=r.getWebCitationImageUrl(x),re=t.useMemo(function(){return function(e,i,t){return t?"success":e||(i?"error":"pending")}(F,x,se)},[F,x,se]),ue=t.useCallback(function(){I?I():ie||$(!1)},[I,ie]),de=t.useCallback(function(){I?I():ie||$(!0),se||"success"===re||null==S||S()},[I,ie,se,re,S]),ge=null!=y?y:"Source: Web Citation > ".concat(ne),ce=function(t){var n=!!X.DocumentTitle,l=[g.default.gptCitationWrapper,n?g.default.gptCitationWrapperWithSource:"",D?g.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return i.jsxs("div",e.__assign({className:l,style:e.__assign(e.__assign({},P.gptWrapper),K)},{children:[i.jsx(o.default,e.__assign({},X,{splitterCustomStyle:!0,onFullscreenChange:W})),t&&(n?i.jsx("div",e.__assign({className:g.default.gptCitationFooterAction,style:P.gptFooterAction},{children:t})):i.jsx("div",e.__assign({className:[g.default.gptCitationToggleFooter,D?g.default.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:P.gptFooterAction},{children:t})))]}))};return z&&!ee?i.jsx("div",e.__assign({className:g.default.overlay,style:e.__assign(e.__assign({},P.container),J)},{children:ce(A?i.jsx(v,{variant:"web",onClick:de,title:"View web-based citation for this source.",style:P.gptToggleButton}):void 0)})):U?i.jsxs("div",e.__assign({className:[g.default.panel,D?g.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},P.webPanel),K)},{children:[i.jsxs("div",e.__assign({className:g.default.panelHeader,style:P.webHeader},{children:[i.jsx("span",e.__assign({className:g.default.panelSource},{children:ge})),i.jsx("div",e.__assign({className:g.default.panelHeaderActions},{children:oe>0&&i.jsxs("div",e.__assign({className:g.default.confidenceBadge,title:"Decision strength"},{children:[i.jsx(n.Sparkles,{size:14}),oe,"%"]}))}))]})),i.jsx("div",e.__assign({className:[g.default.panelContent,g.default.panelContentExpanded,D?g.default.panelContentFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},P.webContent),D?d.getFixedWebContentStyle():void 0)},{children:"pending"===re?i.jsx(a.default,{status:"pending",citationUrl:ae,ExternalLinkIcon:Q.ExternalLinkIcon,styles:P.webSkeleton,visitLinkStyles:P.webSkeletonVisitLink,isFixedHeight:D}):"success"===re&&se?i.jsx(l.default,{citationImage:se,citationUrl:ae,showExpandImageButton:L,iconsConfig:Q,styles:P.webImage,visitLinkStyles:P.webImageVisitLink,skeletonStyles:P.webSkeleton,skeletonVisitLinkStyles:P.webSkeletonVisitLink,isFixedHeight:D,onFullscreenChange:W}):i.jsx(a.default,{status:"error",citationUrl:ae,ExternalLinkIcon:Q.ExternalLinkIcon,styles:P.webSkeleton,visitLinkStyles:P.webSkeletonVisitLink,isFixedHeight:D})})),i.jsxs("div",e.__assign({className:g.default.panelFooter,style:P.webFooter},{children:[A?i.jsx(v,{variant:"gpt",onClick:ue,style:P.webToggleButton}):null,le&&i.jsxs("span",e.__assign({className:g.default.learnedFrom,style:P.webLearnedFrom},{children:["Learned From ",le]}))]}))]})):i.jsx("div",e.__assign({className:g.default.overlay,style:e.__assign(e.__assign({},P.container),J)},{children:ce()}))};
2
2
  //# sourceMappingURL=GptWebCitation.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="520px",t="3.25rem";exports.getFixedPanelStyle=function(e){return{height:e,minHeight:e,maxHeight:e,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},exports.getFixedWebContentStyle=function(){return{flex:1,minHeight:0,maxHeight:"none",overflow:"hidden",display:"flex",flexDirection:"column"}},exports.resolveFixedHeightLayout=function(n,i){if(void 0===i&&(i=!0),!i){var o=null!=n?n:e;return{contentHeight:o,gptBodyHeight:o,panelHeight:o}}if(n)return{contentHeight:n,gptBodyHeight:n,panelHeight:"calc(".concat(n," + ").concat(t,")")};var r="calc(".concat(e," - ").concat(t,")");return{contentHeight:r,gptBodyHeight:r,panelHeight:e}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="520px",t="3.25rem";exports.getFixedPanelStyle=function(e){return{height:e,minHeight:e,maxHeight:e,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},exports.getFixedWebContentStyle=function(){return{flex:1,minHeight:0,maxHeight:"none",overflow:"hidden",display:"flex",flexDirection:"column"}},exports.getParentHeightGptBodyHeight=function(e){return void 0===e&&(e=!0),e?"calc(100% - ".concat(t,")"):"100%"},exports.getParentHeightPanelStyle=function(){return{height:"100%",minHeight:0,width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",boxSizing:"border-box"}},exports.resolveFixedHeightLayout=function(i,n){if(void 0===n&&(n=!0),!n){var o=null!=i?i:e;return{contentHeight:o,gptBodyHeight:o,panelHeight:o}}if(i)return{contentHeight:i,gptBodyHeight:i,panelHeight:"calc(".concat(i," + ").concat(t,")")};var r="calc(".concat(e," - ").concat(t,")");return{contentHeight:r,gptBodyHeight:r,panelHeight:e}};
2
2
  //# sourceMappingURL=fixedHeight.utils.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i,__awaiter as n,__generator as e}from"tslib";import{jsxs as o,jsx as t,Fragment as l}from"react/jsx-runtime";import{Globe as r,ChevronUp as a,ChevronDown as u,Maximize2 as d,X as c,ExternalLink as s}from"lucide-react";import{useState as v,useEffect as p,useMemo as m,useRef as h}from"react";import g from"./ResizableSplitPane.js";import f from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as b,DefaultFullScreenIcon as x}from"../../assests/svg/PdfViewerIcons.js";import _ from"react-markdown";import y from"rehype-raw";import{Dialog as w,Box as C}from"@mui/material";import"./utils/normalizeRedlineMarkdown.js";import{SHARED_MARKDOWN_STYLES as F}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as D}from"./CompareContext.js";import{processGuidelinesMarkdown as P}from"./Guidelines/utils/processGuidelinesMarkdown.js";import T from"../GptWebCitation/GptWebCitation.js";import{CitationType as S}from"../GptWebCitation/types.js";import"./MoreFunctionsPopup.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";var k=function(i){var n,e,o;return(null===(o=null===(e=null===(n=(null==i?void 0:i.extraMetaData)||i)||void 0===n?void 0:n.aiReasoningCitation)||void 0===e?void 0:e.gpt_citation)||void 0===o?void 0:o[0])||null},N="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",j="sai.siddhartha@techolution.com",I="672e32f7a0e8fe2e8e50bcba",R="TNV Sai Siddhartha",G="90vh",U="calc(".concat(G," - 120px)"),M=function(){var i;return"function"==typeof(null===(i=globalThis.crypto)||void 0===i?void 0:i.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var n=Math.floor(16*Math.random());return("x"===i?n:n%4+8).toString(16)})},E=function(i,n){var e=function(i){var n;return(null==i?void 0:i.payloadCitationId)||(null===(n=null==i?void 0:i.extraMetaData)||void 0===n?void 0:n.payloadCitationId)||""}(i)||n||M();return function(i,n){i&&"object"==typeof i&&(i.payloadCitationId=n,i.extraMetaData&&"object"==typeof i.extraMetaData&&(i.extraMetaData.payloadCitationId=n))}(i,e),e},A=function(o){var l,r=o.metaData,g=o.isFullscreen,f=void 0!==g&&g,b=o.onFullscreenChange,x=D().gptWebCitationConfig,_=m(function(){return function(i){return{endpoint:(null==i?void 0:i.endpoint)||N,userEmail:(null==i?void 0:i.userEmail)||j,userId:(null==i?void 0:i.userId)||I,userName:(null==i?void 0:i.userName)||R,headers:null==i?void 0:i.headers}}(x)},[x]),y=null==r?void 0:r.webGpt,w=h(null);w.current||(w.current=M());var C=m(function(){return function(i,n,e){var o,t,l=k(i),r=(null==l?void 0:l.customMetaData)||{},a=(null==r?void 0:r.value)||{},u=(null==i?void 0:i.webSearchAnswer)||{},d=(null==i?void 0:i.extraMetaData)||i||{};return{userEmail:(null==i?void 0:i.userEmail)||(null==u?void 0:u.userEmail)||(null==n?void 0:n.userEmail)||"",userId:(null==i?void 0:i.userId)||(null==u?void 0:u.userId)||(null==n?void 0:n.userId)||"",userName:(null==i?void 0:i.userName)||(null==u?void 0:u.userName)||(null==n?void 0:n.userName)||"",citationId:E(i,e),citationUrl:(null==a?void 0:a.citationUrl)||(null==u?void 0:u.citationUrl)||"",content:(null==d?void 0:d.Reasoning)||(null==u?void 0:u.enhanced_content)||"",citationType:(null==a?void 0:a.citationType)||"web",citatioNumber:null!==(t=null!==(o=null==r?void 0:r.citation_number)&&void 0!==o?o:null==l?void 0:l.citation_number)&&void 0!==t?t:Number((null==i?void 0:i.reasoningId)||0)}}(y,_,w.current||void 0)},[y,_]),F=m(function(){return k(y)},[y]),P=(null===(l=null==F?void 0:F.customMetaData)||void 0===l?void 0:l.value)||{},G=(null==y?void 0:y.extraMetaData)||y||{},A=v(),H=A[0],W=A[1],z=v("pending"),B=z[0],O=z[1],V=v(!0),L=V[0],J=V[1];p(function(){var o=!0;return n(void 0,void 0,void 0,function(){var n,t,l,r;return e(this,function(e){switch(e.label){case 0:if(!_.endpoint||!(null==C?void 0:C.citationUrl)||!(null==C?void 0:C.content))return O("error"),[2];O("pending"),e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(_.endpoint,{method:"POST",headers:i({"actor-id":C.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},_.headers||{}),body:JSON.stringify(C)})];case 2:if(!(n=e.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return t=e.sent(),l=(null==t?void 0:t.responseData)||(null==t?void 0:t.result)||(null==t?void 0:t.data)||t,o?(W(l),O("success"),[3,5]):[2];case 4:return r=e.sent(),o?(console.error("Failed to load GPT web citation",r),O("error"),[3,5]):[2];case 5:return[2]}})}),function(){o=!1}},[C,_]);var Y=m(function(){return{item:{confidence_score:Number((null==G?void 0:G.Confidence_score)||0),text:(null==P?void 0:P.paraphrase)||"Web citation reasoning",dataSource:(null==P?void 0:P.text)||(null==G?void 0:G.Reasoning)||"",paraphrase:(null==P?void 0:P.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==C?void 0:C.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:u,ChevronUpIcon:a,MaximizeIcon:d,CloseIcon:c}}},[P,null==C?void 0:C.citatioNumber,G]),$=m(function(){return i(i({},Y),f?{bodyHeight:U}:{})},[Y,f]);return t("div",i({style:{overflowY:"auto"}},{children:t(T,{gptCitation:$,defaultCitationUrl:(null==C?void 0:C.citationUrl)||"",citationType:S.GPT_WEB,webCitationData:H,webCitationStatus:B,showWebCitation:L,onToggleCitationView:function(){return J(function(i){return!i})},iconsConfig:{MaximizeIcon:d,ExternalLinkIcon:s},showGptMaximizeButton:!1,isFixedHeight:!0,onFullscreenChange:b})}))},H=function(n){var e,o,r,a,u,d,c,s=n.href,v=n.metaData,p=n.citationTitle,h=n.citationType,b=n.citationReason,x=n.isFullscreen,w=n.onFullscreenChange,T=D().guidelinesData,S=function(i){try{var n=function(i){var n=i.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(n)try{var e=i.indexOf("?"),o=e>=0?i.slice(e):"";return{citationNumber:n[1],parsedUrl:new URL(o||"./",window.location.origin)}}catch(i){return{citationNumber:n[1],parsedUrl:null}}try{var t=new URL(i,window.location.origin);return{citationNumber:t.searchParams.get("citationNumber")||t.searchParams.get("citation_number"),parsedUrl:t}}catch(i){return{citationNumber:null,parsedUrl:null}}}(i),e=n.citationNumber,o=n.parsedUrl;return{citationNumber:e,phraseToHighlight:(null==o?void 0:o.searchParams.get("phrase_to_highlight"))||null,citationTypeFromHref:(null==o?void 0:o.searchParams.get("citation_type"))||null}}catch(i){return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}}(s),k=S.citationNumber,N=S.phraseToHighlight,j=S.citationTypeFromHref,I=h||j||void 0,R="il_rulebook_citation"===I?"rulebook_citation":I,G=k&&(null===(e=null==v?void 0:v.citations)||void 0===e?void 0:e[k])||{},U=(null===(o=null==v?void 0:v.docData)||void 0===o?void 0:o.documents)||{},M=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},E=Object.keys((null==v?void 0:v.citations)||{}).length>0||Object.keys((null==v?void 0:v.docData)||{}).length>0,H=null==M?void 0:M[0],W=null==M?void 0:M[1],z=H?U[H]:null,B=W?U[W]:null,O=H?G[H]:null,V=W?G[W]:null,L=m(function(){var i,n,e,o;return O&&z?t(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==z?void 0:z.title,pdfUrl:null==z?void 0:z.signed_url,highlightText:[null!==(i=null==O?void 0:O.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==O?void 0:O.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(e=null==O?void 0:O.custom_metadata)||void 0===e?void 0:e.pdf_start_page_number,null===(o=null==O?void 0:O.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==z?void 0:z.title,null==z?void 0:z.signed_url,null==O?void 0:O.highlighted_text,null===(a=null==O?void 0:O.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(u=null==O?void 0:O.custom_metadata)||void 0===u?void 0:u.pdf_end_page_number]),J=m(function(){var i,n,e,o;return V&&B?t(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==B?void 0:B.title,pdfUrl:null==B?void 0:B.signed_url,jumpToPageValue:1,highlightText:[null!==(i=null==V?void 0:V.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==V?void 0:V.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(e=null==V?void 0:V.custom_metadata)||void 0===e?void 0:e.pdf_start_page_number,null===(o=null==V?void 0:V.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==B?void 0:B.title,null==B?void 0:B.signed_url,null==V?void 0:V.highlighted_text,null===(d=null==V?void 0:V.custom_metadata)||void 0===d?void 0:d.pdf_start_page_number,null===(c=null==V?void 0:V.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]),Y="dual_citation"===R,$=Y&&!!(null==v?void 0:v.webGpt),q=m(function(){var n=$?t(A,{metaData:v,isFullscreen:x,onFullscreenChange:w}):"rulebook_citation"===R?t(l,{children:t(C,i({sx:i(i({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},F),{overflow:"auto"})},{children:t(_,i({rehypePlugins:[y]},{children:P({guidelinesData:T,targetHighlights:[N],labelColor:"#FEF08A"})}))}))}):J;return t(g,{leftComponent:L,rightComponent:n,isFullscreen:x})},[L,J,R,$,v,x,T,N,w]);return(null==v?void 0:v.webGpt)&&!E?t(A,{metaData:v,isFullscreen:x,onFullscreenChange:w}):k?"rulebook_citation"===R?t("div",O?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):i({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:b||"Rulebook citation selected."})):Y?O||V?t("div",i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q})):(null==v?void 0:v.webGpt)?t(A,{metaData:v,isFullscreen:x,onFullscreenChange:w}):t("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(p)?t("div",O||V?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):{children:"Missing PDF Citation. Please try again later"}):t("div",{children:"No Citation Found. Please try again later"}):null},W=function(n){var e,l,d,c,s,m,h,g=n.href,f=n.children,_=n.citationType,y=n.citationReason,C=n.metaData,F=n.chevronUpComponent,D=void 0===F?null:F,P=n.chevronDownComponent,T=void 0===P?null:P,S=n.customStyle,k=void 0===S?{}:S,N=n.defaultState,j=void 0!==N&&N,I=n.onFullscreenChange,R=v(j),U=R[0],M=R[1],E=v(!1),A=E[0],W=E[1],z="string"==typeof f&&(null===(e=null==f?void 0:f.split("\n"))||void 0===e?void 0:e.length)>1?f.split("\n").join(" "):f;p(function(){if(null==I||I(A),A)return function(){null==I||I(!1)}},[A,I]);var B="string"==typeof f?f:f[0],O=null!=D?D:function(i){var n,e;return t(a,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(e=null==i?void 0:i.color)&&void 0!==e?e:"rgb(214, 51, 132)"})}(null!==(l=null==k?void 0:k.arrow)&&void 0!==l?l:{}),V=null!=T?T:function(i){var n,e;return t(u,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(e=null==i?void 0:i.color)&&void 0!==e?e:"rgb(214, 51, 132)"})}(null!==(d=null==k?void 0:k.arrow)&&void 0!==d?d:{}),L=o("div",i({style:{boxSizing:"border-box",border:A?"none":"1px solid #E4E7EC",borderRadius:A?0:"8px",overflow:"hidden",marginTop:A?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:A?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[t("div",i({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:t("button",i({onClick:function(){W(function(i){var n=!i;return null==I||I(n),n})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:t(A?b:x,{})}))})),t("div",i({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:t(H,{href:g,children:f,metaData:C,citationTitle:B,citationType:_,citationReason:y,isFullscreen:A,onFullscreenChange:I})}))]}));return o("span",i({style:i({display:"inline"},k.relativeWrapper||{})},{children:[t("div",i({style:i({display:"inline",marginTop:0},k.citationButtonWrapper||{})},{children:o("button",i({type:"button",onClick:function(){return M(function(i){return!i})},style:i({display:(null==C?void 0:C.webGpt)?"inline":"inline-flex",alignItems:(null==C?void 0:C.webGpt)?void 0:"center",gap:(null==C?void 0:C.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==C?void 0:C.webGpt)?600:700,color:(null==C?void 0:C.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},k.citationButton||{})},{children:[(null==C?void 0:C.webGpt)&&t(r,{size:null!==(s=null===(c=k.arrow)||void 0===c?void 0:c.fontSize)&&void 0!==s?s:"1em",color:null!==(h=null===(m=k.arrow)||void 0===m?void 0:m.color)&&void 0!==h?h:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),t("span",{children:z}),t("span",i({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==C?void 0:C.webGpt)?"3px":void 0,verticalAlign:(null==C?void 0:C.webGpt)?"-0.125em":void 0}},{children:U?O:V}))]}))})),U&&(A?t(w,i({open:A,onClose:function(){W(!1),null==I||I(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:G,m:0,maxHeight:G,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:L})):L)]}))};export{W as default};
1
+ import{__assign as i,__awaiter as n,__generator as e}from"tslib";import{jsxs as o,jsx as t,Fragment as l}from"react/jsx-runtime";import{Globe as r,ChevronUp as a,ChevronDown as u,Maximize2 as d,X as c,ExternalLink as s}from"lucide-react";import{useState as v,useEffect as p,useMemo as m,useRef as h}from"react";import g from"./ResizableSplitPane.js";import f from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as b,DefaultFullScreenIcon as x}from"../../assests/svg/PdfViewerIcons.js";import _ from"react-markdown";import y from"rehype-raw";import{Dialog as w,Box as C}from"@mui/material";import"./utils/normalizeRedlineMarkdown.js";import{SHARED_MARKDOWN_STYLES as F}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as D}from"./CompareContext.js";import{processGuidelinesMarkdown as P}from"./Guidelines/utils/processGuidelinesMarkdown.js";import T from"../GptWebCitation/GptWebCitation.js";import{CitationType as S}from"../GptWebCitation/types.js";import"./MoreFunctionsPopup.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";var k=function(i){var n,e,o;return(null===(o=null===(e=null===(n=(null==i?void 0:i.extraMetaData)||i)||void 0===n?void 0:n.aiReasoningCitation)||void 0===e?void 0:e.gpt_citation)||void 0===o?void 0:o[0])||null},N="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",j="sai.siddhartha@techolution.com",I="672e32f7a0e8fe2e8e50bcba",R="TNV Sai Siddhartha",G="90vh",U="calc(".concat(G," - 120px)"),M=function(){var i;return"function"==typeof(null===(i=globalThis.crypto)||void 0===i?void 0:i.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var n=Math.floor(16*Math.random());return("x"===i?n:n%4+8).toString(16)})},E=function(i,n){var e=function(i){var n;return(null==i?void 0:i.payloadCitationId)||(null===(n=null==i?void 0:i.extraMetaData)||void 0===n?void 0:n.payloadCitationId)||""}(i)||n||M();return function(i,n){i&&"object"==typeof i&&(i.payloadCitationId=n,i.extraMetaData&&"object"==typeof i.extraMetaData&&(i.extraMetaData.payloadCitationId=n))}(i,e),e},A=function(o){var l,r=o.metaData,g=o.isFullscreen,f=void 0!==g&&g,b=o.onFullscreenChange,x=D().gptWebCitationConfig,_=m(function(){return function(i){return{endpoint:(null==i?void 0:i.endpoint)||N,userEmail:(null==i?void 0:i.userEmail)||j,userId:(null==i?void 0:i.userId)||I,userName:(null==i?void 0:i.userName)||R,headers:null==i?void 0:i.headers}}(x)},[x]),y=null==r?void 0:r.webGpt,w=h(null);w.current||(w.current=M());var C=m(function(){return function(i,n,e){var o,t,l=k(i),r=(null==l?void 0:l.customMetaData)||{},a=(null==r?void 0:r.value)||{},u=(null==i?void 0:i.webSearchAnswer)||{},d=(null==i?void 0:i.extraMetaData)||i||{};return{userEmail:(null==i?void 0:i.userEmail)||(null==u?void 0:u.userEmail)||(null==n?void 0:n.userEmail)||"",userId:(null==i?void 0:i.userId)||(null==u?void 0:u.userId)||(null==n?void 0:n.userId)||"",userName:(null==i?void 0:i.userName)||(null==u?void 0:u.userName)||(null==n?void 0:n.userName)||"",citationId:E(i,e),citationUrl:(null==a?void 0:a.citationUrl)||(null==u?void 0:u.citationUrl)||"",content:(null==d?void 0:d.Reasoning)||(null==u?void 0:u.enhanced_content)||"",citationType:(null==a?void 0:a.citationType)||"web",citatioNumber:null!==(t=null!==(o=null==r?void 0:r.citation_number)&&void 0!==o?o:null==l?void 0:l.citation_number)&&void 0!==t?t:Number((null==i?void 0:i.reasoningId)||0)}}(y,_,w.current||void 0)},[y,_]),F=m(function(){return k(y)},[y]),P=(null===(l=null==F?void 0:F.customMetaData)||void 0===l?void 0:l.value)||{},G=(null==y?void 0:y.extraMetaData)||y||{},A=v(),H=A[0],W=A[1],z=v("pending"),B=z[0],O=z[1],V=v(!0),L=V[0],J=V[1];p(function(){var o=!0;return n(void 0,void 0,void 0,function(){var n,t,l,r;return e(this,function(e){switch(e.label){case 0:if(!_.endpoint||!(null==C?void 0:C.citationUrl)||!(null==C?void 0:C.content))return O("error"),[2];O("pending"),e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(_.endpoint,{method:"POST",headers:i({"actor-id":C.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},_.headers||{}),body:JSON.stringify(C)})];case 2:if(!(n=e.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return t=e.sent(),l=(null==t?void 0:t.responseData)||(null==t?void 0:t.result)||(null==t?void 0:t.data)||t,o?(W(l),O("success"),[3,5]):[2];case 4:return r=e.sent(),o?(console.error("Failed to load GPT web citation",r),O("error"),[3,5]):[2];case 5:return[2]}})}),function(){o=!1}},[C,_]);var Y=m(function(){return{item:{confidence_score:Number((null==G?void 0:G.Confidence_score)||0),text:(null==P?void 0:P.paraphrase)||"Web citation reasoning",dataSource:(null==P?void 0:P.text)||(null==G?void 0:G.Reasoning)||"",paraphrase:(null==P?void 0:P.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==C?void 0:C.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:u,ChevronUpIcon:a,MaximizeIcon:d,CloseIcon:c}}},[P,null==C?void 0:C.citatioNumber,G]),$=m(function(){return i(i({},Y),f?{bodyHeight:U}:{})},[Y,f]);return t("div",i({style:{overflowY:"auto"}},{children:t(T,{gptCitation:$,defaultCitationUrl:(null==C?void 0:C.citationUrl)||"",citationType:S.GPT_WEB,webCitationData:H,webCitationStatus:B,showWebCitation:L,onToggleCitationView:function(){return J(function(i){return!i})},iconsConfig:{MaximizeIcon:d,ExternalLinkIcon:s},showGptMaximizeButton:!1,useParentHeight:!0,onFullscreenChange:b})}))},H=function(n){var e,o,r,a,u,d,c,s=n.href,v=n.metaData,p=n.citationTitle,h=n.citationType,b=n.citationReason,x=n.isFullscreen,w=n.onFullscreenChange,T=D().guidelinesData,S=function(i){try{var n=function(i){var n=i.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(n)try{var e=i.indexOf("?"),o=e>=0?i.slice(e):"";return{citationNumber:n[1],parsedUrl:new URL(o||"./",window.location.origin)}}catch(i){return{citationNumber:n[1],parsedUrl:null}}try{var t=new URL(i,window.location.origin);return{citationNumber:t.searchParams.get("citationNumber")||t.searchParams.get("citation_number"),parsedUrl:t}}catch(i){return{citationNumber:null,parsedUrl:null}}}(i),e=n.citationNumber,o=n.parsedUrl;return{citationNumber:e,phraseToHighlight:(null==o?void 0:o.searchParams.get("phrase_to_highlight"))||null,citationTypeFromHref:(null==o?void 0:o.searchParams.get("citation_type"))||null}}catch(i){return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}}(s),k=S.citationNumber,N=S.phraseToHighlight,j=S.citationTypeFromHref,I=h||j||void 0,R="il_rulebook_citation"===I?"rulebook_citation":I,G=k&&(null===(e=null==v?void 0:v.citations)||void 0===e?void 0:e[k])||{},U=(null===(o=null==v?void 0:v.docData)||void 0===o?void 0:o.documents)||{},M=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},E=Object.keys((null==v?void 0:v.citations)||{}).length>0||Object.keys((null==v?void 0:v.docData)||{}).length>0,H=null==M?void 0:M[0],W=null==M?void 0:M[1],z=H?U[H]:null,B=W?U[W]:null,O=H?G[H]:null,V=W?G[W]:null,L=m(function(){var i,n,e,o;return O&&z?t(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==z?void 0:z.title,pdfUrl:null==z?void 0:z.signed_url,highlightText:[null!==(i=null==O?void 0:O.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==O?void 0:O.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(e=null==O?void 0:O.custom_metadata)||void 0===e?void 0:e.pdf_start_page_number,null===(o=null==O?void 0:O.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==z?void 0:z.title,null==z?void 0:z.signed_url,null==O?void 0:O.highlighted_text,null===(a=null==O?void 0:O.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(u=null==O?void 0:O.custom_metadata)||void 0===u?void 0:u.pdf_end_page_number]),J=m(function(){var i,n,e,o;return V&&B?t(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==B?void 0:B.title,pdfUrl:null==B?void 0:B.signed_url,jumpToPageValue:1,highlightText:[null!==(i=null==V?void 0:V.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==V?void 0:V.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(e=null==V?void 0:V.custom_metadata)||void 0===e?void 0:e.pdf_start_page_number,null===(o=null==V?void 0:V.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==B?void 0:B.title,null==B?void 0:B.signed_url,null==V?void 0:V.highlighted_text,null===(d=null==V?void 0:V.custom_metadata)||void 0===d?void 0:d.pdf_start_page_number,null===(c=null==V?void 0:V.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]),Y="dual_citation"===R,$=Y&&!!(null==v?void 0:v.webGpt),q=m(function(){var n=$?t(A,{metaData:v,isFullscreen:x,onFullscreenChange:w}):"rulebook_citation"===R?t(l,{children:t(C,i({sx:i(i({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},F),{overflow:"auto"})},{children:t(_,i({rehypePlugins:[y]},{children:P({guidelinesData:T,targetHighlights:[N],labelColor:"#FEF08A"})}))}))}):J;return t(g,{leftComponent:L,rightComponent:n,isFullscreen:x})},[L,J,R,$,v,x,T,N,w]);return(null==v?void 0:v.webGpt)&&!E?t(A,{metaData:v,isFullscreen:x,onFullscreenChange:w}):k?"rulebook_citation"===R?t("div",O?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):i({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:b||"Rulebook citation selected."})):Y?O||V?t("div",i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q})):(null==v?void 0:v.webGpt)?t(A,{metaData:v,isFullscreen:x,onFullscreenChange:w}):t("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(p)?t("div",O||V?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):{children:"Missing PDF Citation. Please try again later"}):t("div",{children:"No Citation Found. Please try again later"}):null},W=function(n){var e,l,d,c,s,m,h,g=n.href,f=n.children,_=n.citationType,y=n.citationReason,C=n.metaData,F=n.chevronUpComponent,D=void 0===F?null:F,P=n.chevronDownComponent,T=void 0===P?null:P,S=n.customStyle,k=void 0===S?{}:S,N=n.defaultState,j=void 0!==N&&N,I=n.onFullscreenChange,R=v(j),U=R[0],M=R[1],E=v(!1),A=E[0],W=E[1],z="string"==typeof f&&(null===(e=null==f?void 0:f.split("\n"))||void 0===e?void 0:e.length)>1?f.split("\n").join(" "):f;p(function(){if(null==I||I(A),A)return function(){null==I||I(!1)}},[A,I]);var B="string"==typeof f?f:f[0],O=null!=D?D:function(i){var n,e;return t(a,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(e=null==i?void 0:i.color)&&void 0!==e?e:"rgb(214, 51, 132)"})}(null!==(l=null==k?void 0:k.arrow)&&void 0!==l?l:{}),V=null!=T?T:function(i){var n,e;return t(u,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(e=null==i?void 0:i.color)&&void 0!==e?e:"rgb(214, 51, 132)"})}(null!==(d=null==k?void 0:k.arrow)&&void 0!==d?d:{}),L=o("div",i({style:{boxSizing:"border-box",border:A?"none":"1px solid #E4E7EC",borderRadius:A?0:"8px",overflow:"hidden",marginTop:A?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:A?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[t("div",i({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:t("button",i({onClick:function(){W(function(i){var n=!i;return null==I||I(n),n})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:t(A?b:x,{})}))})),t("div",i({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:t(H,{href:g,children:f,metaData:C,citationTitle:B,citationType:_,citationReason:y,isFullscreen:A,onFullscreenChange:I})}))]}));return o("span",i({style:i({display:"inline"},k.relativeWrapper||{})},{children:[t("div",i({style:i({display:"inline",marginTop:0},k.citationButtonWrapper||{})},{children:o("button",i({type:"button",onClick:function(){return M(function(i){return!i})},style:i({display:(null==C?void 0:C.webGpt)?"inline":"inline-flex",alignItems:(null==C?void 0:C.webGpt)?void 0:"center",gap:(null==C?void 0:C.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==C?void 0:C.webGpt)?600:700,color:(null==C?void 0:C.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},k.citationButton||{})},{children:[(null==C?void 0:C.webGpt)&&t(r,{size:null!==(s=null===(c=k.arrow)||void 0===c?void 0:c.fontSize)&&void 0!==s?s:"1em",color:null!==(h=null===(m=k.arrow)||void 0===m?void 0:m.color)&&void 0!==h?h:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),t("span",{children:z}),t("span",i({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==C?void 0:C.webGpt)?"3px":void 0,verticalAlign:(null==C?void 0:C.webGpt)?"-0.125em":void 0}},{children:U?O:V}))]}))})),U&&(A?t(w,i({open:A,onClose:function(){W(!1),null==I||I(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:G,m:0,maxHeight:G,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:L})):L)]}))};export{W as default};
2
2
  //# sourceMappingURL=CitationAnchor.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 d}from"react";import{Box as s,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,de,se,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,dn=re.isGuidelineMode,sn=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),di=ai.cognitivePopup,si=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===(se=null===(ae=null==qe?void 0:qe.documents)||void 0===ae?void 0:ae[null===(de=null==qe?void 0:qe.input_index_map)||void 0===de?void 0:de[0]])||void 0===se?void 0:se.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,dn),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,dt=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}),st=dt.isSideBySide,vt=dt.isArrowVisible,ft=dt.setIsArrowVisible,pt=dt.isResizing,gt=dt.setIsResizing,ht=dt.isSideBySideLoading,mt=dt.activeSideBySideSection,St=dt.scrollLock,xt=dt.sideBySideCacheRef,Rt=dt.isSideBySideRef,bt=dt.activeSideBySideRightSectionRef,yt=dt.activeSideBySideSectionRef,Ct=dt.sideBySideLineRef,wt=dt.highlightedClauseRefs,Bt=dt.clearClauseHighlight,_t=dt.resetSideBySide,It=dt.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=d(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=d(function(e,n,i,t,o,r){return ur.current(e,n,i,t,o,r)},[]),Ut=d(function(e,n,i,t,o){return ar.current(e,n,i,t,o)},[]),Qt=d(function(){return dr.current()},[]),Zt=d(function(e,n){return sr.current(e,n)},[]),eo=d(function(e){return vr.current(e)},[]),no=d(function(e){return fr.current(e)},[]),io=d(function(){return pr.current()},[]),to=d(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=d(function(n,i,t,o,r,l,u){var c,a,d,s,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!==(d=null===(a=lt.current[o])||void 0===a?void 0:a.current)&&void 0!==d?d: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)||{},d=(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 d?e(e(e({},a),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),C=(null!==(f=null===(v=null===(s=null==y?void 0:y.cognitive_decisioning)||void 0===s?void 0:s.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=d(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=d(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=d(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=d(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=d(function(e){var n,i,t,o,r,l,u,c,a,d=null===(n=null==Ht?void 0:Ht.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],v=(null==s?void 0:s.relation)||(null===(t=null===(i=null==s?void 0:s.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.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:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=s.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:st,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=d(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(){st||0!==_n.size||Dn(!1)},[st,_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=st},[st]),a(function(){yt.current=mt},[mt]);var Mo=d(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,d=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==d?void 0:d.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)?1:0},[zi,$n]),Ho=d(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 d=(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&&d&&t&&o){var s=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=d.getBoundingClientRect(),n=s.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=d(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=d(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=d(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 d=c.top-window.innerHeight/2;fn?(null===(e=li.current)||void 0===e||e.scrollBy({top:d,behavior:"smooth"}),null===(i=ni.current)||void 0===i||i.scrollBy({top:d,behavior:"smooth"})):null===(r=Zn.current)||void 0===r||r.scrollBy({top:d,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",d="".concat(nn.id,":").concat(o);Uo.current!==d&&(xi(),wi(),_t(),In(new Set),En([]),Vn.current=[],Uo.current=d);var s=!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(!s){var d=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;s||(e=X,n=function(){s||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!s)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),d=a.top,v=a.height,f=null!==o&&Math.abs(d-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=d,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 s?[2]:(d(),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;d();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(){s=!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=di.open,Zo=di.sectionIdx,er=di.isOrphan,nr=di.badgeStyle,ir=di.anchorEl,tr=di.sectionAnchorEl;a(function(){var n,i;if($e.isStreamingEnabled&&Qo&&null!=Zo&&Zo!==qt){var t="string"==typeof Zo?Zo.split(B)[0]:null,o=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var t=0,r=e;t<r.length;t++){var l=r[t];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=o(l.subsections,n);if(u)return u}}return null},r=t&&"string"==typeof t?o(zi,t):null,l=t&&"string"==typeof t?o(Wi,t):null,u="number"==typeof Zo?zi[Zo]||null:r||t&&((null===(n=null==qe?void 0:qe.nodes)||void 0===n?void 0:n[t])||(null==qe?void 0:qe[t]))||null,c="number"==typeof Zo&&fn?null===(i=null==u?void 0:u.refIndexes)||void 0===i?void 0:i[0]:void 0,a="number"==typeof Zo?(null!=c?Wi.find(function(e){return e.selfIndex===c}):Wi[Zo])||null:l,d=fo(ir,u,a,Zo,er,nr);si(function(n){return n.open?b(n.cognitiveData)===b(d.cognitiveData)&&b(n.deviationData)===b(d.deviationData)&&n.sectionTitle===d.sectionTitle&&n.refSectionTitle===d.refSectionTitle?n:e(e(e({},n),d),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Qo,Zo,er,nr,ir,tr,zi,Wi,fn,fo]);var or=d(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,d=e.sectionOffset,s=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:d,rhsOrphanVisualIndexes:s})},[]),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 dr=u(Wo);a(function(){dr.current=Wo},[Wo]);var sr=u(Pt);a(function(){sr.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:st,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:sn}},[Ni,fn,mn,rn,ln,un,st,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,sn]),hr=b(di.sectionTitle||Di||Ai),mr=b(Ni?Pi||ji||di.refSectionTitle:di.refSectionTitle||Pi||ji);return o($,e({value:gr},{children:r(s,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(s,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}),di.open&&o(j,{open:di.open,popupRef:bi,position:pi,popupConfig:Qe,onClose:function(){gi(null),si(function(n){return e(e({},n),{open:!1})}),Ri(null)},markdownStyles:Je,sectionTitle:hr,referenceSectionTitle:mr,cognitiveData:di.cognitiveData,anchorEl:di.anchorEl,sectionAnchorEl:di.sectionAnchorEl,scrollContainerEl:Zn.current,badgeStyle:di.badgeStyle,docData:di.docData,deviationData:di.deviationData,isLoading:di.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(s,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(s,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},fn?{flex:1}:{})},{children:r(s,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:st,activeSideBySideSection:mt,isArrowVisible:vt,maintainRelativeOrder:fn,proposedSections:zi,existingSections:Wi,cognitivePopup:di,activeBadgeId:hi,closeCognitivePopup:wi,setActiveBadgeId:Ri,openCognitivePopupFromState:Ci,buildSectionPopupState:fo,connectedLines:Tn,isGuidelineMode:Ni,pathRefs:Gn}),r(s,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(s,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(s,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(s,e({ref:xo,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(s,e({onClick:function(n){n.stopPropagation(),di.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(s,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:di.open&&hi===qt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(s,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(s,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(s,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(s,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(s,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};
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";import{normalizeRedlineMarkdown as n}from"./utils/normalizeRedlineMarkdown.js";var e=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},o=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return o(t)}))},r=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},i=function(t){var n=t.section,e=t.proposedSections,o=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)?o.get(t.id):void 0;return null==u?null:e.length>1?"".concat(u).concat(r(i)):String(u)}).filter(Boolean);return 0===a.length?i:l?a[0]:a.join(", ")},u=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},l=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):[]},a=function(t,n,o,r){var i,u,a;void 0===r&&(r={});var s=l(t,n,o,r),c=(null===(i=s[0])||void 0===i?void 0:i.data)||{},d=(null===(u=s[0])||void 0===u?void 0:u.attributes)||null;return{title:e((null==c?void 0:c.title)||""),content:e((null==c?void 0:c.content)||""),change_history:e((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}},s=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 c(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 d(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 v=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},f="::",g=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},h=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},p=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},b=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}},m=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=b(t,e),i=b(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}},y=function(t,o,r){var i=new Map;if(!o)return i;var u=function(t){var o=e(t||"").replace(/\\n/g,"\n");return h(o)?p(n(o)):o};return(t||[]).forEach(function(t){var n=new Map,e=function(t){var i;if(t){var l=u(t.content);((null===(i=t.evaluationResults)||void 0===i?void 0:i.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(e){var i=(null==e?void 0:e.nodeId)||t.nodeId||t.id;Object.entries((null==e?void 0:e.deviations)||{}).forEach(function(t){var e=t[0],a=t[1][o],s=u(a);if(s&&!g(a)&&m(l,s)){var c="".concat(i).concat("::").concat(e),d=r[c];null!=d&&n.set(c,d)}})}),(t.subsections||[]).forEach(e)}};if(e(t),0!==n.size){var l=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){i.set(n,t-l+1)})}}),i},_=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:""},x=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(" ")},T=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)},I=["#B91C1C","#A16207","#1D4ED8","#000000"],w=function(t){var n=I.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?I.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];(I=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(I)}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];(I=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(I)}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 I;m=T[x];(I=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(I)}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 w(t)-w(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},B=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"}},M=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=M(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=M(t[e],String(e),n);if(o)return o}return null},N=new WeakMap,j=function(t){if(t){var n=N.get(t);null!=n&&(clearTimeout(n),N.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=N.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(){j(t)},3e3);N.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 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)}},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{f as DEVIATION_BADGE_SEPARATOR,v as areMarkdownPropsEqual,d as debounce,_ as extractDeviationScore,S as findKeyPathByNodeId,m as findTextMatchRange,c as generateColorPalette,r as getAlphabeticSuffix,x as getBentArrowPath,A as getFirstDeviationColor,C as getFirstDeviationOutputValue,y as getLhsDeviationDisplayIndexes,s as getRationale,i as getRhsMappedSectionNumber,a as getSideData,h as hasMeaningfulRedlineTags,u as hasSingleMappedLhsSection,o as hasValue,L as highlightClause,g as isMissingStr,B as mixHexColors,M as recursivelyFindSubSectionIdxById,j as resetClauseHighlight,l as resolveComparisonInputItems,e as safeStringify,O as scrollAndHighlightClause,k as scrollAndWait,T as smoothScrollTo,p as stripRedlineTags,E as waitForScrollIdle};
1
+ import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as n}from"./utils/normalizeRedlineMarkdown.js";var e=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(e).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},r=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return r(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},i=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(", ")},u=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},l=function(t,n,e,r){var o;void 0===r&&(r={});var i=e[n],u=null===(o=null==t?void 0:t.comparison_inputs)||void 0===o?void 0:o[i];return u?(Array.isArray(u)?u:[u]).map(function(t,n){if(t&&"string"==typeof t&&t.trim()){var e=r[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):[]},a=function(t,n,r,o){var i,u,a;void 0===o&&(o={});var s=l(t,n,r,o),c=(null===(i=s[0])||void 0===i?void 0:i.data)||{},d=(null===(u=s[0])||void 0===u?void 0:u.attributes)||null;return{title:e((null==c?void 0:c.title)||""),content:e((null==c?void 0:c.content)||""),change_history:e((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}},s=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 c(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),r=e.r,o=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(r+(255-r)*n),Math.round(o+(255-o)*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 d(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}}var v=function(t,n){var e,r,o,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===(r=v[c].style)||void 0===r?void 0:r.badgeBg))return!1;if((null===(o=d[c].style)||void 0===o?void 0:o.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},f="::",g=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},h=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,r=null;null!==(r=e.exec(t));){if((null!==(n=r[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},p=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},m=function(t,n){for(var e="",r=[],o=[],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(" ")?o[o.length-1]=i+1:(e+=a,r.push(i),o.push(i+1))}return{text:e,starts:r,ends:o}},b=function(t,n,e){if(void 0===e&&(e=!1),!t||!n)return null;var r=t.toLowerCase().indexOf(n.toLowerCase());if(-1!==r)return{start:r,end:r+n.length};var o=m(t,e),i=m(n,e).text.trim().toLowerCase();if(!i)return null;var u=o.text.toLowerCase().indexOf(i);if(-1===u)return null;var l=u+i.length-1,a=o.starts[u],s=o.ends[l];return void 0===a||void 0===s?null:{start:a,end:s}},y=function(t,n){var e=b(t,n,!0);if(e)return e;for(var r=0,o=n.split(/\n+/).map(function(t){return t.trim()}).filter(function(t){return!(t.length<12)&&!(""===t.replace(/[|:\-\s]/g,""))});r<o.length;r++){var i=o[r],u=b(t,i,!0);if(u)return u}return null},_=function(t,r,o){var i=new Map;if(!r)return i;var u=function(t){var r=e(t||"").replace(/\\n/g,"\n");return h(r)?p(n(r)):r};return(t||[]).forEach(function(t){var n=new Map,e=function(t){var i;if(t){var l=u(t.content);((null===(i=t.evaluationResults)||void 0===i?void 0:i.length)?t.evaluationResults:t.evaluationResult?[t.evaluationResult]:[]).forEach(function(e){var i=(null==e?void 0:e.nodeId)||t.nodeId||t.id;Object.entries((null==e?void 0:e.deviations)||{}).forEach(function(t){var e=t[0],a=t[1][r],s=u(a);if(s&&!g(a)&&b(l,s)){var c="".concat(i).concat("::").concat(e),d=o[c];null!=d&&n.set(c,d)}})}),(t.subsections||[]).forEach(e)}};if(e(t),0!==n.size){var l=Math.min.apply(Math,Array.from(n.values()));n.forEach(function(t,n){i.set(n,t-l+1)})}}),i},x=function(t,n){var e,r,o,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.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:""},T=function(t,n,e,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),u=r-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=u>0?1:-1,a=Math.min(o,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(r-l*a),"Q ".concat(i," ").concat(r," ").concat(i+a," ").concat(r),"H ".concat(e)].join(" ")},I=function(t,n,e,r,o){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),o&&o(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};requestAnimationFrame(s)},w=["#B91C1C","#A16207","#1D4ED8","#000000"],A=function(t){var n=w.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?w.length:n},C=function(n){for(var e,r,o,i,u,l,a,s,c,d,v,f,g,h=[],p=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});p<m.length;p++){var b=m[p];(I=null===(i=null===(o=null===(r=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[b])||void 0===r?void 0:r.evaluation_outputs)||void 0===o?void 0:o.metadata)||void 0===i?void 0:i.label_color)&&h.push(I)}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++){b=_[y];(I=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[b])||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(I)}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 I;b=T[x];(I=null===(v=null===(d=null===(c=null==n?void 0:n[b])||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(I)}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 A(t)-A(n)})[0]},B=function(t){for(var n,e,r,o,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(m=null===(r=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===r?void 0:r.output_value)return m}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(m=null===(u=null===(i=null===(o=null==t?void 0:t.deviation_entries)||void 0===o?void 0:o[v])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return m}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 m;v=p[h];if(m=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 m}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)]},r=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var o=e(t),i=e(n),u=(o[0]+i[0])/2*.95,l=(o[1]+i[1])/2*.95,a=(o[2]+i[2])/2*.95;return"#".concat(r(u)).concat(r(l)).concat(r(a))}catch(t){return"#FDE68A"}},S=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 r=0;r<t.subsections.length;r++){var o=S(t.subsections[r],"".concat(n,"-").concat(r),e);if(o)return o}return null},N=function(t,n){for(var e=0;e<t.length;e++){var r=S(t[e],String(e),n);if(r)return r}return null},j=new WeakMap,L=function(t){if(t){var n=j.get(t);null!=n&&(clearTimeout(n),j.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)}},O=function(t){if(t){var n=j.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(){L(t)},3e3);j.set(t,e)}},k=function(t,n){var e=n.getBoundingClientRect(),r=t.getBoundingClientRect(),o=n.scrollTop+r.top-e.top-e.height/2+r.height/2;n.scrollTo({top:o,behavior:"smooth"});var i=function(){return O(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)}},E=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var r,o=!1,i=function(){o||(o=!0,clearTimeout(r),t.removeEventListener("scrollend",u),e())},u=function(){return i()};t.addEventListener("scrollend",u),t.scrollTo({top:n,behavior:"smooth"}),r=setTimeout(i,800)}},R=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var r,o=!1,i=function(){o||(o=!0,t.removeEventListener("scroll",u),e())},u=function(){clearTimeout(r),r=setTimeout(i,n)};t.addEventListener("scroll",u),r=setTimeout(i,n)})};export{f as DEVIATION_BADGE_SEPARATOR,v as areMarkdownPropsEqual,d as debounce,x as extractDeviationScore,N as findKeyPathByNodeId,y as findRedlineTextAnchorRange,b as findTextMatchRange,c as generateColorPalette,o as getAlphabeticSuffix,T as getBentArrowPath,C as getFirstDeviationColor,B as getFirstDeviationOutputValue,_ as getLhsDeviationDisplayIndexes,s as getRationale,i as getRhsMappedSectionNumber,a as getSideData,h as hasMeaningfulRedlineTags,u as hasSingleMappedLhsSection,r as hasValue,O as highlightClause,g as isMissingStr,M as mixHexColors,S as recursivelyFindSubSectionIdxById,L as resetClauseHighlight,l as resolveComparisonInputItems,e as safeStringify,k as scrollAndHighlightClause,E as scrollAndWait,I as smoothScrollTo,p as stripRedlineTags,R as waitForScrollIdle};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import i from"react";import{Box as t}from"@mui/material";import{EllipsisVertical as r}from"lucide-react";import l from"./SectionAccordion.js";import a from"./ThreeDotsLoader.js";import{extractDeviationScore as d}from"../CognitiveComparehelpers.js";import{useCompareContext as c}from"../CompareContext.js";var s=i.memo(function(i){var s,p,u,v=i.section,f=i.idx,g=c(),m=g.maintainRelativeOrder,x=g.existingSections;g.proposedSections;var h=g.connectedSections,S=g.expandedSections,b=g.displayConfig,R=g.treeData;g.deviationNumberRegistry;var y=g.getSectionCompareStyle;g.getBadgeRef;var w=g.getSectionRowRef,B=g.sectionLeftRefs,C=g.lhsBadgeRefs,I=g.openMoreFunctionsPopup,N=g.handleOpenSummaryPopup,k=g.handleCloseSummaryPopup,P=g.toggleSection;g.showDeviationBadges,g.renderSubSectionAccordion,g.isProposingFix,g.proposingFixNodeId,g.isRedlineFlow,g.isSideBySide,g.activeSideBySideSection,g.scrollSyncLocked,g.toggleScrollSyncLocked,g.summaryPopupAnchorEl,g.deviationNodeIdToView,g.deviationTargetParentId;var D=g.showDeviationNavigation;g.showOpenNodeRef,g.resolvedMarkdownStyles;var T=g.unifiedNumbering,A=!v.title&&!v.content;if(m&&A)return null;var L=v,j=y(f,"left"),z=m?!(null===(s=L.refIndexes)||void 0===s?void 0:s.length)||L.selfIndex<0:!x[f],F=h.has(f);null===(p=C.current[f])||void 0===p||p.current;var O=d(L.evaluationResult,null==j?void 0:j.deviationLabel),W=T.leftNums.get(L.id);return o(t,e({ref:w(f),sx:{mb:1,width:"100%"}},{children:o(t,e({ref:B.current[f],sx:e({width:"100%",display:"flex",flexDirection:"column",minWidth:0},F&&{borderRadius:"6px",outline:"2px solid ".concat((null==j?void 0:j.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n(t,e({sx:{position:"relative",width:"100%"}},{children:[o(l,{section:v,idx:f,columnKey:"left",colRef:w("left-accordion-".concat(f)),mb:0,parentNodeId:(null===(u=null==R?void 0:R.input_index_map)||void 0===u?void 0:u[0])||"",isExpanded:m?!!S["left-".concat(f)]:!!S[String(f)],onToggle:function(){k(),P(f,"left")},navigation:v.id?D[v.id]:null}),m&&j&&n(t,e({ref:C.current[f],onClick:function(e){var o,n,i,t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=L.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=L.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;N(e,String(f),z,t)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:j.badgeBg,color:j.badgeText,border:"1px solid ".concat(j.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n(t,e({component:"span",onClick:function(e){var o,n,i;e.stopPropagation();var t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=L.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=L.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;N(e,String(f),z,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:z?"default":"pointer",borderRight:"1px solid ".concat(j.badgeBorder),"&:hover":z?{}:{bgColor:"".concat(j.badgeBorder,"22")}}},{children:[null!=W&&o(t,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(j.badgeBorder)}},{children:W})),o(t,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!b.isLoading||null!=L.evaluationResult&&void 0!==L.evaluationResult?"N/A"===O||"NA"===O?"N/A":0==O||null==O?"Same":"".concat(O):o(a,{color:j.badgeText})}))]})),o(t,e({component:"span",onClick:function(e){var o;e.stopPropagation();var n=null===(o=L.refIndexes)||void 0===o?void 0:o[0],i=m?x.find(function(e){return e.selfIndex===n})||{title:"",content:""}:x[f]||{title:"",content:""};I(e,v,z,i,f,j)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(j.badgeBorder,"22")}}},{children:o(r,{size:11,color:j.badgeText})}))]}))]}))}))}),"left-row-".concat(f))});export{s as default};
1
+ import{__assign as e}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import i from"react";import{Box as t}from"@mui/material";import{EllipsisVertical as r}from"lucide-react";import l from"./SectionAccordion.js";import a from"./ThreeDotsLoader.js";import{extractDeviationScore as d}from"../CognitiveComparehelpers.js";import{useCompareContext as c}from"../CompareContext.js";var s=i.memo(function(i){var s,p,u,v=i.section,f=i.idx,g=c(),m=g.maintainRelativeOrder,x=g.existingSections;g.proposedSections;var h=g.connectedSections,S=g.expandedSections,b=g.displayConfig,R=g.treeData;g.deviationNumberRegistry;var y=g.getSectionCompareStyle;g.getBadgeRef;var w=g.getSectionRowRef,B=g.sectionLeftRefs,C=g.lhsBadgeRefs,I=g.openMoreFunctionsPopup,N=g.handleOpenSummaryPopup,k=g.handleCloseSummaryPopup,P=g.toggleSection;g.showDeviationBadges,g.renderSubSectionAccordion,g.isProposingFix,g.proposingFixNodeId,g.isRedlineFlow,g.isSideBySide,g.activeSideBySideSection,g.scrollSyncLocked,g.toggleScrollSyncLocked,g.summaryPopupAnchorEl,g.deviationNodeIdToView,g.deviationTargetParentId;var D=g.showDeviationNavigation;g.showOpenNodeRef,g.resolvedMarkdownStyles;var T=g.unifiedNumbering,A=!v.title&&!v.content;if(m&&A)return null;var L=v,j=y(f,"left"),z=m?!(null===(s=L.refIndexes)||void 0===s?void 0:s.length)||L.selfIndex<0:!x[f],F=h.has(f);null===(p=C.current[f])||void 0===p||p.current;var O=d(L.evaluationResult,null==j?void 0:j.deviationLabel),W=T.leftNums.get(L.id);return o(t,e({ref:w(f),sx:{mb:1,width:"100%"}},{children:o(t,e({ref:B.current[f],sx:e({width:"100%",display:"flex",flexDirection:"column",minWidth:0},F&&{borderRadius:"6px",outline:"2px solid ".concat((null==j?void 0:j.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n(t,e({sx:{position:"relative",width:"100%"}},{children:[o(l,{section:v,idx:f,columnKey:"left",colRef:w("left-accordion-".concat(f)),mb:0,parentNodeId:(null===(u=null==R?void 0:R.input_index_map)||void 0===u?void 0:u[0])||"",isExpanded:m?!!S["left-".concat(f)]:!!S[String(f)],onToggle:function(){k(),P(f,"left")},navigation:v.id?D[v.id]:null}),m&&j&&n(t,e({ref:C.current[f],onClick:function(e){var o,n,i,t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=L.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=L.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;N(e,String(f),z,t)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:j.badgeBg,color:j.badgeText,border:"1px solid ".concat(j.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n(t,e({component:"span",onClick:function(e){var o,n,i;e.stopPropagation();var t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=L.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=L.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;N(e,String(f),z,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:z?"default":"pointer",borderRight:"1px solid ".concat(j.badgeBorder),"&:hover":z?{}:{bgColor:"".concat(j.badgeBorder,"22")}}},{children:[null!=W&&o(t,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(j.badgeBorder)}},{children:W})),o(t,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!b.isLoading||null!=L.evaluationResult&&void 0!==L.evaluationResult?"N/A"===O||"NA"===O?"N/A":0==O||null==O?"Same":"".concat(O):o(a,{color:j.badgeText})}))]})),o(t,e({component:"span",onClick:function(e){e.stopPropagation();var o=m?x.find(function(e){var o;return null===(o=L.refIndexes)||void 0===o?void 0:o.includes(e.selfIndex)})||{title:"",content:""}:x[f]||{title:"",content:""};I(e,v,z,o,f,j)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(j.badgeBorder,"22")}}},{children:o(r,{size:11,color:j.badgeText})}))]}))]}))}))}),"left-row-".concat(f))});export{s as default};
2
2
  //# sourceMappingURL=LHSSectionRow.js.map