@viswa-test/test-citation 0.0.20 → 0.0.22

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/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConfig.js +2 -0
  3. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConfig.js.map +1 -0
  4. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +2 -0
  5. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -0
  6. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +2 -0
  7. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -0
  8. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +2 -0
  9. package/dist/cjs/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js.map +1 -0
  10. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  11. package/dist/features/CognitiveCompare/CognitiveCompareConfig.js +2 -0
  12. package/dist/features/CognitiveCompare/CognitiveCompareConfig.js.map +1 -0
  13. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +2 -0
  14. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -0
  15. package/dist/features/CognitiveCompare/CognitivePopup.js +2 -0
  16. package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -0
  17. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js +2 -0
  18. package/dist/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js.map +1 -0
  19. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  20. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +4 -107
  21. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  22. package/dist/types/src/features/CognitiveCompare/CognitiveCompareConfig.d.ts +41 -0
  23. package/dist/types/src/features/CognitiveCompare/CognitiveCompareConfig.d.ts.map +1 -0
  24. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +15 -13
  25. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  26. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +33 -0
  27. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -0
  28. package/dist/types/src/features/CognitiveCompare/CognitivePopup.d.ts +5 -0
  29. package/dist/types/src/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -0
  30. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts +15 -0
  31. package/dist/types/src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.d.ts.map +1 -0
  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"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("react-dom"),s=require("../../assests/svg/SparkleIcon.js"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),a=require("react-markdown");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(i),u=c(r),x=c(a),g=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(g).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},p={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul, & ol":{mt:0,mb:1.5,pl:2.5},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"},"& ol":{listStyleType:"decimal"},"& ul":{listStyleType:"disc"}},h=function(e){return e?g(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(d.default.Fragment,{children:e},i)}):null},f=function(n,i,t,o){o.thresholds;var r=o.relationStyles;if(!t)return null;var s=function(e){return e&&"string"==typeof e?e:"Unknown"}(i);return(i||"").toLowerCase().includes("NA"),e.__assign(e.__assign({},r.low),{label:s})},v=function(i,o,r){if(!i)return null;if(!o||0===o.length)return h(i);var s=o.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===s.length)return h(i);var l=new RegExp("(".concat(s.join("|"),")"),"gi");return i.split(l).map(function(i,s){return o.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===i.toLowerCase()})?n.jsx(t.Box,e.__assign({component:"span",sx:{bgcolor:r.highlightBg,borderRadius:"2px",px:"2px"}},{children:h(i)}),s):n.jsx(d.default.Fragment,{children:h(i)},s)})},m=d.default.memo(d.default.forwardRef(function(i,o){var r=i.label,s=i.content,l=i.highlights,a=void 0===l?[]:l,c=i.styleVariant,d=i.isHighlighted,u=void 0!==d&&d,x=Array.isArray(s)?s.map(g).join("\n"):g(s),p=function(e){return"#9F1239"===e.badgeText?{borderColor:"#E11D48",shadow:"rgba(225, 29, 72, 0.25)"}:"#B91C1C"===e.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#1D4ED8"===e.badgeText?{borderColor:"#3B82F6",shadow:"rgba(59, 130, 246, 0.25)"}:"#A16207"===e.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"}}(c);return n.jsxs(t.Box,e.__assign({sx:{mb:1.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:r})),n.jsx(t.Box,e.__assign({ref:o,sx:{p:"4px 12px",borderRadius:"6px",border:u?"1.5px solid ".concat(p.borderColor):"1px solid ".concat(c.border),boxShadow:u?"0px 0px 0px 2px ".concat(p.shadow):"none",bgcolor:c.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:n.jsx(t.Box,{children:v(x,a,c)})}))]}))})),_=12,b=10,y=function(r){var l,a,c,d,g,h=r.open,f=r.onClose,v=r.sectionTitle,m=r.referenceSectionTitle,_=r.cognitiveData,y=r.relevanceScore,F=r.anchorEl,w=r.badgeStyle,B=r.popupRef,j=r.position,E=i.useState("association"),S=E[0],C=E[1],D=i.useMemo(function(){if(!w)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=w.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[w]);if(i.useEffect(function(){if(h){var e=function(e){var n;(null===(n=B.current)||void 0===n?void 0:n.contains(e.target))||(null==F?void 0:F.contains(e.target))||f()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[h,f,F,B]),!h||!_)return null;var k=null!==(a=null!==(l=_.relevance_score)&&void 0!==l?l:y)&&void 0!==a?a:0,A=_.decisioning,R=Array.isArray(A)?A:"string"==typeof A&&A.trim()?[A]:[],T=_.gap,I=Array.isArray(T)?T:"string"==typeof T&&T.trim()?[T]:[],z=null!==(c=null==j?void 0:j.arrowLeft)&&void 0!==c?c:60,W=n.jsxs(t.Box,e.__assign({ref:B,sx:{position:"fixed",top:null!==(d=null==j?void 0:j.top)&&void 0!==d?d:-9999,left:null!==(g=null==j?void 0:j.left)&&void 0!==g?g:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(D.border),boxShadow:"0px 8px 32px ".concat(D.shadow,", 0px 0px 0px 3px ").concat(D.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==j?void 0:j.maxHeight)?"min(60vh, ".concat(j.maxHeight,"px)"):"60vh",visibility:j?"visible":"hidden"}},{children:[j&&(j.openAbove?n.jsxs(n.Fragment,{children:[n.jsx(t.Box,{sx:{position:"absolute",bottom:-11,left:z-b,width:0,height:0,borderLeft:"".concat(b,"px solid transparent"),borderRight:"".concat(b,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(D.border),zIndex:1}}),n.jsx(t.Box,{sx:{position:"absolute",bottom:-9,left:z-b+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(b,"px solid #FFFFFF"),zIndex:2}})]}):n.jsxs(n.Fragment,{children:[n.jsx(t.Box,{sx:{position:"absolute",top:-11,left:z-b,width:0,height:0,borderLeft:"".concat(b,"px solid transparent"),borderRight:"".concat(b,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(D.border),zIndex:1}}),n.jsx(t.Box,{sx:{position:"absolute",top:-9,left:z-b+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(b,"px solid #FFFFFF"),zIndex:2}})]})),n.jsxs(t.Box,e.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[n.jsxs(t.Box,e.__assign({sx:{flex:1,minWidth:0}},{children:[n.jsxs(t.Typography,e.__assign({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[n.jsx(t.Box,e.__assign({component:"span",title:v,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:v})),n.jsx(t.Box,e.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),n.jsx(t.Box,e.__assign({component:"span",title:m||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:m||"Reference Section"}))]})),n.jsx(t.Box,e.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"deviation"===S?"Why this is a deviation?":"Why these sections are paired?"}))}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[n.jsx(s.default,{}),"Decision Strength ",k,"%"]})),n.jsx(t.IconButton,e.__assign({onClick:f,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:n.jsx(o.X,{size:22})}))]}))]})),n.jsx(t.Box,e.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(i){var o=S===i,r="deviation"===i?"Deviation Analysis":"Association Logic";return n.jsx(t.Box,e.__assign({onClick:function(){return C(i)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:o?600:400,color:o?"#5928ED":"#667085",backgroundColor:o?"rgba(89,40,237,0.08)":"transparent",borderBottom:o?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:r}),i)})})),n.jsx(t.Box,e.__assign({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(D.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:D.border},scrollbarWidth:"thin",scrollbarColor:"".concat(D.border,"55 transparent")}},{children:"deviation"===S?n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):n.jsxs(n.Fragment,{children:[R.length>0&&n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(t.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),n.jsx(t.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column"}},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:e.__assign({},p)},{children:n.jsx(x.default,{children:R.join("\n\n")})}))}))}))]})),I.length>0&&n.jsxs(t.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[n.jsx(t.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),n.jsx(t.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column"}},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:e.__assign({},p)},{children:n.jsx(x.default,{children:I.join("\n\n")})}))}))}))]})),0===R.length&&0===I.length&&n.jsx(t.Box,e.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return u.default.createPortal(W,document.body)},F=d.default.memo(function(i){var r=i.data,s=i.isSelected,a=i.isCognitiveOpen,c=i.onToggleCognitive,d=i.onClick,u=g(r.summaryText||r.description),x=u.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),p=x?u.replace(x[0],"").trim():u,h=!!x;return n.jsxs(t.Box,e.__assign({id:"variant-card-".concat(r.id),onClick:d,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:s?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:r.isLoading?.7:1,border:s?"1.4px solid #2563EB":void 0,boxShadow:s?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:s?"#2563EB":"#CBD5E1",boxShadow:s?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:r.isLoading?n.jsx(t.Skeleton,{variant:"rounded",width:80,height:20}):n.jsxs(t.Box,e.__assign({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==r.similarity?r.similarity:0,"% Similarity"]}))})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:g(r.title)}))})),r.isLoading?n.jsxs(t.Box,{children:[n.jsx(t.Skeleton,{width:"90%"}),n.jsx(t.Skeleton,{width:"60%"})]}):n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:p})),h&&n.jsxs(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),s||d(),c()},sx:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:12,style:{transform:s&&a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))}),w=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],B={fields:w,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},j=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return j(e)}))},E=function(e,n,i){var t,o=i[n],r=null===(t=null==e?void 0:e.comparison_inputs)||void 0===t?void 0:t[o];return{title:g((null==r?void 0:r.title)||""),content:g((null==r?void 0:r.content)||"")}},S=function(n){var i,t,o,r,s=[],l=[],a=n.base_root_id,c=n.input_index_map||{0:"left",1:"right"},d=n[a];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(i){var t=n[i];if(t&&!1!==t.display_node){var o=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"NA"};var n=e.mapping_rationale,i=!n.decision_strength,t=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:t},score:i?100:t/100,relation:"NA"}}(t),r=E(t,"0",c),a=E(t,"1",c),d=r.title.trim()||r.content.trim(),x=a.title.trim()||a.content.trim();s.push(e.__assign({id:i,title:d?r.title:"",content:d?r.content:"",subsections:[]},d?o:{score:void 0,relation:"not_defined"})),l.push(e.__assign({id:i,title:x?a.title:"",content:x?a.content:"",subsections:[]},x?o:{score:void 0,relation:"not_defined"})),t.next&&Object.values(t.next).forEach(u)}};return d.next&&Object.values(d.next).forEach(u),{activeProposed:{title:(null===(t=null===(i=d.comparison_inputs)||void 0===i?void 0:i[c[0]])||void 0===t?void 0:t.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(o=d.comparison_inputs)||void 0===o?void 0:o[c[1]])||void 0===r?void 0:r.title)||"Reference Template",similarity:0,sections:l,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}},C={id:"",title:""};exports.DEFAULT_COMPARISON_CONFIG=B,exports.DEFAULT_FIELD_CONFIG=w,exports.default=function(r){var s,a,c,u=r.variants,v=void 0===u?[]:u,E=r.treeData,D=r.comparisonConfig,k=r.onSelectVariant,A=r.targetVariantId,R=r.highlightedField,T=i.useState(null),I=T[0],z=T[1],W=i.useMemo(function(){return(null==E?void 0:E.cognitive_decisioning)||{}},[E]),L=i.useRef(null),H=i.useState(null),M=H[0],O=H[1],q=i.useRef(null),P=i.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null}),N=P[0],V=P[1],U=i.useRef(null),K=i.useRef(null),G=i.useRef(null),Y=i.useRef(!1),J=i.useRef(null);i.useEffect(function(){J.current=null},[N.sectionIdx,N.open]);var X=i.useCallback(function(){var e;if(N.anchorEl&&N.refSectionTitle){var n=N.anchorEl.getBoundingClientRect(),i=(null===(e=null==q?void 0:q.current)||void 0===e?void 0:e.offsetHeight)||0,t=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-_,r=n.top-12-_,s=o<i&&r>o;null!==J.current?!0===J.current&&(s=r>=i||r>=o):s=!(o>=i||o>=r),J.current=s;var l=s?r:o,a=Math.min(i||9999,l),c=s?n.top-12-a:n.bottom+12,d=n.left+n.width/2,u=d-t/2,x=Math.max(_,Math.min(u,window.innerWidth-t-_)),g=Math.max(14,Math.min(d-x,t-b-4));O({top:c,left:x,arrowLeft:g,openAbove:s,maxHeight:l})}},[N.anchorEl,N.refSectionTitle]);i.useEffect(function(){if(N.open){window.addEventListener("resize",X);var e=requestAnimationFrame(X),n=null;return q.current&&(n=new ResizeObserver(function(){e=requestAnimationFrame(X)})).observe(q.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",X),n&&n.disconnect()}}},[N.open,X]),i.useEffect(function(){var n=K.current;if(n&&N.open){var i=function(n){q.current&&q.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),O(null),V(function(n){return e.__assign(e.__assign({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})}))};return n.addEventListener("scroll",i,{capture:!0}),window.addEventListener("scroll",i,{capture:!0}),function(){n.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("scroll",i,{capture:!0})}}},[N.open]);var $=i.useMemo(function(){var n,i,t,o,r,s,l,a,c,d,u,x;return{fields:null!==(n=null==D?void 0:D.fields)&&void 0!==n?n:w,thresholds:{high:null!==(t=null===(i=null==D?void 0:D.thresholds)||void 0===i?void 0:i.high)&&void 0!==t?t:B.thresholds.high,medium:null!==(r=null===(o=null==D?void 0:D.thresholds)||void 0===o?void 0:o.medium)&&void 0!==r?r:B.thresholds.medium,exact:null!==(l=null===(s=null==D?void 0:D.thresholds)||void 0===s?void 0:s.exact)&&void 0!==l?l:B.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},B.relationStyles.noContent),(null===(a=null==D?void 0:D.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},B.relationStyles.high),(null===(c=null==D?void 0:D.relationStyles)||void 0===c?void 0:c.high)||{}),exact:e.__assign(e.__assign({},B.relationStyles.exact),(null===(d=null==D?void 0:D.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},B.relationStyles.medium),(null===(u=null==D?void 0:D.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e.__assign(e.__assign({},B.relationStyles.low),(null===(x=null==D?void 0:D.relationStyles)||void 0===x?void 0:x.low)||{})}}},[D]),Q=i.useMemo(function(){if(E&&Object.keys(E).length>0)try{var n=S(E);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:v||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:v||[],parseError:null}},[E,v]),Z=Q.activeProposed,ee=Q.activeVariants,ne=Q.parseError;i.useEffect(function(){ne&&z("Failed to load comparison: ".concat(ne))},[ne]);var ie=i.useState(A||null),te=ie[0],oe=ie[1],re=i.useState(!1),se=re[0],le=re[1],ae=i.useState(null),ce=ae[0],de=ae[1],ue=i.useState({}),xe=ue[0],ge=ue[1];i.useEffect(function(){if(A&&oe(A),de(null!=R?R:null),R){var e=setTimeout(function(){return de(null)},6e3);return function(){return clearTimeout(e)}}},[A,R]);var pe=function(e){var n;null===(n=U.current)||void 0===n||n.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},he=i.useMemo(function(){return e.__spreadArray([],ee,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[ee]),fe=i.useMemo(function(){if(te){var e=String(te).trim();return ee.find(function(n){return n.id&&String(n.id).trim()===e})||he[0]}return he[0]||null},[te,ee,he]);i.useEffect(function(){te&&U.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(te.trim())),n=U.current;if(e&&n){var i=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:i,behavior:"smooth"})}},150)},[te,he]);var ve=fe||C,me=g(Z.title)||"Uploaded Contract",_e=g(ve.title)||"Reference Template",be=i.useMemo(function(){return Z.sections||[]},[Z.sections]),ye=i.useMemo(function(){return ve.sections||[]},[ve.sections]),Fe=be.length>0||ye.length>0,we=null==fe?void 0:fe.analysis,Be=g(null===(a=null===(s=null==we?void 0:we.rule_difference_comparison)||void 0===s?void 0:s.summary)||void 0===a?void 0:a.overall_summary),je=!!Be.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ee=null!==(c=null==fe?void 0:fe.similarity)&&void 0!==c?c:0,Se=i.useRef({}),Ce=function(e){return Se.current[e]||(Se.current[e]=d.default.createRef()),Se.current[e]};i.useEffect(function(){!te&&!A&&he.length>0&&!he[0].isLoading&&oe(he[0].id)},[he,te,A]);var De=i.useRef(null),ke=i.useRef(null),Ae=i.useRef(null),Re=i.useState([]),Te=Re[0],Ie=Re[1],ze=i.useState(null),We=ze[0],Le=ze[1],He=i.useState(!1),Me=He[0],Oe=He[1],qe=i.useState(!1),Pe=qe[0],Ne=qe[1];i.useEffect(function(){var e=U.current;if(e){var n=function(){Oe(e.scrollLeft>0),Ne(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[he]);var Ve=i.useMemo(function(){return $.fields.filter(function(e){var n=e.key;return(!Fe||"description"!==n)&&(j(Z[n])||j(ve[n]))})},[Z,ve,Fe,$.fields]),Ue=i.useRef({}),Ke=i.useRef({}),Ge=i.useRef({}),Ye=i.useRef({});Ve.forEach(function(e){var n=e.key;Ue.current[n]||(Ue.current[n]=d.default.createRef()),Ke.current[n]||(Ke.current[n]=d.default.createRef())});for(var Je=0;Je<Math.max(be.length,ye.length);Je+=1)Ge.current[Je]||(Ge.current[Je]=d.default.createRef()),Ye.current[Je]||(Ye.current[Je]=d.default.createRef());i.useEffect(function(){if(ce){var e=$.fields.find(function(e){return e.analysisKey===ce||e.key===ce});if(e){var n=Ue.current[e.key]||Ke.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ce,$.fields]);var Xe=i.useCallback(function(e){var n,i,t,o,r,s,l,a,c,d=null===(n=null==we?void 0:we.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=d[e],x=(null==u?void 0:u.relation)||(null===(t=null===(i=null==u?void 0:u.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==u?void 0:u.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var g=u.mappings[0]||{};return{score:u.score,relation:g.relation||"",highlightsA:(null===(s=g.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(l=g.highlights)||void 0===l?void 0:l.ruleB_spans)||[],hasContent:!!x}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(a=u.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=u.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!x}},[we]),$e=i.useCallback(function(n){var i,t,o=be[n],r=ye[n],s=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,l=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,a=!(!(null==o?void 0:o.cognitiveData)&&!(null==r?void 0:r.cognitiveData));if(!s&&!l&&!a)return e.__assign(e.__assign({},$.relationStyles.noContent),{label:"Not Defined"});var c,d=Xe("description"),u=null!==(i=null==o?void 0:o.cognitiveRelevanceScore)&&void 0!==i?i:null==r?void 0:r.cognitiveRelevanceScore;if(null!=u){var x=(c=u)>=90?{score:1,relation:"exact_match"}:c>=70?{score:.8,relation:"high_match"}:c>=40?{score:.5,relation:"partial_match"}:{score:0,relation:"NA"};return f(0,x.relation,!0,$)}var g=s?o.relation:l?r.relation:d.relation,p=null!==(t=null==o?void 0:o.score)&&void 0!==t?t:null==r?void 0:r.score;"number"==typeof p||d.score;return f(0,g,!0,$)},[be,ye,$,Xe]),Qe=i.useCallback(function(){var e,n,i;if(!Y.current){Y.current=!0;try{if(!De.current)return;var t=De.current.getBoundingClientRect(),o=[];Ve.forEach(function(e){var n=e.key,i=e.analysisKey,r=Ue.current[n],s=Ke.current[n];if((null==r?void 0:r.current)&&(null==s?void 0:s.current)){r.current.style.height="auto",s.current.style.height="auto",r.current.style.minHeight="0px",s.current.style.minHeight="0px";var l=r.current.getBoundingClientRect().height,a=s.current.getBoundingClientRect().height,c=Math.max(l,a);r.current.style.minHeight="".concat(c,"px"),s.current.style.minHeight="".concat(c,"px");var d=r.current.getBoundingClientRect(),u=s.current.getBoundingClientRect(),x=Xe(i),g=f(x.score,x.relation,x.hasContent,$);if(!g)return;var p=d.top+d.height/2-t.top;o.push({id:"field-".concat(n),x1:d.right-t.left,y1:p,x2:u.left-t.left,y2:p,style:g})}});for(var r=Math.min(be.length,ye.length),s=0;s<r;s+=1){var l=Ge.current[s],a=Ye.current[s];if((null==l?void 0:l.current)&&(null==a?void 0:a.current)){l.current.style.height="auto",a.current.style.height="auto",l.current.style.minHeight="0px",a.current.style.minHeight="0px";var c=Math.max(l.current.getBoundingClientRect().height,a.current.getBoundingClientRect().height);l.current.style.minHeight="".concat(c,"px"),a.current.style.minHeight="".concat(c,"px");var d=l.current.querySelector(".MuiAccordionSummary-root"),u=a.current.querySelector(".MuiAccordionSummary-root");if(d&&u){var x=d.getBoundingClientRect(),g=u.getBoundingClientRect(),p=(x.top+x.height/2-t.top+g.top+g.height/2-t.top)/2,h=(null===(e=ye[s])||void 0===e?void 0:e.id)||"sec-".concat(s),v=$e(s);v&&o.push({id:h,x1:x.right-t.left,y1:p,x2:g.left-t.left,y2:p,style:v,sectionIdx:s,hasCognitive:!(!(null===(n=be[s])||void 0===n?void 0:n.cognitiveData)&&!(null===(i=ye[s])||void 0===i?void 0:i.cognitiveData))})}}}if(Ie(o),ke.current&&Ae.current){var m=ke.current.getBoundingClientRect(),_=Ae.current.getBoundingClientRect(),b=(m.top+m.height/2-t.top+_.top+_.height/2-t.top)/2;Le({x1:m.right-t.left,x2:_.left-t.left,y:b})}else Le(null)}catch(e){console.error("Line render safe fail: ",e)}finally{Y.current=!1}}},[Ve,be,ye,$,Xe,$e]);i.useEffect(function(){var e=setTimeout(Qe,250);window.addEventListener("resize",Qe);var n=null;return K.current&&(n=new ResizeObserver(function(){return window.requestAnimationFrame(Qe)})).observe(K.current),function(){clearTimeout(e),window.removeEventListener("resize",Qe),null==n||n.disconnect()}},[Z,ve,we,se,Ve,xe,be,ye,$,Qe]);var Ze=function(i,r,s,l){var a=!j(i.title)&&!j(i.content);return n.jsx(t.Box,e.__assign({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!a&&!!xe[r],onChange:function(){return!a&&(n=r,void ge(function(i){var t;return e.__assign(e.__assign({},i),((t={})[n]=!i[n],t))}));var n},sx:{boxShadow:"none",border:a?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:a?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:a?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:a?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:a?"#94A3B8":"#19213D",fontWeight:a?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:h(i.title||"No Matching Section Found")}))})),!a&&n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:p},{children:n.jsx(x.default,{children:g(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(i,o){return n.jsx(t.Box,e.__assign({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:p},{children:n.jsx(x.default,{children:g(i).replace(/\\n/g,"\n")})}))}),"".concat(s,"-sub-").concat(r,"-").concat(o))})]}))]}))}),"".concat(s,"-sec-").concat(r))};return n.jsxs(t.Box,e.__assign({ref:G,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[N.open&&n.jsx(y,{open:N.open,popupRef:q,position:M,onClose:function(){O(null),V(function(n){return e.__assign(e.__assign({},n),{open:!1})})},sectionTitle:N.sectionTitle,referenceSectionTitle:N.refSectionTitle,cognitiveData:N.cognitiveData,anchorEl:N.anchorEl,sectionAnchorEl:N.sectionAnchorEl,scrollContainerEl:K.current,badgeStyle:N.badgeStyle}),n.jsx(t.Snackbar,e.__assign({open:!!I,autoHideDuration:8e3,onClose:function(){return z(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return z(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:I}))})),he.length>1&&n.jsxs(t.Box,e.__assign({sx:{px:3,pb:.25},ref:L},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[n.jsx(t.IconButton,e.__assign({onClick:function(){return pe("left")},size:"small",disabled:!Me},{children:n.jsx(o.ArrowLeft,{size:18})})),n.jsx(t.IconButton,e.__assign({onClick:function(){return pe("right")},size:"small",disabled:!Pe},{children:n.jsx(o.ArrowRight,{size:18})}))]}))]})),n.jsx(t.Box,e.__assign({ref:U,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"}}},{children:he.map(function(e){return n.jsx(F,{data:e,isSelected:(null==fe?void 0:fe.id)===e.id,isCognitiveOpen:se,onToggleCognitive:function(){return le(function(e){return!e})},onClick:function(){return oe((n=e).id),k(n),void le(!1);var n}},e.id)})}))]})),n.jsx(t.Box,e.__assign({ref:K,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:Be&&je&&se?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:n.jsxs(t.Box,e.__assign({ref:De,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[We&&n.jsxs("g",{children:[n.jsx("line",{x1:We.x1,y1:We.y,x2:Math.max(We.x1,(We.x1+We.x2)/2-70),y2:We.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(We.x2,(We.x1+We.x2)/2+70),y1:We.y,x2:We.x2,y2:We.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Te.map(function(i,r){var s=(i.x1+i.x2)/2;return"Not Defined"!==i.style.label||i.hasCognitive?n.jsxs("g",{children:[n.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder,strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-75,y:i.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,n.jsxs(t.Box,e.__assign({onClick:function(n){if(n.stopPropagation(),N.open&&N.sectionIdx===i.sectionIdx)return O(null),void V(function(n){return e.__assign(e.__assign({},n),{open:!1})});!function(e,n,i,t,o){var r,s;e.stopPropagation(),O(null);var l=g(n.id)||g(i.id)||"",a=(l?W[l]:null)||n.cognitiveData||i.cognitiveData||null,c=null!==(s=null===(r=Se.current[t])||void 0===r?void 0:r.current)&&void 0!==s?s:null;V({open:!0,sectionTitle:n.title||"Section",refSectionTitle:i.title||"Reference Section",cognitiveData:a,anchorEl:e.currentTarget,sectionAnchorEl:c,badgeStyle:o||null,sectionIdx:t})}(n,be[i.sectionIdx]||{title:"",content:""},ye[i.sectionIdx]||{title:"",content:""},i.sectionIdx,i.style)},sx:{display:"inline-flex",alignItems:"center",gap:"2px",cursor:"pointer",verticalAlign:"middle"}},{children:[i.hasCognitive&&void 0!==i.sectionIdx&&n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",color:i.style.badgeText}},{children:n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(l.ButtonCognitiveIcon,{})}))})),N.open&&N.sectionIdx===i.sectionIdx?n.jsx(o.ChevronUp,{size:12,color:i.style.badgeText}):n.jsx(o.ChevronDown,{size:12,color:i.style.badgeText})]}))]}))}))}))]},r):null})]})),n.jsxs(t.Box,e.__assign({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:ke,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:me}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Ve.map(function(e){var i=e.key,t=e.label,o=e.analysisKey,r=Xe(o),s=Z[i],l=ve[i];if(!j(s)&&!j(l))return null;var a=f(r.score,r.relation,r.hasContent,$);return a?n.jsx(m,{ref:Ue.current[i],label:t,content:s,highlights:r.highlightsA,styleVariant:a,isHighlighted:ce===o||ce===i},"left-".concat(i)):null}),Fe&&be.map(function(e,n){return{section:e,idx:n}}).map(function(i){var o=i.section,r=i.idx;return n.jsx(t.Box,e.__assign({ref:Ce(r)},{children:Ze(o,r,"left",Ge.current[r]||d.default.createRef())}),"left-row-".concat(r))})]}))]})),n.jsx(t.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),Ee,"% Similarity",n.jsx(o.ChevronDown,{size:11})]}))}))})),n.jsxs(t.Box,e.__assign({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:Ae,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:_e}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Ve.map(function(e){var i=e.key,t=e.label,o=e.analysisKey,r=Xe(o),s=Z[i],l=ve[i];if(!j(s)&&!j(l))return null;var a=f(r.score,r.relation,r.hasContent,$);return a?n.jsx(m,{ref:Ke.current[i],label:t,content:l,highlights:r.highlightsB,styleVariant:a,isHighlighted:ce===o||ce===i},"right-".concat(i)):null}),Fe&&ye.map(function(e,n){return{section:e,idx:n}}).map(function(e){var n=e.section,i=e.idx;return Ze(n,i,"right",Ye.current[i]||d.default.createRef())})]}))]}))]}))}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("react-markdown"),s=require("./CognitiveComparehelpers.js"),a=require("./CognitiveCompareConfig.js"),c=require("./CognitivePopup.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=u(i),g=u(l),h={id:"",title:""};exports.SHARED_MARKDOWN_STYLES=a.SHARED_MARKDOWN_STYLES,exports.default=function(l){var u,v,x,f,p,_,m,y,F=l.componentHeaderText,S=void 0===F?"Learning Comparison":F,E=l.treeData,b=l.comparisonConfig,w=l.leftColumnTitleText,C=l.rightColumnTitleText,j=l.markdownStyles,R=i.useState(null),A=R[0],D=R[1],I=i.useMemo(function(){return(null==E?void 0:E.cognitive_decisioning)||{}},[E]);i.useRef(null);var B=i.useState(null),T=B[0],M=B[1],O=i.useRef(null),k=i.useState({width:0,height:0}),N=k[0],L=k[1],z=i.useMemo(function(){return e.__assign(e.__assign({},a.SHARED_MARKDOWN_STYLES),j)},[j]),H=i.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null}),W=H[0],P=H[1],q=i.useRef(null),U=i.useRef(null),G=i.useRef(!1),V=i.useRef(null);i.useEffect(function(){V.current=null},[W.sectionIdx,W.open]);var K=i.useCallback(function(){var e;if(W.anchorEl&&W.refSectionTitle){var n=W.anchorEl.getBoundingClientRect(),i=(null===(e=null==O?void 0:O.current)||void 0===e?void 0:e.offsetHeight)||0,t=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-12,r=n.top-12-12,l=o<i&&r>o;null!==V.current?!0===V.current&&(l=r>=i||r>=o):l=!(o>=i||o>=r),V.current=l;var s=l?r:o,a=Math.min(i||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-t/2,g=Math.max(12,Math.min(d,window.innerWidth-t-12)),h=Math.max(14,Math.min(u-g,t-10-4));M({top:c,left:g,arrowLeft:h,openAbove:l,maxHeight:s})}},[W.anchorEl,W.refSectionTitle]);i.useEffect(function(){if(W.open){window.addEventListener("resize",K);var e=requestAnimationFrame(K),n=null;return O.current&&(n=new ResizeObserver(function(){e=requestAnimationFrame(K)})).observe(O.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",K),n&&n.disconnect()}}},[W.open,K]),i.useEffect(function(){var n=q.current;if(n&&W.open){var i=function(n){O.current&&O.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),M(null),P(function(n){return e.__assign(e.__assign({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})}))};return n.addEventListener("scroll",i,{capture:!0}),window.addEventListener("scroll",i,{capture:!0}),function(){n.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("scroll",i,{capture:!0})}}},[W.open]);var Y=i.useMemo(function(){var n,i,t,o,r,l,s,c,u,d,g,h;return{fields:null!==(n=null==b?void 0:b.fields)&&void 0!==n?n:a.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(i=null==b?void 0:b.thresholds)||void 0===i?void 0:i.high)&&void 0!==t?t:a.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(r=null===(o=null==b?void 0:b.thresholds)||void 0===o?void 0:o.medium)&&void 0!==r?r:a.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==b?void 0:b.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:a.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(c=null==b?void 0:b.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==b?void 0:b.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==b?void 0:b.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(g=null==b?void 0:b.relationStyles)||void 0===g?void 0:g.medium)||{}),low:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(h=null==b?void 0:b.relationStyles)||void 0===h?void 0:h.low)||{})}}},[b]),J=i.useMemo(function(){if(E&&Object.keys(E).length>0)try{var n=function(n){var i,t,o,r,l=[],a=[],c=n.base_root_id,u=n.input_index_map||{0:"left",1:"right"},d=n[c];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var g=function(i){var t=n[i];if(t&&!1!==t.display_node){var o=s.getRationale(t),r=s.getSideData(t,"0",u),c=s.getSideData(t,"1",u),d=r.title.trim()||r.content.trim(),h=c.title.trim()||c.content.trim();l.push(e.__assign({id:i,title:d?r.title:"",content:d?r.content:"",subsections:[]},d?o:{score:void 0,relation:"not_defined"})),a.push(e.__assign({id:i,title:h?c.title:"",content:h?c.content:"",subsections:[]},h?o:{score:void 0,relation:"not_defined"})),t.next&&Object.values(t.next).forEach(g)}};return d.next&&Object.values(d.next).forEach(g),{activeProposed:{title:(null===(t=null===(i=d.comparison_inputs)||void 0===i?void 0:i[u[0]])||void 0===t?void 0:t.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:l},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(o=d.comparison_inputs)||void 0===o?void 0:o[u[1]])||void 0===r?void 0:r.title)||"Reference Template",similarity:0,sections:a,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}}(E);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[E]),Q=J.activeProposed,X=J.activeVariants,Z=J.parseError;i.useEffect(function(){Z&&D("Failed to load comparison: ".concat(Z))},[Z]);var $=i.useState(null),ee=$[0];$[1];var ne=i.useState({}),ie=ne[0],te=ne[1],oe=X[0]||h,re=null===(x=null===(u=null==E?void 0:E.documents)||void 0===u?void 0:u[null===(v=null==E?void 0:E.input_index_map)||void 0===v?void 0:v[0]])||void 0===x?void 0:x.title,le=null===(_=null===(f=null==E?void 0:E.documents)||void 0===f?void 0:f[null===(p=null==E?void 0:E.input_index_map)||void 0===p?void 0:p[1]])||void 0===_?void 0:_.title,se=s.safeStringify(w||re||"Uploaded Contract"),ae=s.safeStringify(C||le||"Reference Template"),ce=i.useMemo(function(){return Q.sections||[]},[Q.sections]),ue=i.useMemo(function(){return oe.sections||[]},[oe.sections]),de=ce.length>0||ue.length>0,ge=oe.analysis,he=s.safeStringify(null===(y=null===(m=null==ge?void 0:ge.rule_difference_comparison)||void 0===m?void 0:m.summary)||void 0===y?void 0:y.overall_summary),ve=!!he.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),xe=i.useRef({}),fe=function(e){return xe.current[e]||(xe.current[e]=d.default.createRef()),xe.current[e]},pe=i.useRef(null),_e=i.useRef(null),me=i.useRef(null),ye=i.useState([]),Fe=ye[0],Se=ye[1],Ee=i.useState(null),be=Ee[0],we=Ee[1],Ce=i.useMemo(function(){return Y.fields.filter(function(e){var n=e.key;return(!de||"description"!==n)&&(s.hasValue(Q[n])||s.hasValue(oe[n]))})},[Q,oe,de,Y.fields]),je=i.useRef({}),Re=i.useRef({}),Ae=i.useRef({}),De=i.useRef({});Ce.forEach(function(e){var n=e.key;je.current[n]||(je.current[n]=d.default.createRef()),Re.current[n]||(Re.current[n]=d.default.createRef())});for(var Ie=0;Ie<Math.max(ce.length,ue.length);Ie+=1)Ae.current[Ie]||(Ae.current[Ie]=d.default.createRef()),De.current[Ie]||(De.current[Ie]=d.default.createRef());i.useEffect(function(){if(ee){var e=Y.fields.find(function(e){return e.analysisKey===ee||e.key===ee});if(e){var n=je.current[e.key]||Re.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ee,Y.fields]);var Be=i.useCallback(function(e){var n,i,t,o,r,l,s,a,c,u=null===(n=null==ge?void 0:ge.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],g=(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 h=d.mappings[0]||{};return{score:d.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=h.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!g}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!g}},[ge]),Te=i.useCallback(function(n){var i,t,o=ce[n],r=ue[n],l=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,a=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,c=!(!(null==o?void 0:o.cognitiveData)&&!(null==r?void 0:r.cognitiveData));if(!l&&!a&&!c)return e.__assign(e.__assign({},Y.relationStyles.noContent),{label:"Not Defined"});var u=Be("description");if(null!=(null!==(i=null==o?void 0:o.cognitiveRelevanceScore)&&void 0!==i?i:null==r?void 0:r.cognitiveRelevanceScore)){var d=s.cognitiveScoreToRelation(),g=d.score,h=d.relation;return s.getStyleForRelation(g,h,!0,Y)}var v=l?o.relation:a?r.relation:u.relation,x=null!==(t=null==o?void 0:o.score)&&void 0!==t?t:null==r?void 0:r.score,f="number"==typeof x?x:u.score;return s.getStyleForRelation(f,v,!0,Y)},[ce,ue,Y,Be]),Me=i.useCallback(function(){var e,n,i,t,o,r,l,a,c,u,d;if(!G.current){G.current=!0;try{if(!pe.current)return;var g=pe.current.getBoundingClientRect();L({width:g.width,height:g.height});var h=[];Ce.forEach(function(e){var n,i,t=e.key,o=null===(n=je.current[t])||void 0===n?void 0:n.current,r=null===(i=Re.current[t])||void 0===i?void 0:i.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")});for(var v=0;v<Math.min(ce.length,ue.length);v++){var x=null===(e=Ae.current[v])||void 0===e?void 0:e.current,f=null===(n=De.current[v])||void 0===n?void 0:n.current;x&&f&&(x.style.height="auto",f.style.height="auto",x.style.minHeight="0px",f.style.minHeight="0px")}var p={};Ce.forEach(function(e){var n,i,t=e.key,o=null===(n=je.current[t])||void 0===n?void 0:n.current,r=null===(i=Re.current[t])||void 0===i?void 0:i.current;if(o&&r){var l=o.getBoundingClientRect(),s=r.getBoundingClientRect();p[t]=Math.max(l.height,s.height)}});var _=[];for(v=0;v<Math.min(ce.length,ue.length);v++){x=null===(i=Ae.current[v])||void 0===i?void 0:i.current,f=null===(t=De.current[v])||void 0===t?void 0:t.current;if(x&&f){var m=x.getBoundingClientRect(),y=f.getBoundingClientRect();_[v]=Math.max(m.height,y.height)}}Ce.forEach(function(e){var n,i,t=e.key,o=null===(n=je.current[t])||void 0===n?void 0:n.current,r=null===(i=Re.current[t])||void 0===i?void 0:i.current;if(o&&r){var l=p[t];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}});for(v=0;v<_.length;v++){x=null===(o=Ae.current[v])||void 0===o?void 0:o.current,f=null===(r=De.current[v])||void 0===r?void 0:r.current;if(x&&f){var F=_[v];x.style.minHeight="".concat(F,"px"),f.style.minHeight="".concat(F,"px")}}Ce.forEach(function(e){var n,i,t=e.key,o=e.analysisKey,r=null===(n=je.current[t])||void 0===n?void 0:n.current,l=null===(i=Re.current[t])||void 0===i?void 0:i.current;if(r&&l){var a=r.getBoundingClientRect(),c=l.getBoundingClientRect(),u=Be(o),d=s.getStyleForRelation(u.score,u.relation,u.hasContent,Y);if(!d)return;var v=a.top+a.height/2-g.top;h.push({id:"field-".concat(t),x1:a.right-g.left,y1:v,x2:c.left-g.left,y2:v,style:d})}});for(v=0;v<Math.min(ce.length,ue.length);v++){var S=null===(l=Ae.current[v])||void 0===l?void 0:l.current,E=null===(a=De.current[v])||void 0===a?void 0:a.current;if(S&&E){var b=S.querySelector(".MuiAccordionSummary-root"),w=E.querySelector(".MuiAccordionSummary-root");if(b&&w){var C=b.getBoundingClientRect(),j=w.getBoundingClientRect(),R=(C.top+C.height/2-g.top+j.top+j.height/2-g.top)/2,A=(null===(c=ue[v])||void 0===c?void 0:c.id)||"sec-".concat(v),D=Te(v);D&&h.push({id:A,x1:C.right-g.left,y1:R,x2:j.left-g.left,y2:R,style:D,sectionIdx:v,hasCognitive:!(!(null===(u=ce[v])||void 0===u?void 0:u.cognitiveData)&&!(null===(d=ue[v])||void 0===d?void 0:d.cognitiveData))})}}}if(Se(h),_e.current&&me.current){var I=_e.current.getBoundingClientRect(),B=me.current.getBoundingClientRect(),T=(I.top+I.height/2-g.top+B.top+B.height/2-g.top)/2;we({x1:I.right-g.left,x2:B.left-g.left,y:T})}else we(null)}catch(e){console.error("Line render safe fail: ",e)}finally{G.current=!1}}},[Ce,ce,ue,Y,Be,Te]),Oe=i.useCallback(function(){window.requestAnimationFrame(Me)},[Me]);i.useEffect(function(){var e=setTimeout(Oe,250);window.addEventListener("resize",Oe);var n=null,i=null;return q.current&&(n=new ResizeObserver(Oe)).observe(q.current),pe.current&&(i=new ResizeObserver(Oe)).observe(pe.current),function(){clearTimeout(e),window.removeEventListener("resize",Oe),null==n||n.disconnect(),null==i||i.disconnect()}},[Q,oe,ge,Ce,ie,ce,ue,Y,Oe]);var ke=function(i,r,l,a){var c,u=!s.hasValue(i.title)&&!s.hasValue(i.content);return n.jsx(t.Box,e.__assign({ref:a,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!u&&!!ie[r],onChange:function(){return!u&&(n=r,void te(function(i){var t;return e.__assign(e.__assign({},i),((t={})[n]=!i[n],t))}));var n},sx:{boxShadow:"none",border:u?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:u?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:u?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:u?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(t.Tooltip,e.__assign({title:i.title||"No Matching Section Found",placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:u?"#94A3B8":"#19213D",fontWeight:u?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(c=i.title||"No Matching Section Found",c?s.safeStringify(c).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(d.default.Fragment,{children:e},i)}):null)}))}))})),!u&&n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(t.Typography,e.__assign({component:"div",sx:z},{children:n.jsx(g.default,{children:s.safeStringify(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(i,o){return n.jsx(t.Box,e.__assign({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:z},{children:n.jsx(g.default,{children:s.safeStringify(i).replace(/\\n/g,"\n")})}))}),"".concat(l,"-sub-").concat(r,"-").concat(o))})]}))]}))}),"".concat(l,"-sec-").concat(r))};return n.jsxs(t.Box,e.__assign({ref:U,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[W.open&&n.jsx(c.default,{open:W.open,popupRef:O,position:T,onClose:function(){M(null),P(function(n){return e.__assign(e.__assign({},n),{open:!1})})},markdownStyles:j,sectionTitle:W.sectionTitle,referenceSectionTitle:W.refSectionTitle,cognitiveData:W.cognitiveData,anchorEl:W.anchorEl,sectionAnchorEl:W.sectionAnchorEl,scrollContainerEl:q.current,badgeStyle:W.badgeStyle}),n.jsx(t.Snackbar,e.__assign({open:!!A,autoHideDuration:8e3,onClose:function(){return D(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return D(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:A}))})),n.jsx(t.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:S}))}))})),n.jsx(t.Box,e.__assign({ref:q,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:he&&ve?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:n.jsxs(t.Box,e.__assign({ref:pe,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0}},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:N.width||"100%",height:N.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[be&&n.jsxs("g",{children:[n.jsx("line",{x1:be.x1,y1:be.y,x2:Math.max(be.x1,(be.x1+be.x2)/2-70),y2:be.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(be.x2,(be.x1+be.x2)/2+70),y1:be.y,x2:be.x2,y2:be.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Fe.map(function(i,l){var a=(i.x1+i.x2)/2;return"Not Defined"!==i.style.label||i.hasCognitive?n.jsxs("g",{children:[n.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder,strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:a-75,y:i.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,n.jsxs(t.Box,e.__assign({onClick:function(n){if(n.stopPropagation(),W.open&&W.sectionIdx===i.sectionIdx)return M(null),void P(function(n){return e.__assign(e.__assign({},n),{open:!1})});!function(e,n,i,t,o){var r,l;e.stopPropagation(),M(null);var a=s.safeStringify(n.id)||s.safeStringify(i.id)||"",c=(a?I[a]:null)||n.cognitiveData||i.cognitiveData||null,u=null!==(l=null===(r=xe.current[t])||void 0===r?void 0:r.current)&&void 0!==l?l:null;P({open:!0,sectionTitle:n.title||"N/A",refSectionTitle:i.title||"NA",cognitiveData:c,anchorEl:e.currentTarget,sectionAnchorEl:u,badgeStyle:o||null,sectionIdx:t})}(n,ce[i.sectionIdx]||{title:"",content:""},ue[i.sectionIdx]||{title:"",content:""},i.sectionIdx,i.style)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",cursor:"pointer",verticalAlign:"middle"}},{children:[i.hasCognitive&&void 0!==i.sectionIdx&&n.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",color:i.style.badgeText}},{children:n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:n.jsx(r.ButtonCognitiveIcon,{})}))})),W.open&&W.sectionIdx===i.sectionIdx?n.jsx(o.ChevronUp,{size:12,color:i.style.badgeText}):n.jsx(o.ChevronDown,{size:12,color:i.style.badgeText})]}))]}))}))}))]},l):null})]})),n.jsxs(t.Box,e.__assign({sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:_e,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center",overflow:"hidden"}},{children:n.jsx(t.Tooltip,e.__assign({title:se,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},{children:se}))}))})),n.jsx(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:de&&ce.map(function(e,n){return{section:e,idx:n}}).map(function(i){var o=i.section,r=i.idx;return n.jsx(t.Box,e.__assign({ref:fe(r)},{children:ke(o,r,"left",Ae.current[r]||d.default.createRef())}),"left-row-".concat(r))})}))]})),n.jsx(t.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(o.ChevronDown,{size:11})]}))}))})),n.jsxs(t.Box,e.__assign({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[n.jsx(t.Box,e.__assign({ref:me,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center",overflow:"hidden"}},{children:n.jsx(t.Tooltip,e.__assign({title:ae,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},{children:ae}))}))})),n.jsx(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:de&&ue.map(function(e,n){return{section:e,idx:n}}).map(function(e){var n=e.section,i=e.idx;return ke(n,i,"right",De.current[i]||d.default.createRef())})}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],F={fields:e,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}};exports.DEFAULT_COMPARISON_CONFIG=F,exports.DEFAULT_FIELD_CONFIG=e,exports.SHARED_MARKDOWN_STYLES={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul":{mt:0,mb:1.5,pl:2.5,listStyleType:"disc"},"& ol":{mt:0,mb:1.5,pl:2.5,listStyleType:"decimal"},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}};
