@viswa-test/test-citation 0.0.17 → 0.0.18

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.
@@ -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"}},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){var r=100*(n||0),s=o.thresholds,l=o.relationStyles;if(!t)return null;var a=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(i),c=(i||"").toLowerCase();return c.includes("no_deviation")?e.__assign(e.__assign({},l.low),{label:a}):c.includes("deviation")||c.includes("high_risk")||c.includes("critical")?e.__assign(e.__assign({},l.high),{label:a}):r>=s.exact?e.__assign(e.__assign({},l.exact),{label:a}):r>=s.high?e.__assign(e.__assign({},l.high),{label:a}):r>=s.medium?e.__assign(e.__assign({},l.medium),{label:a}):e.__assign(e.__assign({},l.low),{label:a})},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)})},_=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)})}))]}))})),m=12,b=10,y=function(r){var l,a,c,d,g,h=r.open,f=r.onClose,v=r.sectionTitle,_=r.referenceSectionTitle,m=r.cognitiveData,y=r.relevanceScore,F=r.anchorEl,w=r.badgeStyle,B=r.popupRef,j=r.position,E=i.useState("association"),C=E[0],S=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||!m)return null;var k=null!==(a=null!==(l=m.relevance_score)&&void 0!==l?l:y)&&void 0!==a?a:0,R=m.decisioning,A=Array.isArray(R)?R:"string"==typeof R&&R.trim()?[R]:[],T=m.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:_||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:_||"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"===C?"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=C===i,r="deviation"===i?"Deviation Analysis":"Association Logic";return n.jsx(t.Box,e.__assign({onClick:function(){return S(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"===C?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:[A.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:A.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===A.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)||"")}},C=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:"not_defined"};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:t>=70?"no_deviation":"deviation"}}(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:{}}}}]}},S={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,R=r.targetVariantId,A=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}),V=P[0],N=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},[V.sectionIdx,V.open]);var X=i.useCallback(function(){var e;if(V.anchorEl&&V.refSectionTitle){var n=V.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-m,r=n.top-12-m,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(m,Math.min(u,window.innerWidth-t-m)),g=Math.max(14,Math.min(d-x,t-b-4));O({top:c,left:x,arrowLeft:g,openAbove:s,maxHeight:l})}},[V.anchorEl,V.refSectionTitle]);i.useEffect(function(){if(V.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()}}},[V.open,X]),i.useEffect(function(){var n=K.current;if(n&&V.open){var i=function(n){q.current&&q.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),O(null),N(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})}}},[V.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=C(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(R||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(R&&oe(R),de(null!=A?A:null),A){var e=setTimeout(function(){return de(null)},6e3);return function(){return clearTimeout(e)}}},[R,A]);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||S,_e=g(Z.title)||"Uploaded Contract",me=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,Ce=i.useRef({}),Se=function(e){return Ce.current[e]||(Ce.current[e]=d.default.createRef()),Ce.current[e]};i.useEffect(function(){!te&&!R&&he.length>0&&!he[0].isLoading&&oe(he[0].id)},[he,te,R]);var De=i.useRef(null),ke=i.useRef(null),Re=i.useRef(null),Ae=i.useState([]),Te=Ae[0],Ie=Ae[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],Ve=qe[1];i.useEffect(function(){var e=U.current;if(e){var n=function(){Oe(e.scrollLeft>0),Ve(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 Ne=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({});Ne.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:"no_deviation"};return f(x.score,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,h="number"==typeof p?p:d.score;return f(h,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=[];Ne.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&&Re.current){var _=ke.current.getBoundingClientRect(),m=Re.current.getBoundingClientRect(),b=(_.top+_.height/2-t.top+m.top+m.height/2-t.top)/2;Le({x1:_.right-t.left,x2:m.left-t.left,y:b})}else Le(null)}catch(e){console.error("Line render safe fail: ",e)}finally{Y.current=!1}}},[Ne,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,Ne,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:[V.open&&n.jsx(y,{open:V.open,popupRef:q,position:M,onClose:function(){O(null),N(function(n){return e.__assign(e.__assign({},n),{open:!1})})},sectionTitle:V.sectionTitle,referenceSectionTitle:V.refSectionTitle,cognitiveData:V.cognitiveData,anchorEl:V.anchorEl,sectionAnchorEl:V.sectionAnchorEl,scrollContainerEl:K.current,badgeStyle:V.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(),V.open&&V.sectionIdx===i.sectionIdx)return O(null),void N(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=Ce.current[t])||void 0===r?void 0:r.current)&&void 0!==s?s:null;N({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)}},{children:[i.hasCognitive&&void 0!==i.sectionIdx&&n.jsx(t.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",px:"4px",ml:"2px",color:i.style.badgeText,transition:"background 0.15s"}},{children:n.jsx("div",e.__assign({style:{width:"13px",height:"13px",display:"flex",alignItems:"center",marginRight:"2px"}},{children:n.jsx(l.ButtonCognitiveIcon,{})}))})),V.open&&V.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:_e}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Ne.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(_,{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:Se(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:Re,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:me}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Ne.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(_,{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("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"}},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){var r=100*(n||0),s=o.thresholds,l=o.relationStyles;if(!t)return null;var a=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(i),c=(i||"").toLowerCase();return c.includes("no_deviation")?e.__assign(e.__assign({},l.low),{label:a}):c.includes("deviation")||c.includes("high_risk")||c.includes("critical")?e.__assign(e.__assign({},l.high),{label:a}):r>=s.exact?e.__assign(e.__assign({},l.exact),{label:a}):r>=s.high?e.__assign(e.__assign({},l.high),{label:a}):r>=s.medium?e.__assign(e.__assign({},l.medium),{label:a}):e.__assign(e.__assign({},l.low),{label:a})},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)})},_=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)})}))]}))})),m=12,b=10,y=function(r){var l,a,c,d,g,h=r.open,f=r.onClose,v=r.sectionTitle,_=r.referenceSectionTitle,m=r.cognitiveData,y=r.relevanceScore,F=r.anchorEl,w=r.badgeStyle,B=r.popupRef,j=r.position,E=i.useState("association"),C=E[0],S=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||!m)return null;var k=null!==(a=null!==(l=m.relevance_score)&&void 0!==l?l:y)&&void 0!==a?a:0,R=m.decisioning,A=Array.isArray(R)?R:"string"==typeof R&&R.trim()?[R]:[],T=m.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:_||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:_||"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"===C?"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=C===i,r="deviation"===i?"Deviation Analysis":"Association Logic";return n.jsx(t.Box,e.__assign({onClick:function(){return S(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"===C?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:[A.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:A.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===A.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)||"")}},C=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:"not_defined"};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:t>=70?"no_deviation":"deviation"}}(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:{}}}}]}},S={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,R=r.targetVariantId,A=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}),V=P[0],N=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},[V.sectionIdx,V.open]);var X=i.useCallback(function(){var e;if(V.anchorEl&&V.refSectionTitle){var n=V.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-m,r=n.top-12-m,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(m,Math.min(u,window.innerWidth-t-m)),g=Math.max(14,Math.min(d-x,t-b-4));O({top:c,left:x,arrowLeft:g,openAbove:s,maxHeight:l})}},[V.anchorEl,V.refSectionTitle]);i.useEffect(function(){if(V.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()}}},[V.open,X]),i.useEffect(function(){var n=K.current;if(n&&V.open){var i=function(n){q.current&&q.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),O(null),N(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})}}},[V.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=C(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(R||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(R&&oe(R),de(null!=A?A:null),A){var e=setTimeout(function(){return de(null)},6e3);return function(){return clearTimeout(e)}}},[R,A]);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||S,_e=g(Z.title)||"Uploaded Contract",me=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,Ce=i.useRef({}),Se=function(e){return Ce.current[e]||(Ce.current[e]=d.default.createRef()),Ce.current[e]};i.useEffect(function(){!te&&!R&&he.length>0&&!he[0].isLoading&&oe(he[0].id)},[he,te,R]);var De=i.useRef(null),ke=i.useRef(null),Re=i.useRef(null),Ae=i.useState([]),Te=Ae[0],Ie=Ae[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],Ve=qe[1];i.useEffect(function(){var e=U.current;if(e){var n=function(){Oe(e.scrollLeft>0),Ve(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 Ne=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({});Ne.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:"no_deviation"};return f(x.score,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,h="number"==typeof p?p:d.score;return f(h,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=[];Ne.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&&Re.current){var _=ke.current.getBoundingClientRect(),m=Re.current.getBoundingClientRect(),b=(_.top+_.height/2-t.top+m.top+m.height/2-t.top)/2;Le({x1:_.right-t.left,x2:m.left-t.left,y:b})}else Le(null)}catch(e){console.error("Line render safe fail: ",e)}finally{Y.current=!1}}},[Ne,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,Ne,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:[V.open&&n.jsx(y,{open:V.open,popupRef:q,position:M,onClose:function(){O(null),N(function(n){return e.__assign(e.__assign({},n),{open:!1})})},sectionTitle:V.sectionTitle,referenceSectionTitle:V.refSectionTitle,cognitiveData:V.cognitiveData,anchorEl:V.anchorEl,sectionAnchorEl:V.sectionAnchorEl,scrollContainerEl:K.current,badgeStyle:V.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(),V.open&&V.sectionIdx===i.sectionIdx)return O(null),void N(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=Ce.current[t])||void 0===r?void 0:r.current)&&void 0!==s?s:null;N({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,{})}))})),V.open&&V.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:_e}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Ne.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(_,{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:Se(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:Re,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:me}))})),n.jsxs(t.Box,e.__assign({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[Ne.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(_,{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())})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as i,jsx as t,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"}},_=function(e){return e?A(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(o.Fragment,{children:e},n)}):null},I=function(n,i,t,r){var o=100*(n||0),l=r.thresholds,a=r.relationStyles;if(!t)return null;var c=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(i),s=(i||"").toLowerCase();return s.includes("no_deviation")?e(e({},a.low),{label:c}):s.includes("deviation")||s.includes("high_risk")||s.includes("critical")?e(e({},a.high),{label:c}):o>=l.exact?e(e({},a.exact),{label:c}):o>=l.high?e(e({},a.high),{label:c}):o>=l.medium?e(e({},a.medium),{label:c}):e(e({},a.low),{label:c})},z=function(n,i,r){if(!n)return null;if(!i||0===i.length)return _(n);var l=i.filter(function(e){return e&&"string"==typeof e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===l.length)return _(n);var a=new RegExp("(".concat(l.join("|"),")"),"gi");return n.split(a).map(function(n,l){return i.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===n.toLowerCase()})?t(u,e({component:"span",sx:{bgcolor:r.highlightBg,borderRadius:"2px",px:"2px"}},{children:_(n)}),l):t(o.Fragment,{children:_(n)},l)})},W=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 i(u,e({sx:{mb:1.5}},{children:[t(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:o})),t(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:t(u,{children:z(x,c,s)})}))]}))})),T=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,_=l("association"),I=_[0],z=_[1],W=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 T=null!==(c=null!==(o=y.relevance_score)&&void 0!==o?o:F)&&void 0!==c?c:0,H=y.decisioning,j=Array.isArray(H)?H:"string"==typeof H&&H.trim()?[H]:[],M=y.gap,O=Array.isArray(M)?M:"string"==typeof M&&M.trim()?[M]:[],P=null!==(d=null==A?void 0:A.arrowLeft)&&void 0!==d?d:60,V=i(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(W.border),boxShadow:"0px 8px 32px ".concat(W.shadow,", 0px 0px 0px 3px ").concat(W.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?i(r,{children:[t(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(W.border),zIndex:1}}),t(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}})]}):i(r,{children:[t(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(W.border),zIndex:1}}),t(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}})]})),i(u,e({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[i(u,e({sx:{flex:1,minWidth:0}},{children:[i(p,e({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[t(u,e({component:"span",title:m,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:m})),t(u,e({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),t(u,e({component:"span",title:b||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:b||"Reference Section"}))]})),t(u,e({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:t(p,e({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"deviation"===I?"Why this is a deviation?":"Why these sections are paired?"}))}))]})),i(u,e({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[i(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:[t(D,{}),"Decision Strength ",T,"%"]})),t(f,e({onClick:v,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:t(C,{size:22})}))]}))]})),t(u,e({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(n){var i=I===n;return t(u,e({onClick:function(){return z(n)},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"===n?"Deviation Analysis":"Association Logic"}),n)})})),t(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(W.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:W.border},scrollbarWidth:"thin",scrollbarColor:"".concat(W.border,"55 transparent")}},{children:"deviation"===I?i(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[t(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),t(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."}))]})):i(r,{children:[j.length>0&&i(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[t(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:t(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),t(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:t(u,e({sx:{display:"flex",flexDirection:"column"}},{children:t(p,e({component:"div",sx:e({},R)},{children:t(k,{children:j.join("\n\n")})}))}))}))]})),O.length>0&&i(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[t(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:t(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),t(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:t(u,e({sx:{display:"flex",flexDirection:"column"}},{children:t(p,e({component:"div",sx:e({},R)},{children:t(k,{children:O.join("\n\n")})}))}))}))]})),0===j.length&&0===O.length&&t(u,e({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:t(p,e({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return S.createPortal(V,document.body)},j=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 i(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:[t(u,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:r.isLoading?t(h,{variant:"rounded",width:80,height:20}):i(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"]}))})),i(u,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[t(u,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:t(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?i(u,{children:[t(h,{width:"90%"}),t(h,{width:"60%"})]}):i(u,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[t(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&&i(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:[t("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:t(B,{})})),t(y,{size:12,style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))}),M=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],O={fields:M,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,i){var t,r=i[n],o=null===(t=null==e?void 0:e.comparison_inputs)||void 0===t?void 0:t[r];return{title:A((null==o?void 0:o.title)||""),content:A((null==o?void 0:o.content)||"")}},K=function(n){var i,t,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(i){var t=n[i];if(t&&!1!==t.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"not_defined"};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:t>=70?"no_deviation":"deviation"}}(t),o=V(t,"0",s),c=V(t,"1",s),d=o.title.trim()||o.content.trim(),p=c.title.trim()||c.content.trim();l.push(e({id:i,title:d?o.title:"",content:d?o.content:"",subsections:[]},d?r:{score:void 0,relation:"not_defined"})),a.push(e({id:i,title:p?c.title:"",content:p?c.content:"",subsections:[]},p?r:{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[s[0]])||void 0===t?void 0:t.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:{}}}}]}},N={id:"",title:""},q=function(r){var h,C,S,D=r.variants,z=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],ie=ee[1],te=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(),i=(null===(e=null==te?void 0:te.current)||void 0===e?void 0:e.offsetHeight)||0,t=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-T,o=n.top-12-T,l=r<i&&o>r;null!==ue.current?!0===ue.current&&(l=o>=i||o>=r):l=!(r>=i||r>=o),ue.current=l;var a=l?o:r,c=Math.min(i||9999,a),s=l?n.top-12-c:n.bottom+12,d=n.left+n.width/2,u=d-t/2,p=Math.max(T,Math.min(u,window.innerWidth-t-T)),h=Math.max(14,Math.min(d-p,t-L-4));ie({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 te.current&&(n=new ResizeObserver(function(){e=requestAnimationFrame(pe)})).observe(te.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 i=function(n){te.current&&te.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),ie(null),le(function(n){return e(e({},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})}}},[oe.open]);var he=a(function(){var n,i,t,r,o,l,a,c,s,d,u,p;return{fields:null!==(n=null==q?void 0:q.fields)&&void 0!==n?n:M,thresholds:{high:null!==(t=null===(i=null==q?void 0:q.thresholds)||void 0===i?void 0:i.high)&&void 0!==t?t: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=K(V);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:z||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:z||[],parseError:null}},[V,z]),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"})},_e=a(function(){return n([],fe,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[fe]),Ie=a(function(){if(be){var e=String(be).trim();return fe.find(function(n){return n.id&&String(n.id).trim()===e})||_e[0]}return _e[0]||null},[be,fe,_e]);s(function(){be&&ae.current&&setTimeout(function(){var e=document.getElementById("variant-card-".concat(be.trim())),n=ae.current;if(e&&n){var i=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:i,behavior:"smooth"})}},150)},[be,_e]);var ze=Ie||N,We=A(ge.title)||"Uploaded Contract",Te=A(ze.title)||"Reference Template",Le=a(function(){return ge.sections||[]},[ge.sections]),He=a(function(){return ze.sections||[]},[ze.sections]),je=Le.length>0||He.length>0,Me=null==Ie?void 0:Ie.analysis,Oe=A(null===(C=null===(h=null==Me?void 0:Me.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==Ie?void 0:Ie.similarity)&&void 0!==S?S:0,Ke=c({}),Ne=function(e){return Ke.current[e]||(Ke.current[e]=o.createRef()),Ke.current[e]};s(function(){!be&&!Y&&_e.length>0&&!_e[0].isLoading&&ye(_e[0].id)},[_e,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)}}},[_e]);var an=a(function(){return he.fields.filter(function(e){var n=e.key;return(!je||"description"!==n)&&(P(ge[n])||P(ze[n]))})},[ge,ze,je,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,i,t,r,o,l,a,c,s,d=null===(n=null==Me?void 0:Me.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===(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===(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}},[Me]),xn=d(function(n){var i,t,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!==(i=null==r?void 0:r.cognitiveRelevanceScore)&&void 0!==i?i: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:"no_deviation"};return I(p.score,p.relation,!0,he)}var h=l?r.relation:a?o.relation:d.relation,x=null!==(t=null==r?void 0:r.score)&&void 0!==t?t:null==o?void 0:o.score,g="number"==typeof x?x:d.score;return I(g,h,!0,he)},[Le,He,he,hn]),gn=d(function(){var e,n,i;if(!de.current){de.current=!0;try{if(!qe.current)return;var t=qe.current.getBoundingClientRect(),r=[];an.forEach(function(e){var n=e.key,i=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(i),h=I(p.score,p.relation,p.hasContent,he);if(!h)return;var x=d.top+d.height/2-t.top;r.push({id:"field-".concat(n),x1:d.right-t.left,y1:x,x2:u.left-t.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-t.top+h.top+h.height/2-t.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-t.left,y1:x,x2:h.left-t.left,y2:x,style:f,sectionIdx:l,hasCognitive:!(!(null===(n=Le[l])||void 0===n?void 0:n.cognitiveData)&&!(null===(i=He[l])||void 0===i?void 0:i.cognitiveData))})}}}if($e(r),Ue.current&&Ye.current){var v=Ue.current.getBoundingClientRect(),m=Ye.current.getBoundingClientRect(),b=(v.top+v.height/2-t.top+m.top+m.height/2-t.top)/2;Ze({x1:v.right-t.left,x2:m.left-t.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,ze,Me,we,an,ke,Le,He,he,gn]);var fn=function(n,r,o,l){var a=!P(n.title)&&!P(n.content);return t(u,e({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:i(v,e({disableGutters:!0,expanded:!a&&!!ke[r],onChange:function(){return!a&&(n=r,void Ae(function(i){var t;return e(e({},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:[t(m,e({expandIcon:a?null:t(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:t(p,e({sx:{fontSize:"12px",color:a?"#94A3B8":"#19213D",fontWeight:a?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:_(n.title||"No Matching Section Found")}))})),!a&&i(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(p,e({component:"div",sx:R},{children:t(k,{children:A(n.content).replace(/\\n/g,"\n")})})),(n.subsections||[]).map(function(n,i){return t(u,e({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:t(p,e({component:"div",sx:R},{children:t(k,{children:A(n).replace(/\\n/g,"\n")})}))}),"".concat(o,"-sub-").concat(r,"-").concat(i))})]}))]}))}),"".concat(o,"-sec-").concat(r))};return i(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&&t(H,{open:oe.open,popupRef:te,position:ne,onClose:function(){ie(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}),t(x,e({open:!!$,autoHideDuration:8e3,onClose:function(){return X(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(g,e({onClose:function(){return X(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:$}))})),_e.length>1&&i(u,e({sx:{px:3,pb:.25},ref:Z},{children:[i(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[t(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),i(u,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[t(f,e({onClick:function(){return Re("left")},size:"small",disabled:!nn},{children:t(F,{size:18})})),t(f,e({onClick:function(){return Re("right")},size:"small",disabled:!on},{children:t(w,{size:18})}))]}))]})),t(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:_e.map(function(e){return t(j,{data:e,isSelected:(null==Ie?void 0:Ie.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)})}))]})),t(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:t(u,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:i(u,e({ref:qe,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[i("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[Qe&&i("g",{children:[t("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"}),t("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?i("g",{children:[t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1.5"}),t("foreignObject",e({x:o-75,y:n.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(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,i(u,e({onClick:function(i){if(i.stopPropagation(),oe.open&&oe.sectionIdx===n.sectionIdx)return ie(null),void le(function(n){return e(e({},n),{open:!1})});!function(e,n,i,t,r){var o,l;e.stopPropagation(),ie(null);var a=A(n.id)||A(i.id)||"",c=(a?Q[a]:null)||n.cognitiveData||i.cognitiveData||null,s=null!==(l=null===(o=Ke.current[t])||void 0===o?void 0:o.current)&&void 0!==l?l:null;le({open:!0,sectionTitle:n.title||"Section",refSectionTitle:i.title||"Reference Section",cognitiveData:c,anchorEl:e.currentTarget,sectionAnchorEl:s,badgeStyle:r||null,sectionIdx:t})}(i,Le[n.sectionIdx]||{title:"",content:""},He[n.sectionIdx]||{title:"",content:""},n.sectionIdx,n.style)}},{children:[n.hasCognitive&&void 0!==n.sectionIdx&&t(u,e({sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",px:"4px",ml:"2px",color:n.style.badgeText,transition:"background 0.15s"}},{children:t("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center",marginRight:"2px"}},{children:t(B,{})}))})),oe.open&&oe.sectionIdx===n.sectionIdx?t(E,{size:12,color:n.style.badgeText}):t(y,{size:12,color:n.style.badgeText})]}))]}))}))}))]},r):null})]})),i(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:[t(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:t(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:We}))})),i(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[an.map(function(e){var n=e.key,i=e.label,r=e.analysisKey,o=hn(r),l=ge[n],a=ze[n];if(!P(l)&&!P(a))return null;var c=I(o.score,o.relation,o.hasContent,he);return c?t(W,{ref:cn.current[n],label:i,content:l,highlights:o.highlightsA,styleVariant:c,isHighlighted:Se===r||Se===n},"left-".concat(n)):null}),je&&Le.map(function(e,n){return{section:e,idx:n}}).map(function(n){var i=n.section,r=n.idx;return t(u,e({ref:Ne(r)},{children:fn(i,r,"left",dn.current[r]||o.createRef())}),"left-row-".concat(r))})]}))]})),t(u,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:i(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:[t(u,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(B,{})})),Ve,"% Similarity",t(y,{size:11})]}))}))})),i(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:[t(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:t(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:Te}))})),i(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[an.map(function(e){var n=e.key,i=e.label,r=e.analysisKey,o=hn(r),l=ge[n],a=ze[n];if(!P(l)&&!P(a))return null;var c=I(o.score,o.relation,o.hasContent,he);return c?t(W,{ref:sn.current[n],label:i,content:a,highlights:o.highlightsB,styleVariant:c,isHighlighted:Se===r||Se===n},"right-".concat(n)):null}),je&&He.map(function(e,n){return{section:e,idx:n}}).map(function(e){var n=e.section,i=e.idx;return fn(n,i,"right",un.current[i]||o.createRef())})]}))]}))]}))}))}))]}))};export{O as DEFAULT_COMPARISON_CONFIG,M as DEFAULT_FIELD_CONFIG,q as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as i,jsx as t,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"}},I=function(e){return e?A(e).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(o.Fragment,{children:e},n)}):null},_=function(n,i,t,r){var o=100*(n||0),l=r.thresholds,a=r.relationStyles;if(!t)return null;var c=function(e){return e&&"string"==typeof e?e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" "):"Unknown"}(i),s=(i||"").toLowerCase();return s.includes("no_deviation")?e(e({},a.low),{label:c}):s.includes("deviation")||s.includes("high_risk")||s.includes("critical")?e(e({},a.high),{label:c}):o>=l.exact?e(e({},a.exact),{label:c}):o>=l.high?e(e({},a.high),{label:c}):o>=l.medium?e(e({},a.medium),{label:c}):e(e({},a.low),{label:c})},z=function(n,i,r){if(!n)return null;if(!i||0===i.length)return I(n);var l=i.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 i.some(function(e){return e&&"string"==typeof e&&e.toLowerCase()===n.toLowerCase()})?t(u,e({component:"span",sx:{bgcolor:r.highlightBg,borderRadius:"2px",px:"2px"}},{children:I(n)}),l):t(o.Fragment,{children:I(n)},l)})},W=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 i(u,e({sx:{mb:1.5}},{children:[t(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500}},{children:o})),t(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:t(u,{children:z(x,c,s)})}))]}))})),T=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"),_=I[0],z=I[1],W=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 T=null!==(c=null!==(o=y.relevance_score)&&void 0!==o?o:F)&&void 0!==c?c:0,H=y.decisioning,j=Array.isArray(H)?H:"string"==typeof H&&H.trim()?[H]:[],M=y.gap,O=Array.isArray(M)?M:"string"==typeof M&&M.trim()?[M]:[],P=null!==(d=null==A?void 0:A.arrowLeft)&&void 0!==d?d:60,V=i(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(W.border),boxShadow:"0px 8px 32px ".concat(W.shadow,", 0px 0px 0px 3px ").concat(W.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?i(r,{children:[t(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(W.border),zIndex:1}}),t(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}})]}):i(r,{children:[t(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(W.border),zIndex:1}}),t(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}})]})),i(u,e({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[i(u,e({sx:{flex:1,minWidth:0}},{children:[i(p,e({sx:{fontSize:"18px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden"}},{children:[t(u,e({component:"span",title:m,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:m})),t(u,e({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),t(u,e({component:"span",title:b||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0}},{children:b||"Reference Section"}))]})),t(u,e({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:t(p,e({sx:{fontSize:"13px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:"deviation"===_?"Why this is a deviation?":"Why these sections are paired?"}))}))]})),i(u,e({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[i(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:[t(D,{}),"Decision Strength ",T,"%"]})),t(f,e({onClick:v,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:t(C,{size:22})}))]}))]})),t(u,e({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:["deviation","association"].map(function(n){var i=_===n;return t(u,e({onClick:function(){return z(n)},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"===n?"Deviation Analysis":"Association Logic"}),n)})})),t(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(W.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:W.border},scrollbarWidth:"thin",scrollbarColor:"".concat(W.border,"55 transparent")}},{children:"deviation"===_?i(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD",p:2,display:"flex",flexDirection:"column",gap:1}},{children:[t(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054"}},{children:"Deviation Analysis"})),t(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."}))]})):i(r,{children:[j.length>0&&i(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[t(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:t(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Decision Making Factors"}))})),t(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:t(u,e({sx:{display:"flex",flexDirection:"column"}},{children:t(p,e({component:"div",sx:e({},R)},{children:t(k,{children:j.join("\n\n")})}))}))}))]})),O.length>0&&i(u,e({sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"}},{children:[t(u,e({sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"}},{children:t(p,e({sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25}},{children:"Gaps in Decision"}))})),t(u,e({sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95}},{children:t(u,e({sx:{display:"flex",flexDirection:"column"}},{children:t(p,e({component:"div",sx:e({},R)},{children:t(k,{children:O.join("\n\n")})}))}))}))]})),0===j.length&&0===O.length&&t(u,e({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:t(p,e({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]})}))]}));return S.createPortal(V,document.body)},j=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 i(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:[t(u,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:r.isLoading?t(h,{variant:"rounded",width:80,height:20}):i(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"]}))})),i(u,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[t(u,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:t(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?i(u,{children:[t(h,{width:"90%"}),t(h,{width:"60%"})]}):i(u,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[t(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&&i(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:[t("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:t(B,{})})),t(y,{size:12,style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}))]}))]}))]}))}),M=[{key:"title",label:"Title",analysisKey:"title"},{key:"description",label:"Description",analysisKey:"description"}],O={fields:M,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,i){var t,r=i[n],o=null===(t=null==e?void 0:e.comparison_inputs)||void 0===t?void 0:t[r];return{title:A((null==o?void 0:o.title)||""),content:A((null==o?void 0:o.content)||"")}},K=function(n){var i,t,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(i){var t=n[i];if(t&&!1!==t.display_node){var r=function(e){if(!e.mapping_rationale)return{score:void 0,relation:"not_defined"};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:t>=70?"no_deviation":"deviation"}}(t),o=V(t,"0",s),c=V(t,"1",s),d=o.title.trim()||o.content.trim(),p=c.title.trim()||c.content.trim();l.push(e({id:i,title:d?o.title:"",content:d?o.content:"",subsections:[]},d?r:{score:void 0,relation:"not_defined"})),a.push(e({id:i,title:p?c.title:"",content:p?c.content:"",subsections:[]},p?r:{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[s[0]])||void 0===t?void 0:t.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:{}}}}]}},N={id:"",title:""},q=function(r){var h,C,S,D=r.variants,z=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],ie=ee[1],te=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(),i=(null===(e=null==te?void 0:te.current)||void 0===e?void 0:e.offsetHeight)||0,t=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-T,o=n.top-12-T,l=r<i&&o>r;null!==ue.current?!0===ue.current&&(l=o>=i||o>=r):l=!(r>=i||r>=o),ue.current=l;var a=l?o:r,c=Math.min(i||9999,a),s=l?n.top-12-c:n.bottom+12,d=n.left+n.width/2,u=d-t/2,p=Math.max(T,Math.min(u,window.innerWidth-t-T)),h=Math.max(14,Math.min(d-p,t-L-4));ie({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 te.current&&(n=new ResizeObserver(function(){e=requestAnimationFrame(pe)})).observe(te.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 i=function(n){te.current&&te.current.contains(n.target)||(console.log("Scroll event detected on:",n.target,"- closing CognitivePopup"),ie(null),le(function(n){return e(e({},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})}}},[oe.open]);var he=a(function(){var n,i,t,r,o,l,a,c,s,d,u,p;return{fields:null!==(n=null==q?void 0:q.fields)&&void 0!==n?n:M,thresholds:{high:null!==(t=null===(i=null==q?void 0:q.thresholds)||void 0===i?void 0:i.high)&&void 0!==t?t: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=K(V);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:z||[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:z||[],parseError:null}},[V,z]),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]),_e=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 i=e.offsetLeft-n.offsetLeft-n.clientWidth/2+e.clientWidth/2;n.scrollTo({left:i,behavior:"smooth"})}},150)},[be,Ie]);var ze=_e||N,We=A(ge.title)||"Uploaded Contract",Te=A(ze.title)||"Reference Template",Le=a(function(){return ge.sections||[]},[ge.sections]),He=a(function(){return ze.sections||[]},[ze.sections]),je=Le.length>0||He.length>0,Me=null==_e?void 0:_e.analysis,Oe=A(null===(C=null===(h=null==Me?void 0:Me.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==_e?void 0:_e.similarity)&&void 0!==S?S:0,Ke=c({}),Ne=function(e){return Ke.current[e]||(Ke.current[e]=o.createRef()),Ke.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(!je||"description"!==n)&&(P(ge[n])||P(ze[n]))})},[ge,ze,je,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,i,t,r,o,l,a,c,s,d=null===(n=null==Me?void 0:Me.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===(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===(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}},[Me]),xn=d(function(n){var i,t,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!==(i=null==r?void 0:r.cognitiveRelevanceScore)&&void 0!==i?i: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:"no_deviation"};return _(p.score,p.relation,!0,he)}var h=l?r.relation:a?o.relation:d.relation,x=null!==(t=null==r?void 0:r.score)&&void 0!==t?t:null==o?void 0:o.score,g="number"==typeof x?x:d.score;return _(g,h,!0,he)},[Le,He,he,hn]),gn=d(function(){var e,n,i;if(!de.current){de.current=!0;try{if(!qe.current)return;var t=qe.current.getBoundingClientRect(),r=[];an.forEach(function(e){var n=e.key,i=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(i),h=_(p.score,p.relation,p.hasContent,he);if(!h)return;var x=d.top+d.height/2-t.top;r.push({id:"field-".concat(n),x1:d.right-t.left,y1:x,x2:u.left-t.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-t.top+h.top+h.height/2-t.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-t.left,y1:x,x2:h.left-t.left,y2:x,style:f,sectionIdx:l,hasCognitive:!(!(null===(n=Le[l])||void 0===n?void 0:n.cognitiveData)&&!(null===(i=He[l])||void 0===i?void 0:i.cognitiveData))})}}}if($e(r),Ue.current&&Ye.current){var v=Ue.current.getBoundingClientRect(),m=Ye.current.getBoundingClientRect(),b=(v.top+v.height/2-t.top+m.top+m.height/2-t.top)/2;Ze({x1:v.right-t.left,x2:m.left-t.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,ze,Me,we,an,ke,Le,He,he,gn]);var fn=function(n,r,o,l){var a=!P(n.title)&&!P(n.content);return t(u,e({ref:l,sx:{mb:1,minHeight:0,display:"flex",flexDirection:"column"}},{children:i(v,e({disableGutters:!0,expanded:!a&&!!ke[r],onChange:function(){return!a&&(n=r,void Ae(function(i){var t;return e(e({},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:[t(m,e({expandIcon:a?null:t(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:t(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&&i(b,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(p,e({component:"div",sx:R},{children:t(k,{children:A(n.content).replace(/\\n/g,"\n")})})),(n.subsections||[]).map(function(n,i){return t(u,e({sx:{mt:1,pt:1,borderTop:"1px solid #EEF2F7"}},{children:t(p,e({component:"div",sx:R},{children:t(k,{children:A(n).replace(/\\n/g,"\n")})}))}),"".concat(o,"-sub-").concat(r,"-").concat(i))})]}))]}))}),"".concat(o,"-sec-").concat(r))};return i(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&&t(H,{open:oe.open,popupRef:te,position:ne,onClose:function(){ie(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}),t(x,e({open:!!$,autoHideDuration:8e3,onClose:function(){return X(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(g,e({onClose:function(){return X(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:$}))})),Ie.length>1&&i(u,e({sx:{px:3,pb:.25},ref:Z},{children:[i(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[t(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),i(u,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[t(f,e({onClick:function(){return Re("left")},size:"small",disabled:!nn},{children:t(F,{size:18})})),t(f,e({onClick:function(){return Re("right")},size:"small",disabled:!on},{children:t(w,{size:18})}))]}))]})),t(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 t(j,{data:e,isSelected:(null==_e?void 0:_e.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)})}))]})),t(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:t(u,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:i(u,e({ref:qe,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[i("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:[Qe&&i("g",{children:[t("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"}),t("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?i("g",{children:[t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1.5"}),t("foreignObject",e({x:o-75,y:n.y1-14,width:"150",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(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,i(u,e({onClick:function(i){if(i.stopPropagation(),oe.open&&oe.sectionIdx===n.sectionIdx)return ie(null),void le(function(n){return e(e({},n),{open:!1})});!function(e,n,i,t,r){var o,l;e.stopPropagation(),ie(null);var a=A(n.id)||A(i.id)||"",c=(a?Q[a]:null)||n.cognitiveData||i.cognitiveData||null,s=null!==(l=null===(o=Ke.current[t])||void 0===o?void 0:o.current)&&void 0!==l?l:null;le({open:!0,sectionTitle:n.title||"Section",refSectionTitle:i.title||"Reference Section",cognitiveData:c,anchorEl:e.currentTarget,sectionAnchorEl:s,badgeStyle:r||null,sectionIdx:t})}(i,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&&t(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"center",color:n.style.badgeText}},{children:t("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:t(B,{})}))})),oe.open&&oe.sectionIdx===n.sectionIdx?t(E,{size:12,color:n.style.badgeText}):t(y,{size:12,color:n.style.badgeText})]}))]}))}))}))]},r):null})]})),i(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:[t(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:t(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:We}))})),i(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[an.map(function(e){var n=e.key,i=e.label,r=e.analysisKey,o=hn(r),l=ge[n],a=ze[n];if(!P(l)&&!P(a))return null;var c=_(o.score,o.relation,o.hasContent,he);return c?t(W,{ref:cn.current[n],label:i,content:l,highlights:o.highlightsA,styleVariant:c,isHighlighted:Se===r||Se===n},"left-".concat(n)):null}),je&&Le.map(function(e,n){return{section:e,idx:n}}).map(function(n){var i=n.section,r=n.idx;return t(u,e({ref:Ne(r)},{children:fn(i,r,"left",dn.current[r]||o.createRef())}),"left-row-".concat(r))})]}))]})),t(u,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(u,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:i(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:[t(u,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(B,{})})),Ve,"% Similarity",t(y,{size:11})]}))}))})),i(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:[t(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:t(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:Te}))})),i(u,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:[an.map(function(e){var n=e.key,i=e.label,r=e.analysisKey,o=hn(r),l=ge[n],a=ze[n];if(!P(l)&&!P(a))return null;var c=_(o.score,o.relation,o.hasContent,he);return c?t(W,{ref:sn.current[n],label:i,content:a,highlights:o.highlightsB,styleVariant:c,isHighlighted:Se===r||Se===n},"right-".concat(n)):null}),je&&He.map(function(e,n){return{section:e,idx:n}}).map(function(e){var n=e.section,i=e.idx;return fn(n,i,"right",un.current[i]||o.createRef())})]}))]}))]}))}))}))]}))};export{O as DEFAULT_COMPARISON_CONFIG,M as DEFAULT_FIELD_CONFIG,q as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAkDA,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;CACH;AAED,UAAU,kBAAkB;IAC1B,0BAA0B,EAAE;QAC1B,OAAO,EAAE;YACP,aAAa,EAAE,MAAM,CAAC;YACtB,eAAe,EAAE,MAAM,CAAC;SACzB,CAAC;QACF,MAAM,EAAE;YACN,CAAC,GAAG,EAAE,MAAM,GACR,uBAAuB,GACvB;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;aAAE,CAAC;SAC5D,CAAC;KACH,CAAC;CACH;AAED,UAAU,yBAAyB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,aAAa,CAAC,EAAE,yBAAyB,CAAC;KAC3C,EAAE,CAAC;CACL;AAQD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACtC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpE,eAAe,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,cAAc,EAAE;QACd,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,MAAM,EAAE,kBAAkB,CAAC;QAC3B,GAAG,EAAE,kBAAkB,CAAC;KACzB,CAAC;CACH,CAAC;AA+7BF,eAAO,MAAM,oBAAoB,EAAE,eAAe,EAGjD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBA6CvC,CAAC;AA4HF,QAAA,MAAM,gBAAgB,kGAWnB,qBAAqB,4CAg5CvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAkDA,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;CACH;AAED,UAAU,kBAAkB;IAC1B,0BAA0B,EAAE;QAC1B,OAAO,EAAE;YACP,aAAa,EAAE,MAAM,CAAC;YACtB,eAAe,EAAE,MAAM,CAAC;SACzB,CAAC;QACF,MAAM,EAAE;YACN,CAAC,GAAG,EAAE,MAAM,GACR,uBAAuB,GACvB;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;aAAE,CAAC;SAC5D,CAAC;KACH,CAAC;CACH;AAED,UAAU,yBAAyB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,aAAa,CAAC,EAAE,yBAAyB,CAAC;KAC3C,EAAE,CAAC;CACL;AAQD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACtC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpE,eAAe,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,cAAc,EAAE;QACd,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,MAAM,EAAE,kBAAkB,CAAC;QAC3B,GAAG,EAAE,kBAAkB,CAAC;KACzB,CAAC;CACH,CAAC;AA+7BF,eAAO,MAAM,oBAAoB,EAAE,eAAe,EAGjD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBA6CvC,CAAC;AA4HF,QAAA,MAAM,gBAAgB,kGAWnB,qBAAqB,4CAk5CvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",