2
+ //# sourceMappingURL=CognitiveCompareConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveCompareConfig.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(n).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},i=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return i(e)}))},t=function(e){return e&&"string"==typeof e?"N/A"===e.toUpperCase()?"N/A":e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"};exports.cognitiveScoreToRelation=function(e){return{score:0,relation:"N/A"}},exports.formatRelationToLabel=t,exports.getRationale=function(e){if(!e.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0},score:0,relation:"N/A"};var n=e.mapping_rationale,i=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:i},score:0,relation:"N/A"}},exports.getSideData=function(e,i,t){var r,o=t[i],s=null===(r=null==e?void 0:e.comparison_inputs)||void 0===r?void 0:r[o];return{title:n((null==s?void 0:s.title)||""),content:n((null==s?void 0:s.content)||"")}},exports.getStyleForRelation=function(n,i,r,o){var s=100*(n||0),a=o.thresholds,l=o.relationStyles;if(!r)return null;var c=t(i),g=(i||"").toLowerCase();return"n/a"===g||g.includes("no_deviation")?e.__assign(e.__assign({},l.low),{label:c}):g.includes("deviation")||g.includes("high_risk")||g.includes("critical")?e.__assign(e.__assign({},l.high),{label:c}):s>=a.exact?e.__assign(e.__assign({},l.exact),{label:c}):s>=a.high?e.__assign(e.__assign({},l.high),{label:c}):s>=a.medium?e.__assign(e.__assign({},l.medium),{label:c}):e.__assign(e.__assign({},l.low),{label:c})},exports.hasValue=i,exports.safeStringify=n;
2
+ //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveComparehelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),i=require("react"),n=require("@mui/material"),r=require("lucide-react"),s=require("react-dom"),t=require("../../assests/svg/SparkleIcon.js"),a=require("react-markdown"),l=require("./CognitiveCompareConfig.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=x(s),c=x(a),p=10;exports.default=function(s){var a,x,h,g,f,u=s.open,b=s.onClose,_=s.sectionTitle,v=s.referenceSectionTitle,m=s.cognitiveData,y=s.relevanceScore,j=s.anchorEl,F=s.badgeStyle,w=s.popupRef,B=s.position,E=s.markdownStyles,D=e.__assign(e.__assign({},l.SHARED_MARKDOWN_STYLES),E),S=null==m?void 0:m.isMissingRationale,C=i.useState(S?"deviation":"association"),k=C[0],R=C[1];i.useEffect(function(){u&&R(S?"deviation":"association")},[u,S]);var W=i.useMemo(function(){if(!F)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=F.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[F]);if(i.useEffect(function(){if(u){var e=function(e){var o;(null===(o=w.current)||void 0===o?void 0:o.contains(e.target))||(null==j?void 0:j.contains(e.target))||b()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[u,b,j,w]),!u||!m)return null;var z=null!==(x=null!==(a=m.relevance_score)&&void 0!==a?a:y)&&void 0!==x?x:0,T=m.decisioning,A=Array.isArray(T)?T:"string"==typeof T&&T.trim()?[T]:[],I=m.gap,H=Array.isArray(I)?I:"string"==typeof I&&I.trim()?[I]:[],q=null!==(h=null==B?void 0:B.arrowLeft)&&void 0!==h?h:60,L=o.jsxs(n.Box,e.__assign({ref:w,sx:{position:"fixed",top:null!==(g=null==B?void 0:B.top)&&void 0!==g?g:-9999,left:null!==(f=null==B?void 0:B.left)&&void 0!==f?f:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(W.border),boxShadow:"0px 8px 32px ".concat(W.shadow,", 0px 0px 0px 3px ").concat(W.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==B?void 0:B.maxHeight)?"min(60vh, ".concat(B.maxHeight,"px)"):"60vh",visibility:B?"visible":"hidden"}},{children:[B&&(B.openAbove?o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",bottom:-11,left:q-p,width:0,height:0,borderLeft:"".concat(p,"px solid transparent"),borderRight:"".concat(p,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(W.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",bottom:-9,left:q-p+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(p,"px solid #FFFFFF"),zIndex:2}})]}):o.jsxs(o.Fragment,{children:[o.jsx(n.Box,{sx:{position:"absolute",top:-11,left:q-p,width:0,height:0,borderLeft:"".concat(p,"px solid transparent"),borderRight:"".concat(p,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(W.border),zIndex:1}}),o.jsx(n.Box,{sx:{position:"absolute",top:-9,left:q-p+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(p,"px solid #FFFFFF"),zIndex:2}})]})),o.jsxs(n.Box,e.__assign({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[o.jsxs(n.Box,e.__assign({sx:{flex:1,minWidth:0}},{children:[o.jsxs(n.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[o.jsx(n.Box,e.__assign({component:"span",title:_,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:_})),o.jsx(n.Box,e.__assign({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),o.jsx(n.Box,e.__assign({component:"span",title:v||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:v||"Reference Section"}))]})),o.jsx(n.Box,e.__assign({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:o.jsx(n.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"deviation"===k?"Why this is a deviation?":"Why these sections are paired?"}))}))]})),o.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[o.jsxs(n.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[o.jsx(t.default,{}),"Decision Strength ",z,"%"]})),o.jsx(n.IconButton,e.__assign({onClick:b,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:o.jsx(r.X,{size:22})}))]}))]})),o.jsx(n.Box,e.__assign({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:(S?["deviation"]:["deviation","association"]).map(function(i){var r=k===i,s="deviation"===i?"Deviation Analysis":"Association Logic";return o.jsx(n.Box,e.__assign({onClick:function(){return R(i)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:r?600:400,color:r?"#5928ED":"#667085",backgroundColor:r?"rgba(89,40,237,0.08)":"transparent",borderBottom:r?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:s}),i)})})),o.jsx(n.Box,e.__assign({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(W.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:W.border},scrollbarWidth:"thin",scrollbarColor:"".concat(W.border,"55 transparent")}},{children:"deviation"===k?o.jsxs(n.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[o.jsx(n.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),o.jsx(n.Typography,e.__assign({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):o.jsxs(o.Fragment,{children:[A.length>0&&o.jsxs(n.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[o.jsx(n.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:o.jsx(n.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),o.jsx(n.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:o.jsx(n.Box,e.__assign({sx:{display:"flex",flexDirection:"column"}},{children:o.jsx(n.Typography,e.__assign({component:"div",sx:e.__assign({},D)},{children:o.jsx(c.default,{children:A.join("\n\n")})}))}))}))]})),H.length>0&&o.jsxs(n.Box,e.__assign({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[o.jsx(n.Box,e.__assign({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:o.jsx(n.Typography,e.__assign({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),o.jsx(n.Box,e.__assign({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:o.jsx(n.Box,e.__assign({sx:{display:"flex",flexDirection:"column"}},{children:o.jsx(n.Typography,e.__assign({component:"div",sx:e.__assign({},D)},{children:o.jsx(c.default,{children:H.join("\n\n")})}))}))}))]})),0===A.length&&0===H.length&&o.jsx(n.Box,e.__assign({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:o.jsx(n.Typography,e.__assign({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return d.default.createPortal(L,document.body)};
2
+ //# sourceMappingURL=CognitivePopup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitivePopup.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),s=require("react"),i=require("lucide-react"),t=require("./CognitiveNonWebSearchReasoning.module.css.js"),a=function(s){return s.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(s,i){return s.startsWith("**")&&s.endsWith("**")||s.startsWith("__")&&s.endsWith("__")?n.jsx("strong",e.__assign({className:t.default.boldText},{children:s.slice(2,-2)}),i):s})};exports.default=function(l){var r=l.item,c=l.headerTitle;l.index;var o=l.iconsConfig,d=l.DocumentTitle,u=l.previewCallback,h=l.bodyHeight,f=l.disableMaximize,g=void 0!==f&&f,m=r.dataSource,_=r.confidence_score,x=r.trainingDataTitle,v=null==o?void 0:o.ChevronDownIcon,j=null==o?void 0:o.ChevronUpIcon,p=null==o?void 0:o.MaximizeIcon,N=null==o?void 0:o.CloseIcon,b=s.useMemo(function(){var n=(m?m.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),s=0,i=n.map(function(e){var n=e.startsWith("<highlight>"),i={text:n?e.replace(/<\/?highlight>/g,""):e,isHighlight:n,highlightIndex:n?s:-1};return n&&s++,i}),t=i.filter(function(e){return e.isHighlight}).length,a=[],l=[];return i.forEach(function(n){var s=n.text,i=n.isHighlight,t=n.highlightIndex;s.split("\n").forEach(function(n,s){s>0&&((l.length>0||a.length>0)&&a.push(e.__spreadArray([],l,!0)),l=[]),n&&l.push({text:n,isHighlight:i,highlightIndex:t})})}),l.length>0&&a.push(e.__spreadArray([],l,!0)),{processedLines:a.map(function(e){var n=e.map(function(e){return e.text}).join(""),s=n.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:e,isListItem:!!s,isHeader:!!n.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==s?void 0:s[1])||"",content:(null==s?void 0:s[3])||n}}),totalHighlights:t}},[m]),C=b.processedLines,I=b.totalHighlights,H=s.useState(0),k=H[0],T=H[1],L=s.useRef(null),y=s.useRef(null),S=s.useRef(null),w=s.useRef([]),B=s.useRef([]);s.useEffect(function(){w.current=w.current.slice(0,I),B.current=B.current.slice(0,I)},[I]),s.useEffect(function(){if(I>0){T(0);var e=setTimeout(function(){var e;null===(e=w.current[0])||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(e)}}},[I]);var z=function(e,n){setTimeout(function(){var s=n?B.current[e]:w.current[e];null==s||s.scrollIntoView({behavior:"smooth",block:"center"})},50)},A=function(s){var i=s?B:w,l=0;return C.map(function(s,r){s.isHeader&&(l=0),s.isListItem&&(l+=1);var c=function(){return s.segments.map(function(l,r){var c=l.isHighlight&&l.highlightIndex===k,o=l.text;return s.isListItem&&0===r&&(o=l.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),l.isHighlight?n.jsx("span",e.__assign({ref:function(e){e&&(i.current[l.highlightIndex]=e)},className:"".concat(t.default.highlight).concat(c?" ".concat(t.default.highlightActive):"")},{children:a(o)}),r):n.jsx("span",{children:a(o)},r)})};return s.isHeader?n.jsx("span",e.__assign({className:t.default.headerLine},{children:c()}),r):s.isListItem?n.jsxs("span",e.__assign({className:t.default.listItemLine,style:{paddingLeft:s.indent?"1rem":"0"}},{children:[n.jsxs("span",e.__assign({className:t.default.listCounter},{children:[l,"."]})),n.jsx("span",{children:c()})]}),r):n.jsx("span",e.__assign({className:t.default.blockLine},{children:c()}),r)})},D=function(s){return I>1?n.jsxs("div",e.__assign({className:s?t.default.modalNavContainer:t.default.navigationContainer},{children:[j&&n.jsx("button",e.__assign({onClick:function(){return function(e){if(void 0===e&&(e=!1),I){var n=k>0?k-1:I-1;T(n),z(n,e)}}(s)},className:s?t.default.modalNavButton:t.default.navButton},{children:n.jsx(j,{className:t.default.navIcon})})),n.jsxs("span",e.__assign({className:t.default.navCounter},{children:[k+1,"/",I]})),v&&n.jsx("button",e.__assign({onClick:function(){return function(e){if(void 0===e&&(e=!1),I){var n=k<I-1?k+1:0;T(n),z(n,e)}}(s)},className:s?t.default.modalNavButton:t.default.navButton},{children:n.jsx(v,{className:t.default.navIcon})}))]})):null},E=null!=_?n.jsxs("span",e.__assign({className:t.default.confidenceBadge},{children:[n.jsx("span",e.__assign({className:t.default.confidenceStar},{children:"✦"})),n.jsxs("span",e.__assign({className:t.default.confidenceScore},{children:[_,"%"]}))]})):null,R=n.jsxs(n.Fragment,{children:[x&&n.jsx("div",e.__assign({className:t.default.footer},{children:n.jsx("span",e.__assign({className:t.default.trainingTitle},{children:x}))})),d&&n.jsx("div",e.__assign({className:t.default.modalFooterSource},{children:n.jsxs("button",e.__assign({type:"button",onClick:function(){return null==u?void 0:u()},className:t.default.trainingTitleLink},{children:[d,n.jsx(i.ExternalLink,{size:16,color:"#2563eb"})]}))}))]});return n.jsxs(n.Fragment,{children:[n.jsxs("div",e.__assign({className:t.default.expandedContainer,style:h?{height:"".concat(h),display:"flex",flexDirection:"column"}:void 0},{children:[n.jsxs("div",e.__assign({className:t.default.expandedHeader},{children:[n.jsx("span",e.__assign({className:t.default.headerTitle},{children:c})),n.jsxs("div",e.__assign({className:t.default.headerActions},{children:[D(!1),E,!g&&p&&n.jsx("button",e.__assign({onClick:function(){var e;return null===(e=S.current)||void 0===e?void 0:e.showModal()},className:t.default.maximizeButton,title:"View fullscreen"},{children:n.jsx(p,{className:t.default.maximizeIcon})}))]}))]})),n.jsx("div",e.__assign({ref:L,className:t.default.contentArea,style:h?{flex:1,maxHeight:"none",overflowY:"auto",minHeight:0}:void 0},{children:n.jsx("div",e.__assign({className:t.default.contentInner},{children:A(!1)}))})),R]})),!g&&n.jsx("dialog",e.__assign({ref:S,className:t.default.modalDialog,onClick:function(e){var n;e.target===S.current&&(null===(n=S.current)||void 0===n||n.close())}},{children:n.jsxs("div",e.__assign({className:t.default.modalContainer},{children:[n.jsxs("div",e.__assign({className:t.default.modalHeader},{children:[n.jsx("span",e.__assign({className:t.default.modalHeaderTitle},{children:c})),n.jsxs("div",e.__assign({className:t.default.modalHeaderActions},{children:[D(!0),E,N&&n.jsx("button",e.__assign({onClick:function(){var e;return null===(e=S.current)||void 0===e?void 0:e.close()},className:t.default.closeButton,title:"Close"},{children:n.jsx(N,{className:t.default.closeIcon})}))]}))]})),n.jsx("div",e.__assign({ref:y,className:t.default.modalContent},{children:n.jsx("div",e.__assign({className:t.default.modalContentInner},{children:A(!0)}))})),x&&n.jsx("div",e.__assign({className:t.default.modalFooter},{children:n.jsx("span",e.__assign({className:t.default.trainingTitle},{children:x}))})),d&&n.jsx("div",e.__assign({className:t.default.modalFooterSource},{children:n.jsxs("button",e.__assign({type:"button",onClick:function(){var e;null==u||u(),null===(e=S.current)||void 0===e||e.close()},className:t.default.trainingTitleLink},{children:[d,n.jsx(i.ExternalLink,{size:16,color:"#2563eb"})]}))}))]}))}))]})};
2
+ //# sourceMappingURL=CognitiveInternalgptCoreComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveInternalgptCoreComponent.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i,Fragment as r}from"react/jsx-runtime";import o,{useState as l,useMemo as a,useRef as c,useEffect as s,useCallback as d}from"react";import{Box as u,Typography as p,Skeleton as h,Snackbar as x,Alert as g,IconButton as f,Accordion as v,AccordionSummary as m,AccordionDetails as b}from"@mui/material";import{ChevronDown as y,ArrowLeft as F,ArrowRight as w,ChevronUp as E,X as C}from"lucide-react";import S from"react-dom";import D from"../../assests/svg/SparkleIcon.js";import{ButtonCognitiveIcon as B}from"../../assests/svg/ButtonCognitiveIcon.js";import k from"react-markdown";var A=function(e){return null==e?"":"string"==typeof e?e:Array.isArray(e)?e.map(A).join("\n\n"):"object"==typeof e?JSON.stringify(e):String(e)},R={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul, & ol":{mt:0,mb:1.5,pl:2.5},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"},"& ol":{listStyleType:"decimal"},"& ul":{listStyleType:"disc"}},I=function(e){return e?A(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?i("strong",{children:e.slice(2,-2)},n):i(o.Fragment,{children:e},n)}):null},z=function(n,t,i,r){r.thresholds;var o=r.relationStyles;if(!i)return null;var l=function(e){return e&&"string"==typeof e?e:"Unknown"}(t);return(t||"").toLowerCase().includes("NA"),e(e({},o.low),{label:l})},T=function(n,t,r){if(!n)return null;if(!t||0===t.length)return I(n);var l=t.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===l.length)return I(n);var a=new RegExp("(".concat(l.join("|"),")"),"gi");return n.split(a).map(function(n,l){return t.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===n.toLowerCase()})?i(u,e({component:"span",sx:{bgcolor:r.highlightBg,borderRadius:"2px",px:"2px"}},{children:I(n)}),l):i(o.Fragment,{children:I(n)},l)})},_=o.memo(o.forwardRef(function(n,r){var o=n.label,l=n.content,a=n.highlights,c=void 0===a?[]:a,s=n.styleVariant,d=n.isHighlighted,h=void 0!==d&&d,x=Array.isArray(l)?l.map(A).join("\n"):A(l),g=function(e){return"#9F1239"===e.badgeText?{borderColor:"#E11D48",shadow:"rgba(225, 29, 72, 0.25)"}:"#B91C1C"===e.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#1D4ED8"===e.badgeText?{borderColor:"#3B82F6",shadow:"rgba(59, 130, 246, 0.25)"}:"#A16207"===e.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"}}(s);return t(u,e({sx:{mb:1.5}},{children:[i(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:o})),i(u,e({ref:r,sx:{p:"4px 12px",borderRadius:"6px",border:h?"1.5px solid ".concat(g.borderColor):"1px solid ".concat(s.border),boxShadow:h?"0px 0px 0px 2px ".concat(g.shadow):"none",bgcolor:s.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:i(u,{children:T(x,c,s)})}))]}))})),W=12,L=10,H=function(n){var o,c,d,h,x,g=n.open,v=n.onClose,m=n.sectionTitle,b=n.referenceSectionTitle,y=n.cognitiveData,F=n.relevanceScore,w=n.anchorEl,E=n.badgeStyle,B=n.popupRef,A=n.position,I=l("association"),z=I[0],T=I[1],_=a(function(){if(!E)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=E.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[E]);if(s(function(){if(g){var e=function(e){var n;(null===(n=B.current)||void 0===n?void 0:n.contains(e.target))||(null==w?void 0:w.contains(e.target))||v()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[g,v,w,B]),!g||!y)return null;var W=null!==(c=null!==(o=y.relevance_score)&&void 0!==o?o:F)&&void 0!==c?c:0,H=y.decisioning,M=Array.isArray(H)?H:"string"==typeof H&&H.trim()?[H]:[],j=y.gap,O=Array.isArray(j)?j:"string"==typeof j&&j.trim()?[j]:[],P=null!==(d=null==A?void 0:A.arrowLeft)&&void 0!==d?d:60,V=t(u,e({ref:B,sx:{position:"fixed",top:null!==(h=null==A?void 0:A.top)&&void 0!==h?h:-9999,left:null!==(x=null==A?void 0:A.left)&&void 0!==x?x:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(_.border),boxShadow:"0px 8px 32px ".concat(_.shadow,", 0px 0px 0px 3px ").concat(_.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==A?void 0:A.maxHeight)?"min(60vh, ".concat(A.maxHeight,"px)"):"60vh",visibility:A?"visible":"hidden"}},{children:[A&&(A.openAbove?t(r,{children:[i(u,{sx:{position:"absolute",bottom:-11,left:P-L,width:0,height:0,borderLeft:"".concat(L,"px solid transparent"),borderRight:"".concat(L,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(_.border),zIndex:1}}),i(u,{sx:{position:"absolute",bottom:-9,left:P-L+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(L,"px solid #FFFFFF"),zIndex:2}})]}):t(r,{children:[i(u,{sx:{position:"absolute",top:-11,left:P-L,width:0,height:0,borderLeft:"".concat(L,"px solid transparent"),borderRight:"".concat(L,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(_.border),zIndex:1}}),i(u,{sx:{position:"absolute",top:-9,left:P-L+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(L,"px solid #FFFFFF"),zIndex:2}})]})),t(u,e({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[t(u,e({sx:{flex:1,minWidth:0}},{children:[t(p,e({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[i(u,e({component:"span",title:m,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:m})),i(u,e({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),i(u,e({component:"span",title:b||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:b||"Reference Section"}))]})),i(u,e({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:i(p,e({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"deviation"===z?"Why this is a deviation?":"Why these sections are paired?"}))}))]})),t(u,e({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[i(D,{}),"Decision Strength ",W,"%"]})),i(f,e({onClick:v,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:i(C,{size:22})}))]}))]})),i(u,e({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(n){var t=z===n;return i(u,e({onClick:function(){return T(n)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:t?600:400,color:t?"#5928ED":"#667085",backgroundColor:t?"rgba(89,40,237,0.08)":"transparent",borderBottom:t?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:"deviation"===n?"Deviation Analysis":"Association Logic"}),n)})})),i(u,e({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(_.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:_.border},scrollbarWidth:"thin",scrollbarColor:"".concat(_.border,"55 transparent")}},{children:"deviation"===z?t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),i(p,e({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):t(r,{children:[M.length>0&&t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[i(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),i(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:i(u,e({sx:{display:"flex",flexDirection:"column"}},{children:i(p,e({component:"div",sx:e({},R)},{children:i(k,{children:M.join("\n\n")})}))}))}))]})),O.length>0&&t(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[i(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:i(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),i(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:i(u,e({sx:{display:"flex",flexDirection:"column"}},{children:i(p,e({component:"div",sx:e({},R)},{children:i(k,{children:O.join("\n\n")})}))}))}))]})),0===M.length&&0===O.length&&i(u,e({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:i(p,e({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return S.createPortal(V,document.body)},M=o.memo(function(n){var r=n.data,o=n.isSelected,l=n.isCognitiveOpen,a=n.onToggleCognitive,c=n.onClick,s=A(r.summaryText||r.description),d=s.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),x=d?s.replace(d[0],"").trim():s,g=!!d;return t(u,e({id:"variant-card-".concat(r.id),onClick:c,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:o?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:r.isLoading?.7:1,border:o?"1.4px solid #2563EB":void 0,boxShadow:o?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:o?"#2563EB":"#CBD5E1",boxShadow:o?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:r.isLoading?i(h,{variant:"rounded",width:80,height:20}):t(u,e({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==r.similarity?r.similarity:0,"% Similarity"]}))})),t(u,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:i(p,e({sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:A(r.title)}))})),r.isLoading?t(u,{children:[i(h,{width:"90%"}),i(h,{width:"60%"})]}):t(u,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[i(p,e({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:x})),g&&t(u,e({onClick:function(e){e.stopPropagation(),o||c(),a()},sx:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[i("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:i(B,{})})),i(y,{size:12,style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))}),j=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],O={fields:j,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},P=function(e){return null!=e&&("string"==typeof e?e.trim().length>0:!Array.isArray(e)||e.length>0&&e.some(function(e){return P(e)}))},V=function(e,n,t){var i,r=t[n],o=null===(i=null==e?void 0:e.comparison_inputs)||void 0===i?void 0:i[r];return{title:A((null==o?void 0:o.title)||""),content:A((null==o?void 0:o.content)||"")}},N=function(n){var t,i,r,o,l=[],a=[],c=n.base_root_id,s=n.input_index_map||{0:"left",1:"right"},d=n[c];if(!d||!1===d.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(t){var i=n[t];if(i&&!1!==i.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"NA"};var n=e.mapping_rationale,t=!n.decision_strength,i=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:i},score:t?100:i/100,relation:"NA"}}(i),o=V(i,"0",s),c=V(i,"1",s),d=o.title.trim()||o.content.trim(),p=c.title.trim()||c.content.trim();l.push(e({id:t,title:d?o.title:"",content:d?o.content:"",subsections:[]},d?r:{score:void 0,relation:"not_defined"})),a.push(e({id:t,title:p?c.title:"",content:p?c.content:"",subsections:[]},p?r:{score:void 0,relation:"not_defined"})),i.next&&Object.values(i.next).forEach(u)}};return d.next&&Object.values(d.next).forEach(u),{activeProposed:{title:(null===(i=null===(t=d.comparison_inputs)||void 0===t?void 0:t[s[0]])||void 0===i?void 0:i.title)||"Uploaded Contract",description:d.decision_scope_description||"",sections:l},activeVariants:[{id:"tree-variant-1",title:(null===(o=null===(r=d.comparison_inputs)||void 0===r?void 0:r[s[1]])||void 0===o?void 0:o.title)||"Reference Template",similarity:0,sections:a,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:d.decision_scope_description||""},fields:{}}}}]}},K={id:"",title:""},q=function(r){var h,C,S,D=r.variants,T=void 0===D?[]:D,V=r.treeData,q=r.comparisonConfig,U=r.onSelectVariant,Y=r.targetVariantId,G=r.highlightedField,J=l(null),$=J[0],X=J[1],Q=a(function(){return(null==V?void 0:V.cognitive_decisioning)||{}},[V]),Z=c(null),ee=l(null),ne=ee[0],te=ee[1],ie=c(null),re=l({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null}),oe=re[0],le=re[1],ae=c(null),ce=c(null),se=c(null),de=c(!1),ue=c(null);s(function(){ue.current=null},[oe.sectionIdx,oe.open]);var pe=d(function(){var e;if(oe.anchorEl&&oe.refSectionTitle){var n=oe.anchorEl.getBoundingClientRect(),t=(null===(e=null==ie?void 0:ie.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-W,o=n.top-12-W,l=r<t&&o>r;null!==ue.current?!0===ue.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),ue.current=l;var a=l?o:r,c=Math.min(t||9999,a),s=l?n.top-12-c:n.bottom+12,d=n.left+n.width/2,u=d-i/2,p=Math.max(W,Math.min(u,window.innerWidth-i-W)),h=Math.max(14,Math.min(d-p,i-L-4));te({top:s,left:p,arrowLeft:h,openAbove:l,maxHeight:a})}},[oe.anchorEl,oe.refSectionTitle]);s(function(){if(oe.open){window.addEventListener("resize",pe);var e=requestAnimationFrame(pe),n=null;return ie.current&&(n=new ResizeObserver(function(){e=requestAnimationFrame(pe)})).observe(ie.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",pe),n&&n.disconnect()}}},[oe.open,pe]),s(function(){var n=ce.current;if(n&&oe.open){var t=function(n){ie.current&&ie.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),te(null),le(function(n){return e(e({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})}))};return n.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){n.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[oe.open]);var he=a(function(){var n,t,i,r,o,l,a,c,s,d,u,p;return{fields:null!==(n=null==q?void 0:q.fields)&&void 0!==n?n:j,thresholds:{high:null!==(i=null===(t=null==q?void 0:q.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:O.thresholds.high,medium:null!==(o=null===(r=null==q?void 0:q.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:O.thresholds.medium,exact:null!==(a=null===(l=null==q?void 0:q.thresholds)||void 0===l?void 0:l.exact)&&void 0!==a?a:O.thresholds.exact},relationStyles:{noContent:e(e({},O.relationStyles.noContent),(null===(c=null==q?void 0:q.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e(e({},O.relationStyles.high),(null===(s=null==q?void 0:q.relationStyles)||void 0===s?void 0:s.high)||{}),exact:e(e({},O.relationStyles.exact),(null===(d=null==q?void 0:q.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},O.relationStyles.medium),(null===(u=null==q?void 0:q.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e(e({},O.relationStyles.low),(null===(p=null==q?void 0:q.relationStyles)||void 0===p?void 0:p.low)||{})}}},[q]),xe=a(function(){if(V&&Object.keys(V).length>0)try{var n=N(V);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:T||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:T||[],parseError:null}},[V,T]),ge=xe.activeProposed,fe=xe.activeVariants,ve=xe.parseError;s(function(){ve&&X("Failed to load comparison: ".concat(ve))},[ve]);var me=l(Y||null),be=me[0],ye=me[1],Fe=l(!1),we=Fe[0],Ee=Fe[1],Ce=l(null),Se=Ce[0],De=Ce[1],Be=l({}),ke=Be[0],Ae=Be[1];s(function(){if(Y&&ye(Y),De(null!=G?G:null),G){var e=setTimeout(function(){return De(null)},6e3);return function(){return clearTimeout(e)}}},[Y,G]);var Re=function(e){var n;null===(n=ae.current)||void 0===n||n.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},Ie=a(function(){return n([],fe,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[fe]),ze=a(function(){if(be){var e=String(be).trim();return fe.find(function(n){return n.id&&String(n.id).trim()===e})||Ie[0]}return Ie[0]||null},[be,fe,Ie]);s(function(){be&&ae.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(be.trim())),n=ae.current;if(e&&n){var t=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:t,behavior:"smooth"})}},150)},[be,Ie]);var Te=ze||K,_e=A(ge.title)||"Uploaded Contract",We=A(Te.title)||"Reference Template",Le=a(function(){return ge.sections||[]},[ge.sections]),He=a(function(){return Te.sections||[]},[Te.sections]),Me=Le.length>0||He.length>0,je=null==ze?void 0:ze.analysis,Oe=A(null===(C=null===(h=null==je?void 0:je.rule_difference_comparison)||void 0===h?void 0:h.summary)||void 0===C?void 0:C.overall_summary),Pe=!!Oe.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ve=null!==(S=null==ze?void 0:ze.similarity)&&void 0!==S?S:0,Ne=c({}),Ke=function(e){return Ne.current[e]||(Ne.current[e]=o.createRef()),Ne.current[e]};s(function(){!be&&!Y&&Ie.length>0&&!Ie[0].isLoading&&ye(Ie[0].id)},[Ie,be,Y]);var qe=c(null),Ue=c(null),Ye=c(null),Ge=l([]),Je=Ge[0],$e=Ge[1],Xe=l(null),Qe=Xe[0],Ze=Xe[1],en=l(!1),nn=en[0],tn=en[1],rn=l(!1),on=rn[0],ln=rn[1];s(function(){var e=ae.current;if(e){var n=function(){tn(e.scrollLeft>0),ln(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[Ie]);var an=a(function(){return he.fields.filter(function(e){var n=e.key;return(!Me||"description"!==n)&&(P(ge[n])||P(Te[n]))})},[ge,Te,Me,he.fields]),cn=c({}),sn=c({}),dn=c({}),un=c({});an.forEach(function(e){var n=e.key;cn.current[n]||(cn.current[n]=o.createRef()),sn.current[n]||(sn.current[n]=o.createRef())});for(var pn=0;pn<Math.max(Le.length,He.length);pn+=1)dn.current[pn]||(dn.current[pn]=o.createRef()),un.current[pn]||(un.current[pn]=o.createRef());s(function(){if(Se){var e=he.fields.find(function(e){return e.analysisKey===Se||e.key===Se});if(e){var n=cn.current[e.key]||sn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Se,he.fields]);var hn=d(function(e){var n,t,i,r,o,l,a,c,s,d=null===(n=null==je?void 0:je.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=d[e],p=(null==u?void 0:u.relation)||(null===(i=null===(t=null==u?void 0:u.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==u?void 0:u.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var h=u.mappings[0]||{};return{score:u.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(a=h.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!p}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(c=u.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(s=u.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!p}},[je]),xn=d(function(n){var t,i,r=Le[n],o=He[n],l=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,a=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,c=!(!(null==r?void 0:r.cognitiveData)&&!(null==o?void 0:o.cognitiveData));if(!l&&!a&&!c)return e(e({},he.relationStyles.noContent),{label:"Not Defined"});var s,d=hn("description"),u=null!==(t=null==r?void 0:r.cognitiveRelevanceScore)&&void 0!==t?t:null==o?void 0:o.cognitiveRelevanceScore;if(null!=u){var p=(s=u)>=90?{score:1,relation:"exact_match"}:s>=70?{score:.8,relation:"high_match"}:s>=40?{score:.5,relation:"partial_match"}:{score:0,relation:"NA"};return z(0,p.relation,!0,he)}var h=l?r.relation:a?o.relation:d.relation,x=null!==(i=null==r?void 0:r.score)&&void 0!==i?i:null==o?void 0:o.score;"number"==typeof x||d.score;return z(0,h,!0,he)},[Le,He,he,hn]),gn=d(function(){var e,n,t;if(!de.current){de.current=!0;try{if(!qe.current)return;var i=qe.current.getBoundingClientRect(),r=[];an.forEach(function(e){var n=e.key,t=e.analysisKey,o=cn.current[n],l=sn.current[n];if((null==o?void 0:o.current)&&(null==l?void 0:l.current)){o.current.style.height="auto",l.current.style.height="auto",o.current.style.minHeight="0px",l.current.style.minHeight="0px";var a=o.current.getBoundingClientRect().height,c=l.current.getBoundingClientRect().height,s=Math.max(a,c);o.current.style.minHeight="".concat(s,"px"),l.current.style.minHeight="".concat(s,"px");var d=o.current.getBoundingClientRect(),u=l.current.getBoundingClientRect(),p=hn(t),h=z(p.score,p.relation,p.hasContent,he);if(!h)return;var x=d.top+d.height/2-i.top;r.push({id:"field-".concat(n),x1:d.right-i.left,y1:x,x2:u.left-i.left,y2:x,style:h})}});for(var o=Math.min(Le.length,He.length),l=0;l<o;l+=1){var a=dn.current[l],c=un.current[l];if((null==a?void 0:a.current)&&(null==c?void 0:c.current)){a.current.style.height="auto",c.current.style.height="auto",a.current.style.minHeight="0px",c.current.style.minHeight="0px";var s=Math.max(a.current.getBoundingClientRect().height,c.current.getBoundingClientRect().height);a.current.style.minHeight="".concat(s,"px"),c.current.style.minHeight="".concat(s,"px");var d=a.current.querySelector(".MuiAccordionSummary-root"),u=c.current.querySelector(".MuiAccordionSummary-root");if(d&&u){var p=d.getBoundingClientRect(),h=u.getBoundingClientRect(),x=(p.top+p.height/2-i.top+h.top+h.height/2-i.top)/2,g=(null===(e=He[l])||void 0===e?void 0:e.id)||"sec-".concat(l),f=xn(l);f&&r.push({id:g,x1:p.right-i.left,y1:x,x2:h.left-i.left,y2:x,style:f,sectionIdx:l,hasCognitive:!(!(null===(n=Le[l])||void 0===n?void 0:n.cognitiveData)&&!(null===(t=He[l])||void 0===t?void 0:t.cognitiveData))})}}}if($e(r),Ue.current&&Ye.current){var v=Ue.current.getBoundingClientRect(),m=Ye.current.getBoundingClientRect(),b=(v.top+v.height/2-i.top+m.top+m.height/2-i.top)/2;Ze({x1:v.right-i.left,x2:m.left-i.left,y:b})}else Ze(null)}catch(e){console.error("Line render safe fail: ",e)}finally{de.current=!1}}},[an,Le,He,he,hn,xn]);s(function(){var e=setTimeout(gn,250);window.addEventListener("resize",gn);var n=null;return ce.current&&(n=new ResizeObserver(function(){return window.requestAnimationFrame(gn)})).observe(ce.current),function(){clearTimeout(e),window.removeEventListener("resize",gn),null==n||n.disconnect()}},[ge,Te,je,we,an,ke,Le,He,he,gn]);var fn=function(n,r,o,l){var a=!P(n.title)&&!P(n.content);return i(u,e({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:t(v,e({disableGutters:!0,expanded:!a&&!!ke[r],onChange:function(){return!a&&(n=r,void Ae(function(t){var i;return e(e({},t),((i={})[n]=!t[n],i))}));var n},sx:{boxShadow:"none",border:a?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:a?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[i(m,e({expandIcon:a?null:i(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:a?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:i(p,e({sx:{fontSize:"12px",color:a?"#94A3B8":"#19213D",fontWeight:a?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:I(n.title||"No Matching Section Found")}))})),!a&&t(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[i(p,e({component:"div",sx:R},{children:i(k,{children:A(n.content).replace(/\\n/g,"\n")})})),(n.subsections||[]).map(function(n,t){return i(u,e({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:i(p,e({component:"div",sx:R},{children:i(k,{children:A(n).replace(/\\n/g,"\n")})}))}),"".concat(o,"-sub-").concat(r,"-").concat(t))})]}))]}))}),"".concat(o,"-sec-").concat(r))};return t(u,e({ref:se,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[oe.open&&i(H,{open:oe.open,popupRef:ie,position:ne,onClose:function(){te(null),le(function(n){return e(e({},n),{open:!1})})},sectionTitle:oe.sectionTitle,referenceSectionTitle:oe.refSectionTitle,cognitiveData:oe.cognitiveData,anchorEl:oe.anchorEl,sectionAnchorEl:oe.sectionAnchorEl,scrollContainerEl:ce.current,badgeStyle:oe.badgeStyle}),i(x,e({open:!!$,autoHideDuration:8e3,onClose:function(){return X(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(g,e({onClose:function(){return X(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:$}))})),Ie.length>1&&t(u,e({sx:{px:3,pb:.25},ref:Z},{children:[t(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[i(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),t(u,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[i(f,e({onClick:function(){return Re("left")},size:"small",disabled:!nn},{children:i(F,{size:18})})),i(f,e({onClick:function(){return Re("right")},size:"small",disabled:!on},{children:i(w,{size:18})}))]}))]})),i(u,e({ref:ae,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"}}},{children:Ie.map(function(e){return i(M,{data:e,isSelected:(null==ze?void 0:ze.id)===e.id,isCognitiveOpen:we,onToggleCognitive:function(){return Ee(function(e){return!e})},onClick:function(){return ye((n=e).id),U(n),void Ee(!1);var n}},e.id)})}))]})),i(u,e({ref:ce,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:Oe&&Pe&&we?"none":"1.5px solid #EEF0F4"}},{children:i(u,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:t(u,e({ref:qe,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[t("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[Qe&&t("g",{children:[i("line",{x1:Qe.x1,y1:Qe.y,x2:Math.max(Qe.x1,(Qe.x1+Qe.x2)/2-70),y2:Qe.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),i("line",{x1:Math.min(Qe.x2,(Qe.x1+Qe.x2)/2+70),y1:Qe.y,x2:Qe.x2,y2:Qe.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Je.map(function(n,r){var o=(n.x1+n.x2)/2;return"Not Defined"!==n.style.label||n.hasCognitive?t("g",{children:[i("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1.5"}),i("foreignObject",e({x:o-75,y:n.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[n.style.label,t(u,e({onClick:function(t){if(t.stopPropagation(),oe.open&&oe.sectionIdx===n.sectionIdx)return te(null),void le(function(n){return e(e({},n),{open:!1})});!function(e,n,t,i,r){var o,l;e.stopPropagation(),te(null);var a=A(n.id)||A(t.id)||"",c=(a?Q[a]:null)||n.cognitiveData||t.cognitiveData||null,s=null!==(l=null===(o=Ne.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;le({open:!0,sectionTitle:n.title||"Section",refSectionTitle:t.title||"Reference Section",cognitiveData:c,anchorEl:e.currentTarget,sectionAnchorEl:s,badgeStyle:r||null,sectionIdx:i})}(t,Le[n.sectionIdx]||{title:"",content:""},He[n.sectionIdx]||{title:"",content:""},n.sectionIdx,n.style)},sx:{display:"inline-flex",alignItems:"center",gap:"2px",cursor:"pointer",verticalAlign:"middle"}},{children:[n.hasCognitive&&void 0!==n.sectionIdx&&i(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"center",color:n.style.badgeText}},{children:i("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:i(B,{})}))})),oe.open&&oe.sectionIdx===n.sectionIdx?i(E,{size:12,color:n.style.badgeText}):i(y,{size:12,color:n.style.badgeText})]}))]}))}))}))]},r):null})]})),t(u,e({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[i(u,e({ref:Ue,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:_e}))})),t(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[an.map(function(e){var n=e.key,t=e.label,r=e.analysisKey,o=hn(r),l=ge[n],a=Te[n];if(!P(l)&&!P(a))return null;var c=z(o.score,o.relation,o.hasContent,he);return c?i(_,{ref:cn.current[n],label:t,content:l,highlights:o.highlightsA,styleVariant:c,isHighlighted:Se===r||Se===n},"left-".concat(n)):null}),Me&&Le.map(function(e,n){return{section:e,idx:n}}).map(function(n){var t=n.section,r=n.idx;return i(u,e({ref:Ke(r)},{children:fn(t,r,"left",dn.current[r]||o.createRef())}),"left-row-".concat(r))})]}))]})),i(u,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:i(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(u,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[i(u,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(B,{})})),Ve,"% Similarity",i(y,{size:11})]}))}))})),t(u,e({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[i(u,e({ref:Ye,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:We}))})),t(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[an.map(function(e){var n=e.key,t=e.label,r=e.analysisKey,o=hn(r),l=ge[n],a=Te[n];if(!P(l)&&!P(a))return null;var c=z(o.score,o.relation,o.hasContent,he);return c?i(_,{ref:sn.current[n],label:t,content:a,highlights:o.highlightsB,styleVariant:c,isHighlighted:Se===r||Se===n},"right-".concat(n)):null}),Me&&He.map(function(e,n){return{section:e,idx:n}}).map(function(e){var n=e.section,t=e.idx;return fn(n,t,"right",un.current[t]||o.createRef())})]}))]}))]}))}))}))]}))};export{O as DEFAULT_COMPARISON_CONFIG,j as DEFAULT_FIELD_CONFIG,q as default};
1
+ import{__assign as e}from"tslib";import{jsxs as n,jsx as t}from"react/jsx-runtime";import i,{useState as o,useMemo as r,useRef as l,useEffect as c,useCallback as a}from"react";import{Box as d,Snackbar as s,Alert as u,Typography as h,Tooltip as v,Accordion as p,AccordionSummary as f,AccordionDetails as g}from"@mui/material";import{ChevronUp as x,ChevronDown as m}from"lucide-react";import{ButtonCognitiveIcon as y}from"../../assests/svg/ButtonCognitiveIcon.js";import w from"react-markdown";import{safeStringify as F,hasValue as b,getStyleForRelation as E,cognitiveScoreToRelation as S,getRationale as C,getSideData as _}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as A,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as I}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import R from"./CognitivePopup.js";var T={id:"",title:""},B=function(B){var k,M,z,H,W,j,L,O,P=B.componentHeaderText,N=void 0===P?"Learning Comparison":P,q=B.treeData,V=B.comparisonConfig,K=B.leftColumnTitleText,U=B.rightColumnTitleText,Y=B.markdownStyles,G=o(null),J=G[0],Q=G[1],X=r(function(){return(null==q?void 0:q.cognitive_decisioning)||{}},[q]);l(null);var Z=o(null),$=Z[0],ee=Z[1],ne=l(null),te=o({width:0,height:0}),ie=te[0],oe=te[1],re=r(function(){return e(e({},A),Y)},[Y]),le=o({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null}),ce=le[0],ae=le[1],de=l(null),se=l(null),ue=l(!1),he=l(null);c(function(){he.current=null},[ce.sectionIdx,ce.open]);var ve=a(function(){var e;if(ce.anchorEl&&ce.refSectionTitle){var n=ce.anchorEl.getBoundingClientRect(),t=(null===(e=null==ne?void 0:ne.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-12,r=n.top-12-12,l=o<t&&r>o;null!==he.current?!0===he.current&&(l=r>=t||r>=o):l=!(o>=t||o>=r),he.current=l;var c=l?r:o,a=Math.min(t||9999,c),d=l?n.top-12-a:n.bottom+12,s=n.left+n.width/2,u=s-i/2,h=Math.max(12,Math.min(u,window.innerWidth-i-12)),v=Math.max(14,Math.min(s-h,i-10-4));ee({top:d,left:h,arrowLeft:v,openAbove:l,maxHeight:c})}},[ce.anchorEl,ce.refSectionTitle]);c(function(){if(ce.open){window.addEventListener("resize",ve);var e=requestAnimationFrame(ve),n=null;return ne.current&&(n=new ResizeObserver(function(){e=requestAnimationFrame(ve)})).observe(ne.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",ve),n&&n.disconnect()}}},[ce.open,ve]),c(function(){var n=de.current;if(n&&ce.open){var t=function(n){ne.current&&ne.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),ee(null),ae(function(n){return e(e({},n),{open:!1,anchorEl:null,sectionAnchorEl:null})}))};return n.addEventListener("scroll",t,{capture:!0}),window.addEventListener("scroll",t,{capture:!0}),function(){n.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("scroll",t,{capture:!0})}}},[ce.open]);var pe=r(function(){var n,t,i,o,r,l,c,a,d,s,u,h;return{fields:null!==(n=null==V?void 0:V.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==V?void 0:V.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:I.thresholds.high,medium:null!==(r=null===(o=null==V?void 0:V.thresholds)||void 0===o?void 0:o.medium)&&void 0!==r?r:I.thresholds.medium,exact:null!==(c=null===(l=null==V?void 0:V.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:I.thresholds.exact},relationStyles:{noContent:e(e({},I.relationStyles.noContent),(null===(a=null==V?void 0:V.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},I.relationStyles.high),(null===(d=null==V?void 0:V.relationStyles)||void 0===d?void 0:d.high)||{}),exact:e(e({},I.relationStyles.exact),(null===(s=null==V?void 0:V.relationStyles)||void 0===s?void 0:s.exact)||{}),medium:e(e({},I.relationStyles.medium),(null===(u=null==V?void 0:V.relationStyles)||void 0===u?void 0:u.medium)||{}),low:e(e({},I.relationStyles.low),(null===(h=null==V?void 0:V.relationStyles)||void 0===h?void 0:h.low)||{})}}},[V]),fe=r(function(){if(q&&Object.keys(q).length>0)try{var n=function(n){var t,i,o,r,l=[],c=[],a=n.base_root_id,d=n.input_index_map||{0:"left",1:"right"},s=n[a];if(!s||!1===s.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var u=function(t){var i=n[t];if(i&&!1!==i.display_node){var o=C(i),r=_(i,"0",d),a=_(i,"1",d),s=r.title.trim()||r.content.trim(),h=a.title.trim()||a.content.trim();l.push(e({id:t,title:s?r.title:"",content:s?r.content:"",subsections:[]},s?o:{score:void 0,relation:"not_defined"})),c.push(e({id:t,title:h?a.title:"",content:h?a.content:"",subsections:[]},h?o:{score:void 0,relation:"not_defined"})),i.next&&Object.values(i.next).forEach(u)}};return s.next&&Object.values(s.next).forEach(u),{activeProposed:{title:(null===(i=null===(t=s.comparison_inputs)||void 0===t?void 0:t[d[0]])||void 0===i?void 0:i.title)||"Uploaded Contract",description:s.decision_scope_description||"",sections:l},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(o=s.comparison_inputs)||void 0===o?void 0:o[d[1]])||void 0===r?void 0:r.title)||"Reference Template",similarity:0,sections:c,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:s.decision_scope_description||""},fields:{}}}}]}}(q);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[q]),ge=fe.activeProposed,xe=fe.activeVariants,me=fe.parseError;c(function(){me&&Q("Failed to load comparison: ".concat(me))},[me]);var ye=o(null),we=ye[0];ye[1];var Fe=o({}),be=Fe[0],Ee=Fe[1],Se=xe[0]||T,Ce=null===(z=null===(k=null==q?void 0:q.documents)||void 0===k?void 0:k[null===(M=null==q?void 0:q.input_index_map)||void 0===M?void 0:M[0]])||void 0===z?void 0:z.title,_e=null===(j=null===(H=null==q?void 0:q.documents)||void 0===H?void 0:H[null===(W=null==q?void 0:q.input_index_map)||void 0===W?void 0:W[1]])||void 0===j?void 0:j.title,Ae=F(K||Ce||"Uploaded Contract"),De=F(U||_e||"Reference Template"),Ie=r(function(){return ge.sections||[]},[ge.sections]),Re=r(function(){return Se.sections||[]},[Se.sections]),Te=Ie.length>0||Re.length>0,Be=Se.analysis,ke=F(null===(O=null===(L=null==Be?void 0:Be.rule_difference_comparison)||void 0===L?void 0:L.summary)||void 0===O?void 0:O.overall_summary),Me=!!ke.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),ze=l({}),He=function(e){return ze.current[e]||(ze.current[e]=i.createRef()),ze.current[e]},We=l(null),je=l(null),Le=l(null),Oe=o([]),Pe=Oe[0],Ne=Oe[1],qe=o(null),Ve=qe[0],Ke=qe[1],Ue=r(function(){return pe.fields.filter(function(e){var n=e.key;return(!Te||"description"!==n)&&(b(ge[n])||b(Se[n]))})},[ge,Se,Te,pe.fields]),Ye=l({}),Ge=l({}),Je=l({}),Qe=l({});Ue.forEach(function(e){var n=e.key;Ye.current[n]||(Ye.current[n]=i.createRef()),Ge.current[n]||(Ge.current[n]=i.createRef())});for(var Xe=0;Xe<Math.max(Ie.length,Re.length);Xe+=1)Je.current[Xe]||(Je.current[Xe]=i.createRef()),Qe.current[Xe]||(Qe.current[Xe]=i.createRef());c(function(){if(we){var e=pe.fields.find(function(e){return e.analysisKey===we||e.key===we});if(e){var n=Ye.current[e.key]||Ge.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[we,pe.fields]);var Ze=a(function(e){var n,t,i,o,r,l,c,a,d,s=null===(n=null==Be?void 0:Be.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var u=s[e],h=(null==u?void 0:u.relation)||(null===(i=null===(t=null==u?void 0:u.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==u?void 0:u.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==u?void 0:u.mappings)&&u.mappings.length>0;if(u.mappings){var v=u.mappings[0]||{};return{score:u.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=v.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!h}}return{score:u.score,relation:u.relation||"",highlightsA:(null===(a=u.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(d=u.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!h}},[Be]),$e=a(function(n){var t,i,o=Ie[n],r=Re[n],l=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,c=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,a=!(!(null==o?void 0:o.cognitiveData)&&!(null==r?void 0:r.cognitiveData));if(!l&&!c&&!a)return e(e({},pe.relationStyles.noContent),{label:"Not Defined"});var d=Ze("description");if(null!=(null!==(t=null==o?void 0:o.cognitiveRelevanceScore)&&void 0!==t?t:null==r?void 0:r.cognitiveRelevanceScore)){var s=S(),u=s.score,h=s.relation;return E(u,h,!0,pe)}var v=l?o.relation:c?r.relation:d.relation,p=null!==(i=null==o?void 0:o.score)&&void 0!==i?i:null==r?void 0:r.score,f="number"==typeof p?p:d.score;return E(f,v,!0,pe)},[Ie,Re,pe,Ze]),en=a(function(){var e,n,t,i,o,r,l,c,a,d,s;if(!ue.current){ue.current=!0;try{if(!We.current)return;var u=We.current.getBoundingClientRect();oe({width:u.width,height:u.height});var h=[];Ue.forEach(function(e){var n,t,i=e.key,o=null===(n=Ye.current[i])||void 0===n?void 0:n.current,r=null===(t=Ge.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")});for(var v=0;v<Math.min(Ie.length,Re.length);v++){var p=null===(e=Je.current[v])||void 0===e?void 0:e.current,f=null===(n=Qe.current[v])||void 0===n?void 0:n.current;p&&f&&(p.style.height="auto",f.style.height="auto",p.style.minHeight="0px",f.style.minHeight="0px")}var g={};Ue.forEach(function(e){var n,t,i=e.key,o=null===(n=Ye.current[i])||void 0===n?void 0:n.current,r=null===(t=Ge.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect();g[i]=Math.max(l.height,c.height)}});var x=[];for(v=0;v<Math.min(Ie.length,Re.length);v++){p=null===(t=Je.current[v])||void 0===t?void 0:t.current,f=null===(i=Qe.current[v])||void 0===i?void 0:i.current;if(p&&f){var m=p.getBoundingClientRect(),y=f.getBoundingClientRect();x[v]=Math.max(m.height,y.height)}}Ue.forEach(function(e){var n,t,i=e.key,o=null===(n=Ye.current[i])||void 0===n?void 0:n.current,r=null===(t=Ge.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=g[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}});for(v=0;v<x.length;v++){p=null===(o=Je.current[v])||void 0===o?void 0:o.current,f=null===(r=Qe.current[v])||void 0===r?void 0:r.current;if(p&&f){var w=x[v];p.style.minHeight="".concat(w,"px"),f.style.minHeight="".concat(w,"px")}}Ue.forEach(function(e){var n,t,i=e.key,o=e.analysisKey,r=null===(n=Ye.current[i])||void 0===n?void 0:n.current,l=null===(t=Ge.current[i])||void 0===t?void 0:t.current;if(r&&l){var c=r.getBoundingClientRect(),a=l.getBoundingClientRect(),d=Ze(o),s=E(d.score,d.relation,d.hasContent,pe);if(!s)return;var v=c.top+c.height/2-u.top;h.push({id:"field-".concat(i),x1:c.right-u.left,y1:v,x2:a.left-u.left,y2:v,style:s})}});for(v=0;v<Math.min(Ie.length,Re.length);v++){var F=null===(l=Je.current[v])||void 0===l?void 0:l.current,b=null===(c=Qe.current[v])||void 0===c?void 0:c.current;if(F&&b){var S=F.querySelector(".MuiAccordionSummary-root"),C=b.querySelector(".MuiAccordionSummary-root");if(S&&C){var _=S.getBoundingClientRect(),A=C.getBoundingClientRect(),D=(_.top+_.height/2-u.top+A.top+A.height/2-u.top)/2,I=(null===(a=Re[v])||void 0===a?void 0:a.id)||"sec-".concat(v),R=$e(v);R&&h.push({id:I,x1:_.right-u.left,y1:D,x2:A.left-u.left,y2:D,style:R,sectionIdx:v,hasCognitive:!(!(null===(d=Ie[v])||void 0===d?void 0:d.cognitiveData)&&!(null===(s=Re[v])||void 0===s?void 0:s.cognitiveData))})}}}if(Ne(h),je.current&&Le.current){var T=je.current.getBoundingClientRect(),B=Le.current.getBoundingClientRect(),k=(T.top+T.height/2-u.top+B.top+B.height/2-u.top)/2;Ke({x1:T.right-u.left,x2:B.left-u.left,y:k})}else Ke(null)}catch(e){console.error("Line render safe fail: ",e)}finally{ue.current=!1}}},[Ue,Ie,Re,pe,Ze,$e]),nn=a(function(){window.requestAnimationFrame(en)},[en]);c(function(){var e=setTimeout(nn,250);window.addEventListener("resize",nn);var n=null,t=null;return de.current&&(n=new ResizeObserver(nn)).observe(de.current),We.current&&(t=new ResizeObserver(nn)).observe(We.current),function(){clearTimeout(e),window.removeEventListener("resize",nn),null==n||n.disconnect(),null==t||t.disconnect()}},[ge,Se,Be,Ue,be,Ie,Re,pe,nn]);var tn=function(o,r,l,c){var a,s=!b(o.title)&&!b(o.content);return t(d,e({ref:c,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:n(p,e({disableGutters:!0,expanded:!s&&!!be[r],onChange:function(){return!s&&(n=r,void Ee(function(t){var i;return e(e({},t),((i={})[n]=!t[n],i))}));var n},sx:{boxShadow:"none",border:s?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:s?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[t(f,e({expandIcon:s?null:t(m,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:s?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:t(v,e({title:o.title||"No Matching Section Found",placement:"top"},{children:t(h,e({sx:{fontSize:"12px",color:s?"#94A3B8":"#19213D",fontWeight:s?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(a=o.title||"No Matching Section Found",a?F(a).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(i.Fragment,{children:e},n)}):null)}))}))})),!s&&n(g,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(h,e({component:"div",sx:re},{children:t(w,{children:F(o.content).replace(/\\n/g,"\n")})})),(o.subsections||[]).map(function(n,i){return t(d,e({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:t(h,e({component:"div",sx:re},{children:t(w,{children:F(n).replace(/\\n/g,"\n")})}))}),"".concat(l,"-sub-").concat(r,"-").concat(i))})]}))]}))}),"".concat(l,"-sec-").concat(r))};return n(d,e({ref:se,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[ce.open&&t(R,{open:ce.open,popupRef:ne,position:$,onClose:function(){ee(null),ae(function(n){return e(e({},n),{open:!1})})},markdownStyles:Y,sectionTitle:ce.sectionTitle,referenceSectionTitle:ce.refSectionTitle,cognitiveData:ce.cognitiveData,anchorEl:ce.anchorEl,sectionAnchorEl:ce.sectionAnchorEl,scrollContainerEl:de.current,badgeStyle:ce.badgeStyle}),t(s,e({open:!!J,autoHideDuration:8e3,onClose:function(){return Q(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(u,e({onClose:function(){return Q(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),t(d,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:t(d,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:t(h,e({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:N}))}))})),t(d,e({ref:de,sx:{flex:1,overflowY:"auto",minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:ke&&Me?"none":"1.5px solid #EEF0F4"}},{children:t(d,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:n(d,e({ref:We,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0}},{children:[n("svg",e({style:{position:"absolute",top:0,left:0,width:ie.width||"100%",height:ie.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[Ve&&n("g",{children:[t("line",{x1:Ve.x1,y1:Ve.y,x2:Math.max(Ve.x1,(Ve.x1+Ve.x2)/2-70),y2:Ve.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(Ve.x2,(Ve.x1+Ve.x2)/2+70),y1:Ve.y,x2:Ve.x2,y2:Ve.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Pe.map(function(i,o){var r=(i.x1+i.x2)/2;return"Not Defined"!==i.style.label||i.hasCognitive?n("g",{children:[t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder,strokeWidth:"1.5"}),t("foreignObject",e({x:r-75,y:i.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(d,e({sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,n(d,e({onClick:function(n){if(n.stopPropagation(),ce.open&&ce.sectionIdx===i.sectionIdx)return ee(null),void ae(function(n){return e(e({},n),{open:!1})});!function(e,n,t,i,o){var r,l;e.stopPropagation(),ee(null);var c=F(n.id)||F(t.id)||"",a=(c?X[c]:null)||n.cognitiveData||t.cognitiveData||null,d=null!==(l=null===(r=ze.current[i])||void 0===r?void 0:r.current)&&void 0!==l?l:null;ae({open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:a,anchorEl:e.currentTarget,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i})}(n,Ie[i.sectionIdx]||{title:"",content:""},Re[i.sectionIdx]||{title:"",content:""},i.sectionIdx,i.style)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",cursor:"pointer",verticalAlign:"middle"}},{children:[i.hasCognitive&&void 0!==i.sectionIdx&&t(d,e({sx:{display:"flex",alignItems:"center",justifyContent:"center",color:i.style.badgeText}},{children:t("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:t(y,{})}))})),ce.open&&ce.sectionIdx===i.sectionIdx?t(x,{size:12,color:i.style.badgeText}):t(m,{size:12,color:i.style.badgeText})]}))]}))}))}))]},o):null})]})),n(d,e({sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[t(d,e({ref:je,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center",overflow:"hidden"}},{children:t(v,e({title:Ae,placement:"top"},{children:t(h,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},{children:Ae}))}))})),t(d,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:Te&&Ie.map(function(e,n){return{section:e,idx:n}}).map(function(n){var o=n.section,r=n.idx;return t(d,e({ref:He(r)},{children:tn(o,r,"left",Je.current[r]||i.createRef())}),"left-row-".concat(r))})}))]})),t(d,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n(d,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(y,{})})),0,"% Similarity",t(m,{size:11})]}))}))})),n(d,e({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[t(d,e({ref:Le,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center",overflow:"hidden"}},{children:t(v,e({title:De,placement:"top"},{children:t(h,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},{children:De}))}))})),t(d,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:Te&&Re.map(function(e,n){return{section:e,idx:n}}).map(function(e){var n=e.section,t=e.idx;return tn(n,t,"right",Qe.current[t]||i.createRef())})}))]}))]}))}))}))]}))};export{B as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -0,0 +1,2 @@
1
+ var e=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],F={fields:e,thresholds:{exact:90,high:70,medium:40},relationStyles:{noContent:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F8FAFC",badgeBorder:"#F1F5F9",badgeText:"#64748B",highlightBg:"transparent"},exact:{bg:"#FFF1F2",border:"#FECDD3",badgeBg:"#FFE4E6",badgeBorder:"#FEE2E2",badgeText:"#9F1239",highlightBg:"#FECDD3"},high:{bg:"#FFF5F5",border:"#FECACA",badgeBg:"#FEECEC",badgeBorder:"#F8C2C2",badgeText:"#B42318",highlightBg:"#FDD5D5"},medium:{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3"},low:{bg:"#F5F9FF",border:"#CFE0FF",badgeBg:"#EEF4FF",badgeBorder:"#BFD3FF",badgeText:"#1D4ED8",highlightBg:"#DCEAFF"}}},r={fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word",overflow:"hidden","& p":{mt:0,mb:1.5},"& p:last-child":{mb:0},"& ul":{mt:0,mb:1.5,pl:2.5,listStyleType:"disc"},"& ol":{mt:0,mb:1.5,pl:2.5,listStyleType:"decimal"},"& li":{mb:.5},"& strong":{fontWeight:600},"& code":{whiteSpace:"pre-wrap",wordBreak:"break-word"}};export{F as DEFAULT_COMPARISON_CONFIG,e as DEFAULT_FIELD_CONFIG,r as SHARED_MARKDOWN_STYLES};
2
+ //# sourceMappingURL=CognitiveCompareConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveCompareConfig.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{__assign as n}from"tslib";var i=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(i).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},e=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return e(n)}))},t=function(n,e,t){var r,o=t[e],a=null===(r=null==n?void 0:n.comparison_inputs)||void 0===r?void 0:r[o];return{title:i((null==a?void 0:a.title)||""),content:i((null==a?void 0:a.content)||"")}},r=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0},score:0,relation:"N/A"};var i=n.mapping_rationale,e=parseInt(i.decision_strength||"0");return{cognitiveData:{decisioning:i.decisioning_factors||[],gap:i.gaps_in_decision||[],relevance_score:e},score:0,relation:"N/A"}},o=function(n){return n&&"string"==typeof n?"N/A"===n.toUpperCase()?"N/A":n.split("_").map(function(n){return n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()}).join(" "):"Unknown"},a=function(i,e,t,r){var a=100*(i||0),l=r.thresholds,s=r.relationStyles;if(!t)return null;var c=o(e),u=(e||"").toLowerCase();return"n/a"===u||u.includes("no_deviation")?n(n({},s.low),{label:c}):u.includes("deviation")||u.includes("high_risk")||u.includes("critical")?n(n({},s.high),{label:c}):a>=l.exact?n(n({},s.exact),{label:c}):a>=l.high?n(n({},s.high),{label:c}):a>=l.medium?n(n({},s.medium),{label:c}):n(n({},s.low),{label:c})},l=function(n){return{score:0,relation:"N/A"}};export{l as cognitiveScoreToRelation,o as formatRelationToLabel,r as getRationale,t as getSideData,a as getStyleForRelation,e as hasValue,i as safeStringify};
2
+ //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveComparehelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{__assign as e}from"tslib";import{jsxs as o,Fragment as i,jsx as r}from"react/jsx-runtime";import{useState as n,useEffect as t,useMemo as l}from"react";import{Box as a,Typography as d,IconButton as s}from"@mui/material";import{X as c}from"lucide-react";import p from"react-dom";import x from"../../assests/svg/SparkleIcon.js";import h from"react-markdown";import{SHARED_MARKDOWN_STYLES as f}from"./CognitiveCompareConfig.js";var b=10,g=function(g){var m,u,v,w,F,y=g.open,E=g.onClose,D=g.sectionTitle,S=g.referenceSectionTitle,C=g.cognitiveData,k=g.relevanceScore,z=g.anchorEl,W=g.badgeStyle,R=g.popupRef,A=g.position,I=g.markdownStyles,B=e(e({},f),I),H=null==C?void 0:C.isMissingRationale,L=n(H?"deviation":"association"),j=L[0],T=L[1];t(function(){y&&T(H?"deviation":"association")},[y,H]);var M=l(function(){if(!W)return{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"};var e=W.badgeText;return"#9F1239"===e||"#B42318"===e?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===e?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===e?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:"#5928ED",shadow:"rgba(89,40,237,0.18)"}},[W]);if(t(function(){if(y){var e=function(e){var o;(null===(o=R.current)||void 0===o?void 0:o.contains(e.target))||(null==z?void 0:z.contains(e.target))||E()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[y,E,z,R]),!y||!C)return null;var O=null!==(u=null!==(m=C.relevance_score)&&void 0!==m?m:k)&&void 0!==u?u:0,Y=C.decisioning,G=Array.isArray(Y)?Y:"string"==typeof Y&&Y.trim()?[Y]:[],N=C.gap,P=Array.isArray(N)?N:"string"==typeof N&&N.trim()?[N]:[],_=null!==(v=null==A?void 0:A.arrowLeft)&&void 0!==v?v:60,q=o(a,e({ref:R,sx:{position:"fixed",top:null!==(w=null==A?void 0:A.top)&&void 0!==w?w:-9999,left:null!==(F=null==A?void 0:A.left)&&void 0!==F?F:-9999,zIndex:9999,width:"min(".concat(680,"px, calc(100vw - ").concat(24,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(M.border),boxShadow:"0px 8px 32px ".concat(M.shadow,", 0px 0px 0px 3px ").concat(M.shadow),overflow:"visible",display:"flex",flexDirection:"column",maxHeight:(null==A?void 0:A.maxHeight)?"min(60vh, ".concat(A.maxHeight,"px)"):"60vh",visibility:A?"visible":"hidden"}},{children:[A&&(A.openAbove?o(i,{children:[r(a,{sx:{position:"absolute",bottom:-11,left:_-b,width:0,height:0,borderLeft:"".concat(b,"px solid transparent"),borderRight:"".concat(b,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(M.border),zIndex:1}}),r(a,{sx:{position:"absolute",bottom:-9,left:_-b+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(b,"px solid #FFFFFF"),zIndex:2}})]}):o(i,{children:[r(a,{sx:{position:"absolute",top:-11,left:_-b,width:0,height:0,borderLeft:"".concat(b,"px solid transparent"),borderRight:"".concat(b,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(M.border),zIndex:1}}),r(a,{sx:{position:"absolute",top:-9,left:_-b+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(b,"px solid #FFFFFF"),zIndex:2}})]})),o(a,e({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[o(a,e({sx:{flex:1,minWidth:0}},{children:[o(d,e({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[r(a,e({component:"span",title:D,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:D})),r(a,e({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),r(a,e({component:"span",title:S||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:S||"Reference Section"}))]})),r(a,e({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:r(d,e({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"deviation"===j?"Why this is a deviation?":"Why these sections are paired?"}))}))]})),o(a,e({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[o(a,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[r(x,{}),"Decision Strength ",O,"%"]})),r(s,e({onClick:E,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:r(c,{size:22})}))]}))]})),r(a,e({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:(H?["deviation"]:["deviation","association"]).map(function(o){var i=j===o;return r(a,e({onClick:function(){return T(o)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:"pointer",fontSize:"14px",fontWeight:i?600:400,color:i?"#5928ED":"#667085",backgroundColor:i?"rgba(89,40,237,0.08)":"transparent",borderBottom:i?"2px solid #5928ED":"2px solid transparent",transition:"all 0.15s",userSelect:"none",overflowY:"auto"}},{children:"deviation"===o?"Deviation Analysis":"Association Logic"}),o)})})),r(a,e({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(M.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:M.border},scrollbarWidth:"thin",scrollbarColor:"".concat(M.border,"55 transparent")}},{children:"deviation"===j?o(a,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[r(d,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),r(d,e({sx:{fontSize:"14px",color:"#667085",lineHeight:1.6}},{children:"Deviation analysis content will appear here. This tab shows structural and semantic deviations identified between the two sections being compared."}))]})):o(i,{children:[G.length>0&&o(a,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[r(a,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:r(d,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),r(a,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:r(a,e({sx:{display:"flex",flexDirection:"column"}},{children:r(d,e({component:"div",sx:e({},B)},{children:r(h,{children:G.join("\n\n")})}))}))}))]})),P.length>0&&o(a,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[r(a,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:r(d,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),r(a,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:r(a,e({sx:{display:"flex",flexDirection:"column"}},{children:r(d,e({component:"div",sx:e({},B)},{children:r(h,{children:P.join("\n\n")})}))}))}))]})),0===G.length&&0===P.length&&r(a,e({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:r(d,e({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return p.createPortal(q,document.body)};export{g as default};
2
+ //# sourceMappingURL=CognitivePopup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitivePopup.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as i,jsx as t,Fragment as l}from"react/jsx-runtime";import{useMemo as a,useState as r,useRef as c,useEffect as o}from"react";import{ExternalLink as s}from"lucide-react";import d from"./CognitiveNonWebSearchReasoning.module.css.js";var h=function(n){return n.split(/(\*\*.*?\*\*|__.*?__)/g).map(function(n,i){return n.startsWith("**")&&n.endsWith("**")||n.startsWith("__")&&n.endsWith("__")?t("strong",e({className:d.boldText},{children:n.slice(2,-2)}),i):n})},u=function(u){var m=u.item,v=u.headerTitle;u.index;var g=u.iconsConfig,f=u.DocumentTitle,p=u.previewCallback,N=u.bodyHeight,x=u.disableMaximize,b=void 0!==x&&x,C=m.dataSource,I=m.confidence_score,H=m.trainingDataTitle,T=null==g?void 0:g.ChevronDownIcon,k=null==g?void 0:g.ChevronUpIcon,L=null==g?void 0:g.MaximizeIcon,_=null==g?void 0:g.CloseIcon,w=a(function(){var e=(C?C.replace(/\\n/g,"\n").replace(/\n+/g,"\n"):"").split(/(<highlight>[\s\S]*?<\/highlight>)/g),i=0,t=e.map(function(n){var e=n.startsWith("<highlight>"),t={text:e?n.replace(/<\/?highlight>/g,""):n,isHighlight:e,highlightIndex:e?i:-1};return e&&i++,t}),l=t.filter(function(n){return n.isHighlight}).length,a=[],r=[];return t.forEach(function(e){var i=e.text,t=e.isHighlight,l=e.highlightIndex;i.split("\n").forEach(function(e,i){i>0&&((r.length>0||a.length>0)&&a.push(n([],r,!0)),r=[]),e&&r.push({text:e,isHighlight:t,highlightIndex:l})})}),r.length>0&&a.push(n([],r,!0)),{processedLines:a.map(function(n){var e=n.map(function(n){return n.text}).join(""),i=e.match(/^(\s*)(-|\*|\d+\.)\s+(.*)$/);return{segments:n,isListItem:!!i,isHeader:!!e.match(/^(Title|Description|Training-basis):\s*(.*)$/i),indent:(null==i?void 0:i[1])||"",content:(null==i?void 0:i[3])||e}}),totalHighlights:l}},[C]),y=w.processedLines,B=w.totalHighlights,S=r(0),z=S[0],D=S[1],W=c(null),A=c(null),j=c(null),F=c([]),M=c([]);o(function(){F.current=F.current.slice(0,B),M.current=M.current.slice(0,B)},[B]),o(function(){if(B>0){D(0);var n=setTimeout(function(){var n;null===(n=F.current[0])||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},50);return function(){return clearTimeout(n)}}},[B]);var V=function(n,e){setTimeout(function(){var i=e?M.current[n]:F.current[n];null==i||i.scrollIntoView({behavior:"smooth",block:"center"})},50)},E=function(n){var l=n?M:F,a=0;return y.map(function(n,r){n.isHeader&&(a=0),n.isListItem&&(a+=1);var c=function(){return n.segments.map(function(i,a){var r=i.isHighlight&&i.highlightIndex===z,c=i.text;return n.isListItem&&0===a&&(c=i.text.replace(/^(\s*)(-|\*|\d+\.)\s+/,"")),i.isHighlight?t("span",e({ref:function(n){n&&(l.current[i.highlightIndex]=n)},className:"".concat(d.highlight).concat(r?" ".concat(d.highlightActive):"")},{children:h(c)}),a):t("span",{children:h(c)},a)})};return n.isHeader?t("span",e({className:d.headerLine},{children:c()}),r):n.isListItem?i("span",e({className:d.listItemLine,style:{paddingLeft:n.indent?"1rem":"0"}},{children:[i("span",e({className:d.listCounter},{children:[a,"."]})),t("span",{children:c()})]}),r):t("span",e({className:d.blockLine},{children:c()}),r)})},$=function(n){return B>1?i("div",e({className:n?d.modalNavContainer:d.navigationContainer},{children:[k&&t("button",e({onClick:function(){return function(n){if(void 0===n&&(n=!1),B){var e=z>0?z-1:B-1;D(e),V(e,n)}}(n)},className:n?d.modalNavButton:d.navButton},{children:t(k,{className:d.navIcon})})),i("span",e({className:d.navCounter},{children:[z+1,"/",B]})),T&&t("button",e({onClick:function(){return function(n){if(void 0===n&&(n=!1),B){var e=z<B-1?z+1:0;D(e),V(e,n)}}(n)},className:n?d.modalNavButton:d.navButton},{children:t(T,{className:d.navIcon})}))]})):null},R=null!=I?i("span",e({className:d.confidenceBadge},{children:[t("span",e({className:d.confidenceStar},{children:"✦"})),i("span",e({className:d.confidenceScore},{children:[I,"%"]}))]})):null,U=i(l,{children:[H&&t("div",e({className:d.footer},{children:t("span",e({className:d.trainingTitle},{children:H}))})),f&&t("div",e({className:d.modalFooterSource},{children:i("button",e({type:"button",onClick:function(){return null==p?void 0:p()},className:d.trainingTitleLink},{children:[f,t(s,{size:16,color:"#2563eb"})]}))}))]});return i(l,{children:[i("div",e({className:d.expandedContainer,style:N?{height:"".concat(N),display:"flex",flexDirection:"column"}:void 0},{children:[i("div",e({className:d.expandedHeader},{children:[t("span",e({className:d.headerTitle},{children:v})),i("div",e({className:d.headerActions},{children:[$(!1),R,!b&&L&&t("button",e({onClick:function(){var n;return null===(n=j.current)||void 0===n?void 0:n.showModal()},className:d.maximizeButton,title:"View fullscreen"},{children:t(L,{className:d.maximizeIcon})}))]}))]})),t("div",e({ref:W,className:d.contentArea,style:N?{flex:1,maxHeight:"none",overflowY:"auto",minHeight:0}:void 0},{children:t("div",e({className:d.contentInner},{children:E(!1)}))})),U]})),!b&&t("dialog",e({ref:j,className:d.modalDialog,onClick:function(n){var e;n.target===j.current&&(null===(e=j.current)||void 0===e||e.close())}},{children:i("div",e({className:d.modalContainer},{children:[i("div",e({className:d.modalHeader},{children:[t("span",e({className:d.modalHeaderTitle},{children:v})),i("div",e({className:d.modalHeaderActions},{children:[$(!0),R,_&&t("button",e({onClick:function(){var n;return null===(n=j.current)||void 0===n?void 0:n.close()},className:d.closeButton,title:"Close"},{children:t(_,{className:d.closeIcon})}))]}))]})),t("div",e({ref:A,className:d.modalContent},{children:t("div",e({className:d.modalContentInner},{children:E(!0)}))})),H&&t("div",e({className:d.modalFooter},{children:t("span",e({className:d.trainingTitle},{children:H}))})),f&&t("div",e({className:d.modalFooterSource},{children:i("button",e({type:"button",onClick:function(){var n;null==p||p(),null===(n=j.current)||void 0===n||n.close()},className:d.trainingTitleLink},{children:[f,t(s,{size:16,color:"#2563eb"})]}))}))]}))}))]})};export{u as default};
2
+ //# sourceMappingURL=CognitiveInternalgptCoreComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveInternalgptCoreComponent.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAqiGA,QAAA,MAAM,oBAAoB,+CAazB,CAAA;AAED,eAAe,oBAAoB,CAAA"}
1
+ {"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAsoCA,QAAA,MAAM,oBAAoB,+CAWzB,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -1,109 +1,6 @@
1
- interface ComparisonFieldAnalysis {
2
- relation: string;
3
- score: number;
4
- highlights?: {
5
- ruleA_spans?: string[];
6
- ruleB_spans?: string[];
7
- };
8
- }
9
- interface ComparisonAnalysis {
10
- rule_difference_comparison: {
11
- summary: {
12
- overall_score: number;
13
- overall_summary: string;
14
- };
15
- fields: {
16
- [key: string]: ComparisonFieldAnalysis | {
17
- score: number;
18
- mappings: Record<string, unknown>[];
19
- };
20
- };
21
- };
22
- }
23
- interface CognitiveDecisioningEntry {
24
- section_id: string;
25
- decisioning?: string | string[];
26
- gap?: string | string[];
27
- relevance_score: number;
28
- metadata?: unknown;
29
- decisioning_metadata?: unknown;
30
- gap_metadata?: unknown;
31
- }
32
- interface RuleData {
33
- id: string;
34
- title: string;
35
- scope?: string;
36
- description?: string;
37
- wta?: string;
38
- wnta?: string;
39
- [key: string]: unknown;
40
- similarity?: number;
41
- summaryText?: string;
42
- variantType?: string;
43
- tierName?: string;
44
- analysis?: ComparisonAnalysis;
45
- isLoading?: boolean;
46
- sections?: {
47
- id?: string;
48
- title: string;
49
- content: string;
50
- subsections?: string[];
51
- relation?: string;
52
- score?: number;
53
- cognitiveRelevanceScore?: number;
54
- cognitiveData?: CognitiveDecisioningEntry;
55
- }[];
56
- }
57
- export interface CognitiveCompareProps {
58
- variants?: RuleData[];
59
- treeData?: Record<string, any> | null;
60
- comparisonConfig?: Partial<ComparisonConfig>;
61
- fieldConfig?: {
62
- key: string;
63
- label: string;
64
- analysisKey: string;
65
- }[];
66
- onSelectVariant: (variant: RuleData) => void;
67
- onAddAsVariant?: () => void;
68
- onSkip?: () => void;
69
- onBack?: () => void;
70
- targetVariantId?: string | null;
71
- highlightedField?: string | null;
72
- onBadgeClick?: (id: string, isOpen: boolean) => void;
73
- activeBadgeId?: string | null;
74
- }
75
- type StyleVariant = {
76
- bg: string;
77
- border: string;
78
- badgeBg: string;
79
- badgeBorder: string;
80
- badgeText: string;
81
- highlightBg: string;
82
- label: string;
83
- };
84
- export type FieldConfigItem = {
85
- key: string;
86
- label: string;
87
- analysisKey: string;
88
- };
89
- export type RelationStyleToken = Omit<StyleVariant, "label">;
90
- export type ComparisonConfig = {
91
- fields: FieldConfigItem[];
92
- thresholds: {
93
- exact: number;
94
- high: number;
95
- medium: number;
96
- };
97
- relationStyles: {
98
- noContent: RelationStyleToken;
99
- high: RelationStyleToken;
100
- exact: RelationStyleToken;
101
- medium: RelationStyleToken;
102
- low: RelationStyleToken;
103
- };
104
- };
105
- export declare const DEFAULT_FIELD_CONFIG: FieldConfigItem[];
106
- export declare const DEFAULT_COMPARISON_CONFIG: ComparisonConfig;
107
- declare const CognitiveCompare: ({ variants, treeData, comparisonConfig, onSelectVariant, targetVariantId, highlightedField, }: CognitiveCompareProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { CognitiveCompareProps } from "./CognitiveCompareTypes";
2
+ import { SHARED_MARKDOWN_STYLES } from "./CognitiveCompareConfig";
3
+ declare const CognitiveCompare: ({ componentHeaderText, treeData, comparisonConfig, leftColumnTitleText, rightColumnTitleText, markdownStyles, }: CognitiveCompareProps) => import("react/jsx-runtime").JSX.Element;
4
+ export { SHARED_MARKDOWN_STYLES };
108
5
  export default CognitiveCompare;
109
6
  //# sourceMappingURL=CognitiveCompare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAIL,qBAAqB,EAKtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA0MlC,QAAA,MAAM,gBAAgB,oHAOnB,qBAAqB,4CAsxCvB,CAAC;AACF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { ComparisonConfig, FieldConfigItem } from "./CognitiveCompareTypes";
2
+ export declare const DEFAULT_FIELD_CONFIG: FieldConfigItem[];
3
+ export declare const DEFAULT_COMPARISON_CONFIG: ComparisonConfig;
4
+ export declare const SHARED_MARKDOWN_STYLES: {
5
+ fontSize: string;
6
+ color: string;
7
+ lineHeight: number;
8
+ wordBreak: string;
9
+ overflowWrap: string;
10
+ overflow: string;
11
+ "& p": {
12
+ mt: number;
13
+ mb: number;
14
+ };
15
+ "& p:last-child": {
16
+ mb: number;
17
+ };
18
+ "& ul": {
19
+ mt: number;
20
+ mb: number;
21
+ pl: number;
22
+ listStyleType: string;
23
+ };
24
+ "& ol": {
25
+ mt: number;
26
+ mb: number;
27
+ pl: number;
28
+ listStyleType: string;
29
+ };
30
+ "& li": {
31
+ mb: number;
32
+ };
33
+ "& strong": {
34
+ fontWeight: number;
35
+ };
36
+ "& code": {
37
+ whiteSpace: string;
38
+ wordBreak: string;
39
+ };
40
+ };
41
+ //# sourceMappingURL=CognitiveCompareConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveCompareConfig.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompareConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE5E,eAAO,MAAM,oBAAoB,EAAE,eAAe,EAGjD,CAAC;AACF,eAAO,MAAM,yBAAyB,EAAE,gBA6CvC,CAAC;AAmBF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAclC,CAAC"}
@@ -61,7 +61,7 @@ export type ProposedRuleData = {
61
61
  sections?: Record<string, unknown>[];
62
62
  };
63
63
  export interface CognitiveCompareProps {
64
- variants?: RuleData[];
64
+ componentHeaderText?: string;
65
65
  treeData?: Record<string, any> | null;
66
66
  comparisonConfig?: Partial<ComparisonConfig>;
67
67
  fieldConfig?: {
@@ -69,14 +69,12 @@ export interface CognitiveCompareProps {
69
69
  label: string;
70
70
  analysisKey: string;
71
71
  }[];
72
- onSelectVariant: (variant: RuleData) => void;
73
- onAddAsVariant?: () => void;
74
- onSkip?: () => void;
75
- onBack?: () => void;
76
- targetVariantId?: string | null;
77
72
  highlightedField?: string | null;
78
73
  onBadgeClick?: (id: string, isOpen: boolean) => void;
79
74
  activeBadgeId?: string | null;
75
+ leftColumnTitleText?: string;
76
+ rightColumnTitleText?: string;
77
+ markdownStyles?: React.CSSProperties & Record<string, any>;
80
78
  }
81
79
  export type StyleVariant = {
82
80
  bg: string;
@@ -108,13 +106,6 @@ export type ComparisonConfig = {
108
106
  low: RelationStyleToken;
109
107
  };
110
108
  };
111
- export interface FieldProps {
112
- label: string;
113
- content: unknown | unknown[];
114
- highlights?: string[];
115
- styleVariant: StyleVariant;
116
- isHighlighted?: boolean;
117
- }
118
109
  export interface PopupPosition {
119
110
  top: number;
120
111
  left: number;
@@ -137,5 +128,16 @@ export interface CognitivePopupProps {
137
128
  baseLayoutRef?: any;
138
129
  popupRef: React.RefObject<HTMLDivElement>;
139
130
  position: PopupPosition | null;
131
+ markdownStyles?: React.CSSProperties & Record<string, any>;
140
132
  }
133
+ export type SectionBlock = {
134
+ id?: string;
135
+ title: string;
136
+ content: string;
137
+ subsections?: string[];
138
+ relation?: string;
139
+ score?: number;
140
+ cognitiveRelevanceScore?: number;
141
+ cognitiveData?: CognitiveDecisioningEntry;
142
+ };
141
143
  //# sourceMappingURL=CognitiveCompareTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompareTypes.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompareTypes.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"CognitiveCompareTypes.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompareTypes.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,33 @@
1
+ import { ComparisonConfig, StyleVariant } from "./CognitiveCompareTypes";
2
+ export declare const safeStringify: (val: unknown) => string;
3
+ export declare const hasValue: (val: unknown) => boolean;
4
+ export declare const getSideData: (node: any, sideIndex: "0" | "1", indexMap: Record<string, string>) => {
5
+ title: string;
6
+ content: string;
7
+ };
8
+ export declare const getRationale: (node: any) => {
9
+ cognitiveData: {
10
+ decisioning: never[];
11
+ gap: never[];
12
+ relevance_score: number;
13
+ isMissingRationale: boolean;
14
+ };
15
+ score: number;
16
+ relation: string;
17
+ } | {
18
+ cognitiveData: {
19
+ decisioning: any;
20
+ gap: any;
21
+ relevance_score: number;
22
+ isMissingRationale?: undefined;
23
+ };
24
+ score: number;
25
+ relation: string;
26
+ };
27
+ export declare const formatRelationToLabel: (relation: string) => string;
28
+ export declare const getStyleForRelation: (score: number, relation: string, hasContent: boolean, config: ComparisonConfig) => StyleVariant | null;
29
+ export declare const cognitiveScoreToRelation: (relevanceScore: number) => {
30
+ score: number;
31
+ relation: string;
32
+ };
33
+ //# sourceMappingURL=CognitiveComparehelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,MAM5C,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAKvC,CAAC;AAGF,eAAO,MAAM,WAAW,SAChB,GAAG,aACE,GAAG,GAAG,GAAG,YACV,OAAO,MAAM,EAAE,MAAM,CAAC;;;CAQjC,CAAC;AAGF,eAAO,MAAM,YAAY,SAAU,GAAG;;;;;;;;;;;;;;;;;;CAyBrC,CAAC;AAGF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAOxD,CAAC;AAEF,eAAO,MAAM,mBAAmB,UACvB,MAAM,YACH,MAAM,cACJ,OAAO,UACX,gBAAgB,KACvB,YAAY,GAAG,IA+BjB,CAAC;AAGF,eAAO,MAAM,wBAAwB,mBACnB,MAAM,KACrB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAMnC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { CognitivePopupProps } from "./CognitiveCompareTypes";
3
+ declare const CognitivePopup: React.FC<CognitivePopupProps>;
4
+ export default CognitivePopup;
5
+ //# sourceMappingURL=CognitivePopup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitivePopup.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitivePopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAM5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAS9D,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAsejD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import type { INonReasoningSource, NonWebReasoningIconsConfig } from "./CognitiveInternalgptReasoningComponent";
3
+ export type CognitiveInternalgptCoreProps = {
4
+ item: INonReasoningSource;
5
+ headerTitle: string;
6
+ index?: number;
7
+ iconsConfig?: NonWebReasoningIconsConfig;
8
+ DocumentTitle?: string;
9
+ previewCallback?: () => void;
10
+ bodyHeight?: string;
11
+ disableMaximize?: boolean;
12
+ };
13
+ declare const CognitiveInternalgptCoreComponent: React.FC<CognitiveInternalgptCoreProps>;
14
+ export default CognitiveInternalgptCoreComponent;
15
+ //# sourceMappingURL=CognitiveInternalgptCoreComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CognitiveInternalgptCoreComponent.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAgBhH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,mBAAmB,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,0BAA0B,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAiBF,QAAA,MAAM,iCAAiC,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAoS9E,CAAC;AAEF,eAAe,iCAAiC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",