@e-llm-studio/citation 0.0.231 → 0.0.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/cjs/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/helper.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/utils/buildComparisonRows.js +2 -0
- package/dist/cjs/features/CognitiveCompare/utils/buildComparisonRows.js.map +1 -0
- package/dist/features/ChatCitation/InternalChatCitationRenderer.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/helper.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/utils/buildComparisonRows.js +2 -0
- package/dist/features/CognitiveCompare/utils/buildComparisonRows.js.map +1 -0
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/Spbanalysispaneltest.d.ts +3 -0
- package/dist/types/src/Spbanalysispaneltest.d.ts.map +1 -0
- package/dist/types/src/features/ChatCitation/InternalChatCitationRenderer.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +13 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +1421 -898
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +2 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/utils/buildComparisonRows.d.ts +11 -0
- package/dist/types/src/features/CognitiveCompare/utils/buildComparisonRows.d.ts.map +1 -0
- package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts +22 -0
- package/dist/types/src/features/SPBAnalysisPanel/Cognitivereasoningpanel.d.ts.map +1 -0
- package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts +37 -0
- package/dist/types/src/features/SPBAnalysisPanel/DependencyGraph.d.ts.map +1 -0
- package/dist/types/src/features/SPBAnalysisPanel/Internaleditor.d.ts +11 -0
- package/dist/types/src/features/SPBAnalysisPanel/Internaleditor.d.ts.map +1 -0
- package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts +10 -0
- package/dist/types/src/features/SPBAnalysisPanel/Markdownrenderer.d.ts.map +1 -0
- package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts +39 -0
- package/dist/types/src/features/SPBAnalysisPanel/Spbanalysispanel.d.ts.map +1 -0
- package/dist/types/src/features/SPBAnalysisPanel/index.d.ts +10 -0
- package/dist/types/src/features/SPBAnalysisPanel/index.d.ts.map +1 -0
- package/package.json +7 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("lucide-react"),n=require("../../../assests/svg/ButtonCognitiveIcon.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("lucide-react"),n=require("../../../assests/svg/ButtonCognitiveIcon.js"),o=require("../CognitiveComparehelpers.js"),s=require("../CognitiveCompareConstants.js"),l=require("./ThreeDotsLoader.js"),a=require("./connectedLines.js"),r=require("@mui/material");exports.default=function(c){var d=c.svgContainerRef,u=c.svgDimensions,g=c.isResizing,p=c.overallConnector,v=c.rootDeviationStyle,x=c.lines,h=c.isSideBySide,y=c.activeSideBySideSection,b=c.isArrowVisible,f=c.maintainRelativeOrder,_=c.proposedSections,S=c.existingSections,m=c.cognitivePopup,j=c.activeBadgeId,C=c.closeCognitivePopup,B=c.setActiveBadgeId,I=c.openCognitivePopupFromState,A=c.buildSectionPopupState,R=c.connectedLines,P=c.pathRefs,D=c.isGuidelineMode,w=e.__spreadArray([],x,!0).sort(function(e,i){return Number(Boolean(i.isMappingContinuation))-Number(Boolean(e.isMappingContinuation))});return i.jsxs("svg",e.__assign({ref:d,style:{position:"absolute",top:0,left:0,width:u.width||"100%",height:u.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:g?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[p&&i.jsx("g",{children:i.jsx("line",{x1:p.x1,y1:p.y,x2:p.x2,y2:p.y,stroke:v.badgeBorder,strokeWidth:"1.5"})}),w.map(function(a){var c,d,u,g,p,v,x,R=a.x1+.5*(a.x2-a.x1),P=(a.y1+a.y2)/2,D=R;if("Not Defined"===a.style.label&&!a.hasCognitive)return null;if(a.isSubSection?h&&y===a.subSectionKeyPath&&b:h&&y===a.sectionIdx&&b)return null;if(f)return null;var w=a.isMappingContinuation?"M ".concat(D," ").concat(a.y1," L ").concat(D," ").concat(a.y2," L ").concat(a.x2," ").concat(a.y2):a.isSubSection?o.getBentArrowPath(a.x1,a.y1,a.x2,a.y2):"M ".concat(a.x1," ").concat(a.y1," L ").concat(a.x2," ").concat(a.y2),E=_[a.sectionIdx]||{title:"",content:""},O=S[null!==(c=a.targetRightIdx)&&void 0!==c?c:a.sectionIdx]||{title:"",content:""};if(a.isSubSection&&a.subSectionKeyPath){var M=a.subSectionKeyPath.includes(o.DEVIATION_BADGE_SEPARATOR)?a.subSectionKeyPath.split(o.DEVIATION_BADGE_SEPARATOR):[],T=M[2]||a.subSectionKeyPath,q=M[3]||T,L=T.split("-").map(Number),N=q.split("-").map(Number),k=null,K=null;L.length>0&&(k=_[L[0]]||null),N.length>0&&(K=S[N[0]]||null);for(var z=(null==k?void 0:k.title)||"",G=(null==K?void 0:K.title)||"",V=1;V<L.length;V+=1)(null==k?void 0:k.subsections)&&(k=k.subsections[L[V]]||null);for(V=1;V<N.length;V+=1)(null==K?void 0:K.subsections)&&(K=K.subsections[N[V]]||null);k&&(E=e.__assign(e.__assign({},k),{title:z||k.title})),K&&(O=e.__assign(e.__assign({},K),{title:G||K.title}))}var F=!(null===(d=E.cognitiveData)||void 0===d?void 0:d.isMissingRationale)||Boolean(null===(g=null===(u=E.cognitiveData)||void 0===u?void 0:u.decisioning)||void 0===g?void 0:g.length),W=(null===(x=null===(v=null===(p=E.evaluationResult)||void 0===p?void 0:p.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===x?void 0:x.length)||!1,U=F||W;return i.jsxs("g",{children:[i.jsx("path",{d:w,fill:"none",stroke:a.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),!a.isMappingContinuation&&i.jsx("foreignObject",e.__assign({x:R-100,y:P-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i.jsx(r.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i.jsxs(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),U&&(m.open&&j===a.id?C():(B(a.id),I(A(e.currentTarget,E,O,a.sectionIdx,!1,a.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.style.badgeBg,color:a.style.badgeText,border:"1px solid ".concat(a.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:U?"pointer":"default"}},{children:[a.style.badgeText===s.DEFAULT_DEVIAION_COLOR&&null==a.style.label?i.jsx(l.default,{color:a.style.badgeText}):null==a.style.label?null:"0"===String(a.style.label)?"Same":a.style.label,i.jsx(r.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i.jsx(n.ButtonCognitiveIcon,{})})),U&&i.jsx(t.ChevronDown,{size:11,style:{transform:m.open&&j===a.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},a.id)}),i.jsx(a.default,{maintainRelativeOrder:f,connectedLines:R,pathRefs:P,isGuidelineMode:D})]}))};
|
|
2
2
|
//# sourceMappingURL=SvgConnectors.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(o,r,a,s,d,l){var u,v;void 0===d&&(d=!0);var c="string"==typeof a?a:JSON.stringify(a||{}),f=Boolean(l&&(null===(v=null===(u=l.data)||void 0===u?void 0:u.artifactData)||void 0===v?void 0:v.userStorySnapshot)),p=e.useMemo(function(){var e;if(!o||0===Object.keys(o).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var i=JSON.parse(c);try{var a=o.nodes||o,s=[],u=[],v=o.base_root_id,p=o.input_index_map||{0:"left",1:"right"},_=o[v]||a[v];if(!_||!1===_.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var I=o.content_mapping||{},g=function(n){return o[n]||a[n]},h=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),s={},l={},u=null;return a.forEach(function(n){var r,a,d,v,c,f=e[n];if(f&&"object"==typeof f){u||(u=f);var _=!(null==f?void 0:f.status)||"pending"===f.status,I=function(n){var e,t=(null===(e=null==f?void 0:f.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==f?void 0:f.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},g=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},h=_?g((null===(a=null==f?void 0:f.deviation_highlights)||void 0===a?void 0:a[i])||(null===(d=null==f?void 0:f.deviation_highlights)||void 0===d?void 0:d[p[0]]),I(i),I(p[0])):[],m=_?g((null===(v=null==f?void 0:f.deviation_highlights)||void 0===v?void 0:v[o])||(null===(c=null==f?void 0:f.deviation_highlights)||void 0===c?void 0:c[p[1]]),I(o),I(p[1])):[];s[n]=((r={})[p[0]]=h[0]||"",r[p[1]]=m[0]||"",r.deviation_summary=(null==f?void 0:f.deviation_summary)||"",r.deviation_title=null==f?void 0:f.deviation_title,r.deviation_impact=null==f?void 0:f.deviation_impact,r.deviation_explanation=null==f?void 0:f.deviation_explanation,r.evaluation_outputs=null==f?void 0:f.evaluation_outputs,r.cognitive_decisioning=null==f?void 0:f.cognitive_decisioning,r.deviation_highlights=null==f?void 0:f.deviation_highlights,r),l[n]=f}}),n.__assign(n.__assign({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:l})},m=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,d=n;s<d.length;s++){a(d[s])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},y=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=p[0],i=p[1];return e.length>0&&(t=e.includes(p[0])?p[0]:e[0],i=e.includes(p[1])?p[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},d=!1!==a.display_title,l=!1!==a.display_content,u=d?t.safeStringify(s.title||""):"",v=l?t.safeStringify(s.content||""):"",c=l?t.safeStringify(s.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:l,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},b=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},R=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},C=function(e,o){var r,a=g(e);if(!a||!1===a.display_node)return[];if(f&&"1"===o)return[];var s=y(a),d=s.nodeLeftId,l=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==i?void 0:i[e])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=h(v,d,l),_=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:e}):c,m=t.resolveComparisonInputItems(a,o,p,I).map(function(n){return x(e,n,_,u)});if(a.next){var b=Object.values(a.next).flatMap(function(n){return C(n,o)});m.forEach(function(n){var e=b.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:b})}return m};if(r){var S=function(e,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!e)return{refSections:a,baseSections:s};var d={},l={},u=-1,v=-1,c=function(a){var s=e[a],c=g(s);if(!c||!1===c.display_node)return"continue";var _=y(c),m=_.nodeLeftId,R=_.nodeRightId,C=t.getRationale(c),E=(null===(r=null==i?void 0:i[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=h(E,m,R),N=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,j=S(c.next,o+1),A=j.refSections,D=j.baseSections,M=t.resolveComparisonInputItems(c,"0",p,I).map(function(n){var e=x(s,n,N,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),P=[];if(!f){var k=t.resolveComparisonInputItems(c,"1",p,I);P=k.map(function(n){var e=x(s,n,N,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}M.forEach(function(n){P.forEach(function(e){var t,i,o,r,a,s,d,l;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(l=n.refContentIds)||void 0===l||l.push(e.contentId))})}),P.forEach(function(n){var e=A.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?b(d[t],n):n}),M.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?b(l[t],n):n})};for(var _ in e)c(_);return a=Object.values(d),s=Object.values(l),a.sort(R),s.sort(R),{refSections:a,baseSections:s}},E=S(_.next),O=E.refSections,N=E.baseSections;f||(u=m(O)),s=N}else _.next&&Object.values(_.next).forEach(function(n){var e=g(n);e&&!1!==e.display_node&&(s.push.apply(s,C(n,"0")),f||u.push.apply(u,C(n,"1")))}),f||(u=m(u));var j=t.getSideData(_,"0",p,I),A=t.getSideData(_,"1",p,I);return{activeProposed:{title:j.title||"Uploaded Contract",description:_.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:f?(null===(e=null==l?void 0:l.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines":A.title||"Reference Template",similarity:0,sections:u,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:_.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[o,r,c,d,l]),_=p.activeProposed,I=p.activeVariants,g=p.parseError,h=(null==I?void 0:I[0])||i,m=e.useMemo(function(){return(null==_?void 0:_.sections)||[]},[null==_?void 0:_.sections]),y=e.useMemo(function(){return h.sections||[]},[h.sections]),x=m.length>0||y.length>0,b=e.useMemo(function(){return s.fields.filter(function(n){var e=n.key;return(!x||"description"!==e)&&(t.hasValue(null==_?void 0:_[e])||t.hasValue(h[e]))})},[_,h,x,s.fields]),R=e.useMemo(function(){var n,e,i={},a={},s={},d=0,l=null===(n=null==o?void 0:o.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==o?void 0:o.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!r){var t="left"===e?m.indexOf(n):y.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:m.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var a=n.selfIndex,s=m.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(a)});if(s){var d=s.selfIndex,l=void 0!==d&&d>=0?d+1:m.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:l}}var u=void 0!==a&&a>=0?a+1:y.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,o,r,v,f,_){if(e&&function(n,e,i){var o;((null===(o=null==n?void 0:n.evaluationResults)||void 0===o?void 0:o.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(o){var r=(null==o?void 0:o.deviations)||{};Object.keys(r).sort().forEach(function(d){var v=r[d];if(v){var c=!t.isMissingStr(v[l]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==o?void 0:o.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(d);void 0===a[_]&&(void 0===s[e]&&(s[e]=1),a[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,r,v),e&&!f){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==o?void 0:o.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),a=c(null==o?void 0:o.subsections,t);p(t,i,a,r,v,!1,e||_)})};m.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,a=null;if(r){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];a=y.find(function(n){return n.selfIndex===s})}else a=y[m.indexOf(n)];p(n,n,a,i,o,!0,n)}),f||y.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(a).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(a).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:_,deviationParentRegistry:I}},[m,y,r,o,f]),C=R.parentDeviationRecord,S=R.registry,E=R.deviationParentRegistry;return{isGuidelineMode:f,activeProposed:_,activeVariants:I,existingRule:h,proposedSections:m,existingSections:y,visibleFields:b,parentDeviationRecord:C,deviationNumberRegistry:S,deviationParentRegistry:E,parseError:g}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i=require("../utils/buildComparisonRows.js"),o={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(r,a,s,d,l,u){var v,c;void 0===l&&(l=!0);var f="string"==typeof s?s:JSON.stringify(s||{}),p=Boolean(u&&(u.learnings_data||(null===(c=null===(v=u.data)||void 0===v?void 0:v.artifactData)||void 0===c?void 0:c.userStorySnapshot))),_=e.useMemo(function(){if(!r||0===Object.keys(r).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};var e=JSON.parse(f);try{var o=r.nodes||r,s=[],d=[],v=[],c=r.base_root_id,_=r.input_index_map||{0:"left",1:"right"},I=r[c]||o[c];if(!I||!1===I.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};var g=r.content_mapping||{},h=function(n){return r[n]||o[n]},m=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(l)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),s={},d={},u=null;return a.forEach(function(n){var r,a,l,v,c,f,p=e[n];if(p&&"object"==typeof p){u||(u=p);var I=!(null==p?void 0:p.status)||"pending"===p.status,g=(null==p?void 0:p.deviation_highlight)||(null===(a=null==p?void 0:p.web_search_answer)||void 0===a?void 0:a.deviation_highlight),h=function(n){var e,t=(null===(e=null==p?void 0:p.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==p?void 0:p.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},m=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},y=I?m((null===(l=null==p?void 0:p.deviation_highlights)||void 0===l?void 0:l[i])||(null===(v=null==p?void 0:p.deviation_highlights)||void 0===v?void 0:v[_[0]]),"string"==typeof g?[g]:[],h(i),h(_[0])):[],b=I?m((null===(c=null==p?void 0:p.deviation_highlights)||void 0===c?void 0:c[o])||(null===(f=null==p?void 0:p.deviation_highlights)||void 0===f?void 0:f[_[1]]),h(o),h(_[1])):[];s[n]=((r={})[_[0]]=y[0]||"",r[_[1]]=b[0]||"",r.deviation_summary=(null==p?void 0:p.deviation_summary)||"",r.deviation_title=null==p?void 0:p.deviation_title,r.deviation_impact=null==p?void 0:p.deviation_impact,r.deviation_explanation=null==p?void 0:p.deviation_explanation,r.evaluation_outputs=null==p?void 0:p.evaluation_outputs,r.cognitive_decisioning=null==p?void 0:p.cognitive_decisioning,r.deviation_highlights=null==p?void 0:p.deviation_highlights,r),d[n]=p}}),n.__assign(n.__assign({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:d})},y=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,d=n;s<d.length;s++){a(d[s])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},b=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=_[0],i=_[1];return e.length>0&&(t=e.includes(_[0])?_[0]:e[0],i=e.includes(_[1])?_[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},d=!1!==a.display_title,l=!1!==a.display_content,u=d?t.safeStringify(s.title||""):"",v=l?t.safeStringify(s.content||""):"",c=l?t.safeStringify(s.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:l,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},R=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},C=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},S=function(i,o){var r,a=h(i);if(!a||!1===a.display_node)return[];if(p&&"1"===o)return[];var s=b(a),d=s.nodeLeftId,l=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==e?void 0:e[i])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=m(v,d,l),f=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:i}):c,I=t.resolveComparisonInputItems(a,o,_,g).map(function(n){return x(i,n,f,u)});if(a.next){var y=Object.values(a.next).flatMap(function(n){return S(n,o)});I.forEach(function(n){var e=y.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:y})}return I};if(a){var E=function(i,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!i)return{refSections:a,baseSections:s};var d={},l={},u=-1,v=-1,c=function(a){var s=i[a],c=h(s);if(!c||!1===c.display_node)return"continue";var f=b(c),I=f.nodeLeftId,y=f.nodeRightId,C=t.getRationale(c),S=(null===(r=null==e?void 0:e[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=m(S,I,y),j=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,N=E(c.next,o+1),w=N.refSections,A=N.baseSections,D=t.resolveComparisonInputItems(c,"0",_,g).map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),k=[];if(!p){var M=t.resolveComparisonInputItems(c,"1",_,g);k=M.map(function(n){var e=x(s,n,j,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}D.forEach(function(n){k.forEach(function(e){var t,i,o,r,a,s,d,l;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(l=n.refContentIds)||void 0===l||l.push(e.contentId))})}),k.forEach(function(n){var e=w.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?R(d[t],n):n}),D.forEach(function(n){var e=A.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?R(l[t],n):n})};for(var f in i)c(f);return a=Object.values(d),s=Object.values(l),a.sort(C),s.sort(C),{refSections:a,baseSections:s}},O=E(I.next),j=O.refSections,N=O.baseSections;p||(d=y(j)),s=N}else I.next&&Object.values(I.next).forEach(function(n){var e=h(n);if(e&&!1!==e.display_node){var t=S(n,"0");if(p)s.push.apply(s,t);else{var o=y(S(n,"1"));v.push.apply(v,i.buildComparisonRows(n,t,o))}}}),p||(s=v.map(function(n){return n.left}),d=v.map(function(n){return n.right}));var w=t.getSideData(I,"0",_,g),A=t.getSideData(I,"1",_,g),D={title:w.title||"Uploaded Contract",description:I.decision_scope_description||"",sections:s},k={id:"tree-variant-1",title:p?function(){var n,e;if((null==u?void 0:u.learnings_data)&&Object.keys(u.learnings_data).length>0){var t=Object.keys(u.learnings_data)[0];return(null===(n=u.learnings_data[t])||void 0===n?void 0:n.title)||"Rulebook Guidelines"}return(null===(e=null==u?void 0:u.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines"}():A.title||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:I.decision_scope_description||""},fields:{}}}};return{activeProposed:D,activeVariants:[k],comparisonRows:v,parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[r,a,f,l,u]),I=_.activeProposed,g=_.activeVariants,h=_.comparisonRows,m=_.parseError,y=(null==g?void 0:g[0])||o,b=e.useMemo(function(){return(null==I?void 0:I.sections)||[]},[null==I?void 0:I.sections]),x=e.useMemo(function(){return y.sections||[]},[y.sections]),R=b.length>0||x.length>0,C=e.useMemo(function(){return d.fields.filter(function(n){var e=n.key;return(!R||"description"!==e)&&(t.hasValue(null==I?void 0:I[e])||t.hasValue(y[e]))})},[I,y,R,d.fields]),S=e.useMemo(function(){var n,e,i={},o={},s={},d=0,l=null===(n=null==r?void 0:r.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==r?void 0:r.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!a){var t="left"===e?b.indexOf(n):x.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:b.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,s=b.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(s){var d=s.selfIndex,l=void 0!==d&&d>=0?d+1:b.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:l}}var u=void 0!==r&&r>=0?r+1:x.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},f=function(n,e,r,a,v,p,_){if(e&&function(n,e,i){var r;((null===(r=null==n?void 0:n.evaluationResults)||void 0===r?void 0:r.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(r){var a=(null==r?void 0:r.deviations)||{};Object.keys(a).sort().forEach(function(d){var v=a[d];if(v){var c=!t.isMissingStr(v[l]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==r?void 0:r.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(d);void 0===o[_]&&(void 0===s[e]&&(s[e]=1),o[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,a,v),e&&!p){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==r?void 0:r.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),o=c(null==r?void 0:r.subsections,t);f(t,i,o,a,v,!1,e||_)})};b.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(a){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=x.find(function(n){return n.selfIndex===s})}else r=x[b.indexOf(n)];f(n,n,r,i,o,!0,n)}),p||x.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&f(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:_,deviationParentRegistry:I}},[b,x,a,r,p]),E=S.parentDeviationRecord,O=S.registry,j=S.deviationParentRegistry;return{isGuidelineMode:p,activeProposed:I,activeVariants:g,comparisonRows:h,existingRule:y,proposedSections:b,existingSections:x,visibleFields:C,parentDeviationRecord:E,deviationNumberRegistry:O,deviationParentRegistry:j,parseError:m}};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A=1===B.length?null:"".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),T=(p=S[0],R=S[1],x=S[2],S[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!T||!E)return;var L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(p,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;T=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!T||!E)return;L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,p=n.subSectionLeftRefs,b=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,I=n.activeSideBySideSection,T=n.maintainRelativeOrder,C=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,w=n.connectedLines,G=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=w?w:ot,dt=null!=G?G:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),pt=t.useRef(!1),bt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,w,G,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===T)return!1;if(T&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}T||Object.keys(p.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(T){if(S&&null!==I)if("number"==typeof I){var it=I,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=I.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=p.current[ot])||void 0===F?void 0:F.current,Z=null===(N=b.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),T||Object.keys(et).forEach(function(t){var e,n,i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!C){a.forEach(function(t,e){var n,i=t.continuationSourceRowId?a.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,l=i>=0?i:e,o=null===(n=g.current[l])||void 0===n?void 0:n.current;if(o){var u=function(t,e){if(!T)return d[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);u.forEach(function(t){var n,u,s,v,h,g,p,b,A,y,R,x,m=null===(n=f.current[t])||void 0===n?void 0:n.current;if(m){var B=o.getBoundingClientRect(),C=m.getBoundingClientRect(),D=B.right-K.left,O=C.left-K.left,L=B.top+18-K.top,_=C.top+18-K.top;if(T&&S&&I===e){var F=null!==(s=null===(u=r.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==s?s:0,N=null!==(h=null===(v=c.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==h?h:0,H=F+(null!==(p=null===(g=r.current)||void 0===g?void 0:g.clientHeight)&&void 0!==p?p:1/0),P=N+(null!==(A=null===(b=c.current)||void 0===b?void 0:b.clientHeight)&&void 0!==A?A:1/0),k=function(t,e,n){return Math.max(e,Math.min(n,t))};L=k(B.top+18,F,H)-K.top,_=k(C.top+18,N,P)-K.top}var w=M(l);w&&J.push({id:"line-".concat(l,"-").concat(t),x1:D,y1:L,x2:O,y2:_,style:w,sectionIdx:l,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(y=a[l])||void 0===y?void 0:y.cognitiveData)||(null===(R=d[t])||void 0===R?void 0:R.cognitiveData)||(null===(x=a[l])||void 0===x?void 0:x.nodeId)&&E[a[l].nodeId])})}})}})}if(!C&&S&&"string"==typeof I&&I.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=I.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],pt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),bt=null===(H=A.current[pt])||void 0===H?void 0:H.current,At=null===(P=y.current[pt])||void 0===P?void 0:P.current;if(bt&&At){var xt=bt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,It=Bt.left-K.left,Tt=xt.top+xt.height/2-K.top,Ct=Bt.top+Bt.height/2-K.top;if(T){var Et=null!==(w=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==w?w:0,Mt=null!==(V=null===(G=c.current)||void 0===G?void 0:G.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Tt=Lt(xt.top+xt.height/2,Et,Dt)-K.top,Ct=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(pt),x1:St,y1:Tt,x2:It,y2:Ct,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,wt=c.current;if(kt&&wt){var Gt=[],Vt=kt.getBoundingClientRect().top,Yt=wt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+wt.clientHeight,Qt=kt.scrollTop,Xt=wt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(C){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var p=t.split(e.DEVIATION_BADGE_SEPARATOR),b=p[0],R=p[1],x=p[2],m="".concat(b).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(b,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),p="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?p=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+i),A=1===B.length?null:"".concat(p,"(").concat(b,")");Gt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),I=(b=S[0],R=S[1],x=S[2],S[3],m="".concat(b).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!I||!E)return;var L=I.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(b,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,w=_.top+_.height/2,G=k-Vt+Qt,V=w-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);Gt.push({lhsScrollY:G,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(w,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,w>=Yt-4&&w<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(T){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Vt+Qt,R=p-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");Gt.push({lhsScrollY:b,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var I=Kt(f,Vt,jt),T=Kt(p,Yt,zt),C=I-qt,E=T-qt,D=Rt(v,C,h,E,g,f>=Vt-4&&f<=jt+4,p>=Yt-4&&p<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:C,y2:E,matchLabel:S})}}})}else{var U=t,W=U;I=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!I||!E)return;L=I.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,w=_.top+_.height/2,G=k-Vt+Qt,V=w-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;Gt.push({lhsScrollY:G,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(w,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,w>=Yt-4&&w<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=Gt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,T,S,I,B,x,m,C]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,p,b,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,I=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,T=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,C=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(b=null===(p=r.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+T,O=M+C,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,w=0,G=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-I+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===w&&(w=t.x1,G=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var p=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-w),Math.max(0,G-U)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-w),Math.max(0,rt-G)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==bt.current&&clearTimeout(bt.current),bt.current=setTimeout(function(){Y.current(),bt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!pt.current&&!z.current){if(T&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=p.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=b.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),I=x.getBoundingClientRect(),C=a.getBoundingClientRect(),E=S.top+S.height/2;m=I.top-C.top+a.scrollTop+I.height/2-(E-C.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(pt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){pt.current=!1}))}}T||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),p="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[p])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var b=g.getBoundingClientRect();N.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,T,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==bt.current&&clearTimeout(bt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,I,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),t=function(n,t){return(null==n?void 0:n.contentId)||(null==n?void 0:n.id)||t},e=function(n,t,e,i){return{id:"".concat(t,":").concat(e,":empty"),nodeId:n,title:"",content:"",change_history:"",subsections:[],relation:"not_defined",selfIndex:-1,refIndexes:[],refContentIds:[],displayTitle:!1,displayContent:!1,layoutKey:"".concat(t,":").concat(e,":empty"),comparisonRowId:t,isMappingContinuation:Boolean(i),continuationSourceRowId:i}},i=function(i,o,l,r,d,u){var a,c;if(void 0===u&&(u=!1),!i)return e(l,r,d);var s=Number(null==o?void 0:o.selfIndex),f=null!=o&&Number.isFinite(s)&&s>=0;return n.__assign(n.__assign({},i),{refIndexes:f?[s]:[],refContentIds:(null==o?void 0:o.contentId)?[o.contentId]:[],layoutKey:"".concat(r,":").concat(d,":").concat(t(i,String(d))),comparisonRowId:r,isMultipleMapping:u||i.isMultipleMapping||(null!==(c=null===(a=i.refContentIds)||void 0===a?void 0:a.length)&&void 0!==c?c:0)>1})};exports.buildComparisonRows=function(n,o,l){if(0===o.length&&0===l.length)return[];var r=o.length>0?o:[void 0],d=l.length>0?l:[void 0],u=[];return r.forEach(function(o,r){var a=d[0],c=[n,r,t(o,"empty-left"),0,t(a,"empty-right")].join("::");d.forEach(function(d,a){var s=[n,r,t(o,"empty-left"),a,t(d,"empty-right")].join("::"),f=null!=o&&a>0;u.push({id:s,nodeId:n,left:f?e(n,s,"left",c):i(o,d,n,s,"left",l.length>1),right:i(d,o,n,s,"right"),leftOrdinal:r,rightOrdinal:a})})}),u};
|
|
2
|
+
//# sourceMappingURL=buildComparisonRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildComparisonRows.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as o}from"tslib";import{jsxs as l,jsx as i}from"react/jsx-runtime";import e from"./components/ChatCitation.js";import{getColorCode as n}from"./utils/helpers.js";import t from"./components/Chip.js";import r from"./assets/message-chat-square.svg.js";import"@mui/icons-material/KeyboardArrowDown";import"@mui/icons-material/KeyboardArrowUp";import"@mui/icons-material/Clear";import d from"./components/InViewNavigation.js";import a from"./components/DetailedView.js";import u from"./components/SummarizedView.js";import v from"./components/RuleBook.js";import{useState as s,useRef as c,useMemo as h,useEffect as f,useCallback as m}from"react";import{defaultRenderer as p}from"./constants/renderer.js";import g from"./components/IconContainer.js";import{Table as y}from"lucide-react";import{BigQueryTable as b}from"./BigQueryTable.js";import x from"@mui/icons-material/CloseOutlined";var w=function(o,l,i){if(void 0===i&&(i="smooth"),l){for(var e=o.parentElement;e;){var n=window.getComputedStyle(e).overflowY;if(("auto"===n||"scroll"===n)&&e.scrollHeight>e.clientHeight)break;if(e===l){e=null;break}e=e.parentElement}var t=null!=e?e:l,r=o.getBoundingClientRect(),d=t.getBoundingClientRect(),a=t.scrollTop+r.top-d.top-(t.clientHeight-r.height)/2;t.scrollTo({top:Math.max(0,a),behavior:i})}};function C(C){var S,k,A,D,T,R,F,j,z,I,B,E,H,P,V,q,N,W,Y,K,O,M,Q,U,G,J,L,X,Z,$,_,oo,lo,io,eo,no,to,ro,ao,uo,vo,so,co,ho,fo,mo,po,go,yo=C.rootContainer,bo=C.chatContainer,xo=void 0===bo?{chatData:[]}:bo,wo=C.ruleBookContainer,Co=C.renderer,So=C.additionalData,ko=C.tableComponent,Ao=C.closePreview,Do=C.isRenderedCustomComponent,To=void 0!==Do&&Do,Ro=C.showRootContainer,Fo=void 0===Ro||Ro,jo=C.reversePanels,zo=void 0!==jo&&jo,Io=s(0),Bo=Io[0],Eo=Io[1],Ho=s(0),Po=Ho[0],Vo=Ho[1],qo=s(0),No=qo[0],Wo=qo[1],Yo=s(0),Ko=Yo[0],Oo=Yo[1],Mo=c(null),Qo=c(null),Uo=c(null),Go=h(function(){return o(o({},p),Co)},[Co]),Jo=h(function(){return!!((null==ko?void 0:ko.rows)&&Object.keys(ko.rows).length>0)},[ko]),Lo=h(function(){var o;return null!==(o=null==So?void 0:So.RuleBookDetailedViewVerticallyStacked)&&void 0!==o&&o},[null==So?void 0:So.RuleBookDetailedViewVerticallyStacked]);f(function(){var o,l;if((null==wo?void 0:wo.show)&&Mo.current){var i=null===(o=Mo.current)||void 0===o?void 0:o.querySelectorAll(".rule-book-highlight");if(Eo((null==i?void 0:i.length)||0),Vo(0),i&&i.length>0){var e=i[0];e.style.backgroundColor="#ffff5c",w(e,Mo.current)}}if((null==xo?void 0:xo.show)&&(null==Qo?void 0:Qo.current)){var n=null===(l=Qo.current)||void 0===l?void 0:l.querySelectorAll(".user-chat-highlight");if(Wo((null==n?void 0:n.length)||0),Oo(0),n&&n.length>0){var t=n[0];t.style.backgroundColor="#ffff5c";var r=requestAnimationFrame(function(){w(t,Uo.current)});return function(){return cancelAnimationFrame(r)}}}},[null==xo?void 0:xo.show,null==wo?void 0:wo.show,null==wo?void 0:wo.data,null==xo?void 0:xo.chatData]);var Xo=m(function(){var o;if(Po+1<Bo){var l=null===(o=Mo.current)||void 0===o?void 0:o.querySelectorAll(".rule-book-highlight");if(!l)return;l[Po].style.backgroundColor="#ffffb8";var i=Po+1;Vo(i);var e=l[i];e.style.backgroundColor="#ffff5c",w(e,Mo.current)}},[Po,Bo]),Zo=m(function(){var o;if(!(Po-1<0)){var l=null===(o=Mo.current)||void 0===o?void 0:o.querySelectorAll(".rule-book-highlight");if(l){l[Po].style.backgroundColor="#ffffb8";var i=Po-1,e=l[i];e.style.backgroundColor="#ffff5c",Vo(i),w(e,Mo.current)}}},[Po]),$o=m(function(){var o;if(Ko+1<No){var l=null===(o=Qo.current)||void 0===o?void 0:o.querySelectorAll(".user-chat-highlight");if(!l)return;l[Ko].style.backgroundColor="#ffffb8";var i=Ko+1,e=l[i];e.style.backgroundColor="#ffff5c",Oo(i),w(e,Uo.current)}},[Ko,No]),_o=m(function(){var o;if(!(Ko-1<0)){var l=null===(o=Qo.current)||void 0===o?void 0:o.querySelectorAll(".user-chat-highlight");if(l){l[Ko].style.backgroundColor="#ffffb8";var i=Ko-1,e=l[i];e.style.backgroundColor="#ffff5c",Oo(i),w(e,Uo.current)}}},[Ko]),ol=n((null==yo?void 0:yo.relevanceScore)||0),ll=h(function(){var e,n=l("span",o({style:o({display:"flex",border:"1px solid",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",borderColor:ol.border,backgroundColor:ol.background,color:ol.text},null===(e=null==yo?void 0:yo.slotStyles)||void 0===e?void 0:e.relevanceScore)},{children:[(null==yo?void 0:yo.relevanceTitle)||"Decision Strength",":"," ",(null==yo?void 0:yo.relevanceScore)||0,"%"]}),"relevance-score"),t=i("span",o({style:{display:"flex",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",backgroundColor:"white",color:"black",cursor:"pointer"},onClick:Ao},{children:i(x,{})}),"close-preview");return To&&!(null==So?void 0:So.isExpanded)?[n,t]:[n]},[To,ol.background,ol.border,ol.text,null==yo?void 0:yo.relevanceScore,null===(S=null==yo?void 0:yo.slotStyles)||void 0===S?void 0:S.relevanceScore,null==yo?void 0:yo.relevanceTitle]),il=h(function(){return[Bo>0&&i(d,{currentItemNumber:Po+1,totalItems:Bo,disableNext:Po+1>=Bo,onNext:Xo,onPrevious:Zo,disablePrevious:Po<=0},"rulebook-nav")]},[Po,Xo,Zo,Bo]),el=h(function(){return(null==So?void 0:So.RuleBookContainerHeight)?So.RuleBookContainerHeight:!(!Lo||(null==So?void 0:So.isExpanded))&&"600px"},[null==So?void 0:So.RuleBookContainerHeight,Lo]),nl=h(function(){var o,l;return[(null===(l=null===(o=null==xo?void 0:xo.detailedTab)||void 0===o?void 0:o.chip)||void 0===l?void 0:l.isActive)&&No>0&&i(d,{currentItemNumber:Ko+1,totalItems:No,onNext:$o,onPrevious:_o,disableNext:Ko+1>=No,disablePrevious:Ko<=0},"chat-nav")]},[null===(A=null===(k=null==xo?void 0:xo.detailedTab)||void 0===k?void 0:k.chip)||void 0===A?void 0:A.isActive,Ko,$o,_o,No]),tl=l("div",o({style:o({display:"flex",flexDirection:zo?Lo?"column-reverse":"row-reverse":Lo?"column":"row",gap:[(null==xo?void 0:xo.chatData)&&xo.chatData.length>0&&(xo.show||void 0===xo.show),(null==wo?void 0:wo.data)&&(wo.show||void 0===wo.show),Jo].filter(Boolean).length>1?"12px":"0",height:el||"100%",minHeight:0},null===(D=null==yo?void 0:yo.slotStyles)||void 0===D?void 0:D.container)},{children:[Jo&&i("span",o({style:o({flex:"1 1 0%",minWidth:0},null===(T=null==xo?void 0:xo.slotStyles)||void 0===T?void 0:T.outerContainer)},{children:i(e,o({title:"Invoice Data Preview",icon:i(g,{children:i(y,{size:16})}),slotStyles:{title:{color:"#475569",fontWeight:500}},secondaryActions:[]},{children:i("div",o({style:{height:"100%",maxHeight:(null==So?void 0:So.isExpanded)?"none":"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",backgroundColor:"#FFFFFF",position:"relative",overflow:"hidden"}},{children:(null==ko?void 0:ko.rows)&&i(b,{rows:ko.rows,columns:ko.columns||[]})}))}))})),(null==wo?void 0:wo.data)&&(wo.show||void 0===wo.show)&&i("span",o({style:o({flex:"1 1 0%",minWidth:0},null===(R=null==wo?void 0:wo.slotStyles)||void 0===R?void 0:R.outerContainer)},{children:i(e,o({title:null!==(F=null==wo?void 0:wo.title)&&void 0!==F?F:"Rule book",icon:null==wo?void 0:wo.ruleBookIcon,slotStyles:{title:o({color:"#475569",fontWeight:500},null===(j=null==wo?void 0:wo.slotStyles)||void 0===j?void 0:j.title),body:null===(z=null==wo?void 0:wo.slotStyles)||void 0===z?void 0:z.body},secondaryActions:(null==wo?void 0:wo.secondaryActions)?wo.secondaryActions(il):il},{children:i("div",o({style:o({height:"100%",maxHeight:"275px",minHeight:0,border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(I=null==wo?void 0:wo.slotStyles)||void 0===I?void 0:I.dataContainer)},{children:i("div",o({style:{padding:"12px",height:"100%",overflowY:"auto"},ref:Mo},{children:i(v,{data:wo.data,renderers:null!==(B=null==wo?void 0:wo.renderer)&&void 0!==B?B:Go})}))}))}))})),(null==xo?void 0:xo.chatData)&&xo.chatData.length>0&&(xo.show||void 0===xo.show)&&i("span",o({style:o({flex:"1 1 0%",minWidth:0},null===(E=null==xo?void 0:xo.slotStyles)||void 0===E?void 0:E.outerContainer)},{children:i(e,o({title:null!==(H=null==xo?void 0:xo.title)&&void 0!==H?H:"Chat",icon:null==xo?void 0:xo.chatIcon,containerStyles:null===(P=null==xo?void 0:xo.slotStyles)||void 0===P?void 0:P.container,slotStyles:{title:o({color:"#475569",fontWeight:500},null===(V=null==xo?void 0:xo.slotStyles)||void 0===V?void 0:V.title),body:null===(q=null==xo?void 0:xo.slotStyles)||void 0===q?void 0:q.body},primaryActions:[((null===(W=null===(N=null==xo?void 0:xo.summarizedTab)||void 0===N?void 0:N.chip)||void 0===W?void 0:W.show)||void 0===(null===(K=null===(Y=null==xo?void 0:xo.summarizedTab)||void 0===Y?void 0:Y.chip)||void 0===K?void 0:K.show))&&i(t,o({label:"Summarized"},null===(O=null==xo?void 0:xo.summarizedTab)||void 0===O?void 0:O.chip)),i(t,o({label:"Detailed"},null===(M=null==xo?void 0:xo.detailedTab)||void 0===M?void 0:M.chip))],secondaryActions:xo.secondaryActions?null==xo?void 0:xo.secondaryActions(nl):nl},{children:l("div",o({ref:Uo,style:o({height:"100%",maxHeight:"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(Q=null==xo?void 0:xo.slotStyles)||void 0===Q?void 0:Q.chatDataContainer)},{children:[(null===(G=null===(U=null==xo?void 0:xo.detailedTab)||void 0===U?void 0:U.chip)||void 0===G?void 0:G.isActive)&&i("div",o({ref:Qo,style:{position:(null==So?void 0:So.isExpanded)?"absolute":"relative",inset:0,padding:"12px",overflowY:"auto"}},{children:i(a,{chatData:null!==(J=xo.chatData)&&void 0!==J?J:[],assistantChatProps:o(o({},null===(X=null===(L=null==xo?void 0:xo.detailedTab)||void 0===L?void 0:L.view)||void 0===X?void 0:X.assistantChatProps),{renderers:null!==(_=null===($=null===(Z=null==xo?void 0:xo.detailedTab)||void 0===Z?void 0:Z.detailedViewRenderer)||void 0===$?void 0:$.assistantText)&&void 0!==_?_:Go}),userChatItemProps:o(o({},null===(lo=null===(oo=null==xo?void 0:xo.detailedTab)||void 0===oo?void 0:oo.view)||void 0===lo?void 0:lo.userChatItemProps),{renderers:null!==(no=null===(eo=null===(io=null==xo?void 0:xo.detailedTab)||void 0===io?void 0:io.detailedViewRenderer)||void 0===eo?void 0:eo.userText)&&void 0!==no?no:Go})})})),(null===(ro=null===(to=null==xo?void 0:xo.summarizedTab)||void 0===to?void 0:to.chip)||void 0===ro?void 0:ro.show)&&(null===(uo=null===(ao=null==xo?void 0:xo.summarizedTab)||void 0===ao?void 0:ao.chip)||void 0===uo?void 0:uo.isActive)&&i(u,o({chatData:null!==(vo=xo.chatData)&&void 0!==vo?vo:[]},null===(so=null==xo?void 0:xo.summarizedTab)||void 0===so?void 0:so.view,{renderer:null!==(ho=null===(co=null==xo?void 0:xo.summarizedTab)||void 0===co?void 0:co.summarizedViewRenderer)&&void 0!==ho?ho:Go}))]}))}))}))]}));return Fo?i(e,o({title:null==yo?void 0:yo.title,slotStyles:{title:null===(fo=null==yo?void 0:yo.slotStyles)||void 0===fo?void 0:fo.title,body:null===(mo=null==yo?void 0:yo.slotStyles)||void 0===mo?void 0:mo.body},containerStyles:null===(po=null==yo?void 0:yo.slotStyles)||void 0===po?void 0:po.container,icon:null!==(go=null==yo?void 0:yo.icon)&&void 0!==go?go:i(g,{children:i("img",{src:r,alt:"chat icon",style:{width:16,height:16}})}),secondaryActions:(null==yo?void 0:yo.secondaryActions)?yo.secondaryActions(ll):ll},{children:tl})):tl}export{C as default};
|
|
1
|
+
import{__assign as o}from"tslib";import{jsxs as l,jsx as i}from"react/jsx-runtime";import e from"./components/ChatCitation.js";import{getColorCode as n}from"./utils/helpers.js";import t from"./components/Chip.js";import r from"./assets/message-chat-square.svg.js";import"@mui/icons-material/KeyboardArrowDown";import"@mui/icons-material/KeyboardArrowUp";import"@mui/icons-material/Clear";import d from"./components/InViewNavigation.js";import a from"./components/DetailedView.js";import u from"./components/SummarizedView.js";import v from"./components/RuleBook.js";import{useState as s,useRef as c,useMemo as h,useEffect as f,useCallback as m}from"react";import{defaultRenderer as p}from"./constants/renderer.js";import g from"./components/IconContainer.js";import{Table as y}from"lucide-react";import{BigQueryTable as b}from"./BigQueryTable.js";import x from"@mui/icons-material/CloseOutlined";var w=function(o,l,i){if(void 0===i&&(i="smooth"),l){for(var e=o.parentElement;e;){var n=window.getComputedStyle(e).overflowY;if(("auto"===n||"scroll"===n)&&e.scrollHeight>e.clientHeight)break;if(e===l){e=null;break}e=e.parentElement}var t=null!=e?e:l,r=o.getBoundingClientRect(),d=t.getBoundingClientRect(),a=t.scrollTop+r.top-d.top-(t.clientHeight-r.height)/2;t.scrollTo({top:Math.max(0,a),behavior:i})}},C={chatData:[]};function S(S){var k,A,D,T,R,F,j,z,I,B,E,H,P,V,q,N,W,Y,K,O,M,Q,U,G,J,L,X,Z,$,_,oo,lo,io,eo,no,to,ro,ao,uo,vo,so,co,ho,fo,mo,po,go,yo,bo=S.rootContainer,xo=S.chatContainer,wo=void 0===xo?C:xo,Co=S.ruleBookContainer,So=S.renderer,ko=S.additionalData,Ao=S.tableComponent,Do=S.closePreview,To=S.isRenderedCustomComponent,Ro=void 0!==To&&To,Fo=S.showRootContainer,jo=void 0===Fo||Fo,zo=S.reversePanels,Io=void 0!==zo&&zo,Bo=s(0),Eo=Bo[0],Ho=Bo[1],Po=s(0),Vo=Po[0],qo=Po[1],No=s(0),Wo=No[0],Yo=No[1],Ko=s(0),Oo=Ko[0],Mo=Ko[1],Qo=c(null),Uo=c(null),Go=c(null),Jo=h(function(){return o(o({},p),So)},[So]),Lo=h(function(){return!!((null==Ao?void 0:Ao.rows)&&Object.keys(Ao.rows).length>0)},[Ao]),Xo=h(function(){var o;return null!==(o=null==ko?void 0:ko.RuleBookDetailedViewVerticallyStacked)&&void 0!==o&&o},[null==ko?void 0:ko.RuleBookDetailedViewVerticallyStacked]);f(function(){var o,l;if((null==Co?void 0:Co.show)&&Qo.current){var i=null===(o=Qo.current)||void 0===o?void 0:o.querySelectorAll(".rule-book-highlight");if(Ho((null==i?void 0:i.length)||0),qo(0),i&&i.length>0){var e=i[0];e.style.backgroundColor="#ffff5c",w(e,Qo.current)}}if((null==wo?void 0:wo.show)&&(null==Uo?void 0:Uo.current)){var n=null===(l=Uo.current)||void 0===l?void 0:l.querySelectorAll(".user-chat-highlight");if(Yo((null==n?void 0:n.length)||0),Mo(0),n&&n.length>0){var t=n[0];t.style.backgroundColor="#ffff5c";var r=requestAnimationFrame(function(){w(t,Go.current)});return function(){return cancelAnimationFrame(r)}}}},[null==wo?void 0:wo.show,null==Co?void 0:Co.show,null==Co?void 0:Co.data,null==wo?void 0:wo.chatData]);var Zo=m(function(){var o;if(Vo+1<Eo){var l=null===(o=Qo.current)||void 0===o?void 0:o.querySelectorAll(".rule-book-highlight");if(!l)return;l[Vo].style.backgroundColor="#ffffb8";var i=Vo+1;qo(i);var e=l[i];e.style.backgroundColor="#ffff5c",w(e,Qo.current)}},[Vo,Eo]),$o=m(function(){var o;if(!(Vo-1<0)){var l=null===(o=Qo.current)||void 0===o?void 0:o.querySelectorAll(".rule-book-highlight");if(l){l[Vo].style.backgroundColor="#ffffb8";var i=Vo-1,e=l[i];e.style.backgroundColor="#ffff5c",qo(i),w(e,Qo.current)}}},[Vo]),_o=m(function(){var o;if(Oo+1<Wo){var l=null===(o=Uo.current)||void 0===o?void 0:o.querySelectorAll(".user-chat-highlight");if(!l)return;l[Oo].style.backgroundColor="#ffffb8";var i=Oo+1,e=l[i];e.style.backgroundColor="#ffff5c",Mo(i),w(e,Go.current)}},[Oo,Wo]),ol=m(function(){var o;if(!(Oo-1<0)){var l=null===(o=Uo.current)||void 0===o?void 0:o.querySelectorAll(".user-chat-highlight");if(l){l[Oo].style.backgroundColor="#ffffb8";var i=Oo-1,e=l[i];e.style.backgroundColor="#ffff5c",Mo(i),w(e,Go.current)}}},[Oo]),ll=n((null==bo?void 0:bo.relevanceScore)||0),il=h(function(){var e,n=l("span",o({style:o({display:"flex",border:"1px solid",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",borderColor:ll.border,backgroundColor:ll.background,color:ll.text},null===(e=null==bo?void 0:bo.slotStyles)||void 0===e?void 0:e.relevanceScore)},{children:[(null==bo?void 0:bo.relevanceTitle)||"Decision Strength",":"," ",(null==bo?void 0:bo.relevanceScore)||0,"%"]}),"relevance-score"),t=i("span",o({style:{display:"flex",alignItems:"center",gap:"4px",borderRadius:"6px",padding:"2px 8px",fontSize:"12px",backgroundColor:"white",color:"black",cursor:"pointer"},onClick:Do},{children:i(x,{})}),"close-preview");return Ro&&!(null==ko?void 0:ko.isExpanded)?[n,t]:[n]},[Ro,ll.background,ll.border,ll.text,null==bo?void 0:bo.relevanceScore,null===(k=null==bo?void 0:bo.slotStyles)||void 0===k?void 0:k.relevanceScore,null==bo?void 0:bo.relevanceTitle]),el=h(function(){return[Eo>0&&i(d,{currentItemNumber:Vo+1,totalItems:Eo,disableNext:Vo+1>=Eo,onNext:Zo,onPrevious:$o,disablePrevious:Vo<=0},"rulebook-nav")]},[Vo,Zo,$o,Eo]),nl=h(function(){return(null==ko?void 0:ko.RuleBookContainerHeight)?ko.RuleBookContainerHeight:!(!Xo||(null==ko?void 0:ko.isExpanded))&&"600px"},[null==ko?void 0:ko.RuleBookContainerHeight,Xo]),tl=h(function(){var o,l;return[(null===(l=null===(o=null==wo?void 0:wo.detailedTab)||void 0===o?void 0:o.chip)||void 0===l?void 0:l.isActive)&&Wo>0&&i(d,{currentItemNumber:Oo+1,totalItems:Wo,onNext:_o,onPrevious:ol,disableNext:Oo+1>=Wo,disablePrevious:Oo<=0},"chat-nav")]},[null===(D=null===(A=null==wo?void 0:wo.detailedTab)||void 0===A?void 0:A.chip)||void 0===D?void 0:D.isActive,Oo,_o,ol,Wo]),rl=l("div",o({style:o({display:"flex",flexDirection:Io?Xo?"column-reverse":"row-reverse":Xo?"column":"row",gap:[(null==wo?void 0:wo.chatData)&&wo.chatData.length>0&&(wo.show||void 0===wo.show),(null==Co?void 0:Co.data)&&(Co.show||void 0===Co.show),Lo].filter(Boolean).length>1?"12px":"0",height:nl||"100%",minHeight:0},null===(T=null==bo?void 0:bo.slotStyles)||void 0===T?void 0:T.container)},{children:[Lo&&i("span",o({style:o({flex:"1 1 0%",minWidth:0},null===(R=null==wo?void 0:wo.slotStyles)||void 0===R?void 0:R.outerContainer)},{children:i(e,o({title:"Invoice Data Preview",icon:i(g,{children:i(y,{size:16})}),slotStyles:{title:{color:"#475569",fontWeight:500}},secondaryActions:[]},{children:i("div",o({style:{height:"100%",maxHeight:(null==ko?void 0:ko.isExpanded)?"none":"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",backgroundColor:"#FFFFFF",position:"relative",overflow:"hidden"}},{children:(null==Ao?void 0:Ao.rows)&&i(b,{rows:Ao.rows,columns:Ao.columns||[]})}))}))})),(null==Co?void 0:Co.data)&&(Co.show||void 0===Co.show)&&i("span",o({style:o({flex:"1 1 0%",minWidth:0},null===(F=null==Co?void 0:Co.slotStyles)||void 0===F?void 0:F.outerContainer)},{children:i(e,o({title:null!==(j=null==Co?void 0:Co.title)&&void 0!==j?j:"Rule book",icon:null==Co?void 0:Co.ruleBookIcon,slotStyles:{title:o({color:"#475569",fontWeight:500},null===(z=null==Co?void 0:Co.slotStyles)||void 0===z?void 0:z.title),body:null===(I=null==Co?void 0:Co.slotStyles)||void 0===I?void 0:I.body},secondaryActions:(null==Co?void 0:Co.secondaryActions)?Co.secondaryActions(el):el},{children:i("div",o({style:o({height:"100%",maxHeight:"275px",minHeight:0,border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(B=null==Co?void 0:Co.slotStyles)||void 0===B?void 0:B.dataContainer)},{children:i("div",o({style:{padding:"12px",height:"100%",overflowY:"auto"},ref:Qo},{children:i(v,{data:Co.data,renderers:null!==(E=null==Co?void 0:Co.renderer)&&void 0!==E?E:Jo})}))}))}))})),(null==wo?void 0:wo.chatData)&&wo.chatData.length>0&&(wo.show||void 0===wo.show)&&i("span",o({style:o({flex:"1 1 0%",minWidth:0},null===(H=null==wo?void 0:wo.slotStyles)||void 0===H?void 0:H.outerContainer)},{children:i(e,o({title:null!==(P=null==wo?void 0:wo.title)&&void 0!==P?P:"Chat",icon:null==wo?void 0:wo.chatIcon,containerStyles:null===(V=null==wo?void 0:wo.slotStyles)||void 0===V?void 0:V.container,slotStyles:{title:o({color:"#475569",fontWeight:500},null===(q=null==wo?void 0:wo.slotStyles)||void 0===q?void 0:q.title),body:null===(N=null==wo?void 0:wo.slotStyles)||void 0===N?void 0:N.body},primaryActions:[((null===(Y=null===(W=null==wo?void 0:wo.summarizedTab)||void 0===W?void 0:W.chip)||void 0===Y?void 0:Y.show)||void 0===(null===(O=null===(K=null==wo?void 0:wo.summarizedTab)||void 0===K?void 0:K.chip)||void 0===O?void 0:O.show))&&i(t,o({label:"Summarized"},null===(M=null==wo?void 0:wo.summarizedTab)||void 0===M?void 0:M.chip)),i(t,o({label:"Detailed"},null===(Q=null==wo?void 0:wo.detailedTab)||void 0===Q?void 0:Q.chip))],secondaryActions:wo.secondaryActions?null==wo?void 0:wo.secondaryActions(tl):tl},{children:l("div",o({ref:Go,style:o({height:"100%",maxHeight:"275px",border:"2px solid #E2E8F0",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#F8FAFC",position:"relative",overflowY:"auto"},null===(U=null==wo?void 0:wo.slotStyles)||void 0===U?void 0:U.chatDataContainer)},{children:[(null===(J=null===(G=null==wo?void 0:wo.detailedTab)||void 0===G?void 0:G.chip)||void 0===J?void 0:J.isActive)&&i("div",o({ref:Uo,style:{position:(null==ko?void 0:ko.isExpanded)?"absolute":"relative",inset:0,padding:"12px",overflowY:"auto"}},{children:i(a,{chatData:null!==(L=wo.chatData)&&void 0!==L?L:[],assistantChatProps:o(o({},null===(Z=null===(X=null==wo?void 0:wo.detailedTab)||void 0===X?void 0:X.view)||void 0===Z?void 0:Z.assistantChatProps),{renderers:null!==(oo=null===(_=null===($=null==wo?void 0:wo.detailedTab)||void 0===$?void 0:$.detailedViewRenderer)||void 0===_?void 0:_.assistantText)&&void 0!==oo?oo:Jo}),userChatItemProps:o(o({},null===(io=null===(lo=null==wo?void 0:wo.detailedTab)||void 0===lo?void 0:lo.view)||void 0===io?void 0:io.userChatItemProps),{renderers:null!==(to=null===(no=null===(eo=null==wo?void 0:wo.detailedTab)||void 0===eo?void 0:eo.detailedViewRenderer)||void 0===no?void 0:no.userText)&&void 0!==to?to:Jo})})})),(null===(ao=null===(ro=null==wo?void 0:wo.summarizedTab)||void 0===ro?void 0:ro.chip)||void 0===ao?void 0:ao.show)&&(null===(vo=null===(uo=null==wo?void 0:wo.summarizedTab)||void 0===uo?void 0:uo.chip)||void 0===vo?void 0:vo.isActive)&&i(u,o({chatData:null!==(so=wo.chatData)&&void 0!==so?so:[]},null===(co=null==wo?void 0:wo.summarizedTab)||void 0===co?void 0:co.view,{renderer:null!==(fo=null===(ho=null==wo?void 0:wo.summarizedTab)||void 0===ho?void 0:ho.summarizedViewRenderer)&&void 0!==fo?fo:Jo}))]}))}))}))]}));return jo?i(e,o({title:null==bo?void 0:bo.title,slotStyles:{title:null===(mo=null==bo?void 0:bo.slotStyles)||void 0===mo?void 0:mo.title,body:null===(po=null==bo?void 0:bo.slotStyles)||void 0===po?void 0:po.body},containerStyles:null===(go=null==bo?void 0:bo.slotStyles)||void 0===go?void 0:go.container,icon:null!==(yo=null==bo?void 0:bo.icon)&&void 0!==yo?yo:i(g,{children:i("img",{src:r,alt:"chat icon",style:{width:16,height:16}})}),secondaryActions:(null==bo?void 0:bo.secondaryActions)?bo.secondaryActions(il):il},{children:rl})):rl}export{S as default};
|
|
2
2
|
//# sourceMappingURL=InternalChatCitationRenderer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i,__awaiter as n,__generator as o}from"tslib";import{jsxs as t,jsx as e,Fragment as l}from"react/jsx-runtime";import{Globe as r,ChevronUp as a,ChevronDown as d,Maximize2 as u,X as c,ExternalLink as s}from"lucide-react";import{useState as v,useEffect as p,useMemo as h,useRef as m}from"react";import g from"./ResizableSplitPane.js";import f from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as x,DefaultFullScreenIcon as b}from"../../assests/svg/PdfViewerIcons.js";import _ from"react-markdown";import y from"rehype-raw";import{Dialog as w,Box as C}from"@mui/material";import{SHARED_MARKDOWN_STYLES as F}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as D}from"./CompareContext.js";import{processGuidelinesMarkdown as P}from"./Guidelines/utils/processGuidelinesMarkdown.js";import S from"../GptWebCitation/GptWebCitation.js";import{CitationType as T}from"../GptWebCitation/types.js";import"./MoreFunctionsPopup.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";var k=function(i){var n,o,t;return(null===(t=null===(o=null===(n=(null==i?void 0:i.extraMetaData)||i)||void 0===n?void 0:n.aiReasoningCitation)||void 0===o?void 0:o.gpt_citation)||void 0===t?void 0:t[0])||null},j="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",I="sai.siddhartha@techolution.com",G="672e32f7a0e8fe2e8e50bcba",N="TNV Sai Siddhartha",R="90vh",E="calc(".concat(R," - 120px)"),M=function(){var i;return"function"==typeof(null===(i=globalThis.crypto)||void 0===i?void 0:i.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var n=Math.floor(16*Math.random());return("x"===i?n:n%4+8).toString(16)})},A=function(i,n){var o=function(i){var n;return(null==i?void 0:i.payloadCitationId)||(null===(n=null==i?void 0:i.extraMetaData)||void 0===n?void 0:n.payloadCitationId)||""}(i)||n||M();return function(i,n){i&&"object"==typeof i&&(i.payloadCitationId=n,i.extraMetaData&&"object"==typeof i.extraMetaData&&(i.extraMetaData.payloadCitationId=n))}(i,o),o},U=function(t){var l,r=t.metaData,g=t.isFullscreen,f=void 0!==g&&g,x=D().gptWebCitationConfig,b=h(function(){return function(i){return{endpoint:(null==i?void 0:i.endpoint)||j,userEmail:(null==i?void 0:i.userEmail)||I,userId:(null==i?void 0:i.userId)||G,userName:(null==i?void 0:i.userName)||N,headers:null==i?void 0:i.headers}}(x)},[x]),_=null==r?void 0:r.webGpt,y=m(null);y.current||(y.current=M());var w=h(function(){return function(i,n,o){var t,e,l=k(i),r=(null==l?void 0:l.customMetaData)||{},a=(null==r?void 0:r.value)||{},d=(null==i?void 0:i.webSearchAnswer)||{},u=(null==i?void 0:i.extraMetaData)||i||{};return{userEmail:(null==i?void 0:i.userEmail)||(null==d?void 0:d.userEmail)||(null==n?void 0:n.userEmail)||"",userId:(null==i?void 0:i.userId)||(null==d?void 0:d.userId)||(null==n?void 0:n.userId)||"",userName:(null==i?void 0:i.userName)||(null==d?void 0:d.userName)||(null==n?void 0:n.userName)||"",citationId:A(i,o),citationUrl:(null==a?void 0:a.citationUrl)||(null==d?void 0:d.citationUrl)||"",content:(null==u?void 0:u.Reasoning)||(null==d?void 0:d.enhanced_content)||"",citationType:(null==a?void 0:a.citationType)||"web",citatioNumber:null!==(e=null!==(t=null==r?void 0:r.citation_number)&&void 0!==t?t:null==l?void 0:l.citation_number)&&void 0!==e?e:Number((null==i?void 0:i.reasoningId)||0)}}(_,b,y.current||void 0)},[_,b]),C=h(function(){return k(_)},[_]),F=(null===(l=null==C?void 0:C.customMetaData)||void 0===l?void 0:l.value)||{},P=(null==_?void 0:_.extraMetaData)||_||{},R=v(),U=R[0],W=R[1],H=v("pending"),z=H[0],V=H[1],B=v(!0),O=B[0],L=B[1];p(function(){var t=!0;return n(void 0,void 0,void 0,function(){var n,e,l,r;return o(this,function(o){switch(o.label){case 0:if(!b.endpoint||!(null==w?void 0:w.citationUrl)||!(null==w?void 0:w.content))return V("error"),[2];V("pending"),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(b.endpoint,{method:"POST",headers:i({"actor-id":w.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},b.headers||{}),body:JSON.stringify(w)})];case 2:if(!(n=o.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return e=o.sent(),l=(null==e?void 0:e.responseData)||(null==e?void 0:e.result)||(null==e?void 0:e.data)||e,t?(W(l),V("success"),[3,5]):[2];case 4:return r=o.sent(),t?(console.error("Failed to load GPT web citation",r),V("error"),[3,5]):[2];case 5:return[2]}})}),function(){t=!1}},[w,b]);var J=h(function(){return{item:{confidence_score:Number((null==P?void 0:P.Confidence_score)||0),text:(null==F?void 0:F.paraphrase)||"Web citation reasoning",dataSource:(null==F?void 0:F.text)||(null==P?void 0:P.Reasoning)||"",paraphrase:(null==F?void 0:F.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==w?void 0:w.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:d,ChevronUpIcon:a,MaximizeIcon:u,CloseIcon:c}}},[F,null==w?void 0:w.citatioNumber,P]),q=h(function(){return i(i({},J),f?{bodyHeight:E}:{})},[J,f]);return e(S,{gptCitation:q,defaultCitationUrl:(null==w?void 0:w.citationUrl)||"",citationType:T.GPT_WEB,webCitationData:U,webCitationStatus:z,showWebCitation:O,onToggleCitationView:function(){return L(function(i){return!i})},iconsConfig:{MaximizeIcon:u,ExternalLinkIcon:s},isFixedHeight:!0})},W=function(n){var o,t,r,a,d,u,c,s=n.href,v=n.metaData,p=n.citationTitle,m=n.citationType,x=n.citationReason,b=n.isFullscreen,w=D().guidelinesData,S=function(i){try{var n=new URL(i,window.location.origin);return{citationNumber:n.searchParams.get("citationNumber"),phraseToHighlight:n.searchParams.get("phrase_to_highlight")}}catch(i){return{citationNumber:null,phraseToHighlight:null}}}(s),T=S.citationNumber,k=S.phraseToHighlight,j=T&&(null===(o=null==v?void 0:v.citations)||void 0===o?void 0:o[T])||{},I=(null===(t=null==v?void 0:v.docData)||void 0===t?void 0:t.documents)||{},G=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},N=Object.keys((null==v?void 0:v.citations)||{}).length>0||Object.keys((null==v?void 0:v.docData)||{}).length>0,R=null==G?void 0:G[0],E=null==G?void 0:G[1],M=R?I[R]:null,A=E?I[E]:null,W=R?j[R]:null,H=E?j[E]:null,z=h(function(){var i,n,o,t;return W&&M?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==M?void 0:M.title,pdfUrl:null==M?void 0:M.signed_url,highlightText:[null!==(i=null==W?void 0:W.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==W?void 0:W.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(o=null==W?void 0:W.custom_metadata)||void 0===o?void 0:o.pdf_start_page_number,null===(t=null==W?void 0:W.custom_metadata)||void 0===t?void 0:t.pdf_end_page_number]}):null},[null==M?void 0:M.title,null==M?void 0:M.signed_url,null==W?void 0:W.highlighted_text,null===(a=null==W?void 0:W.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(d=null==W?void 0:W.custom_metadata)||void 0===d?void 0:d.pdf_end_page_number]),V=h(function(){var i,n,o,t;return H&&A?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==A?void 0:A.title,pdfUrl:null==A?void 0:A.signed_url,jumpToPageValue:1,highlightText:[null!==(i=null==H?void 0:H.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==H?void 0:H.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(o=null==H?void 0:H.custom_metadata)||void 0===o?void 0:o.pdf_start_page_number,null===(t=null==H?void 0:H.custom_metadata)||void 0===t?void 0:t.pdf_end_page_number]}):null},[null==A?void 0:A.title,null==A?void 0:A.signed_url,null==H?void 0:H.highlighted_text,null===(u=null==H?void 0:H.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(c=null==H?void 0:H.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]),B="dual_citation"===m,O=B&&!!(null==v?void 0:v.webGpt),L=h(function(){if(!z)return null;var n=O?e(U,{metaData:v,isFullscreen:b}):"rulebook_citation"===m?e(l,{children:e(C,i({sx:i(i({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},F),{overflow:"auto"})},{children:e(_,i({rehypePlugins:[y]},{children:P({guidelinesData:w,targetHighlights:[k],labelColor:"#FEF08A"})}))}))}):V;return n?e(g,{leftComponent:z,rightComponent:n,isFullscreen:b}):z},[z,V,m,O,v,b]);return(null==v?void 0:v.webGpt)&&!N?e(U,{metaData:v,isFullscreen:b}):T?"rulebook_citation"===m?e("div",W?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:L}):i({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:x||"Rulebook citation selected."})):B?W||H?e("div",i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:L})):(null==v?void 0:v.webGpt)?e(U,{metaData:v,isFullscreen:b}):e("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(p)?e("div",W||H?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:L}):{children:"Missing PDF Citation. Please try again later"}):e("div",{children:"No Citation Found. Please try again later"}):null},H=function(n){var o,l,u,c,s,h,m,g=n.href,f=n.children,_=n.citationType,y=n.citationReason,C=n.metaData,F=n.chevronUpComponent,D=void 0===F?null:F,P=n.chevronDownComponent,S=void 0===P?null:P,T=n.customStyle,k=void 0===T?{}:T,j=n.defaultState,I=void 0!==j&&j,G=n.onFullscreenChange,N=v(I),E=N[0],M=N[1],A=v(!1),U=A[0],H=A[1],z="string"==typeof f&&(null===(o=null==f?void 0:f.split("\n"))||void 0===o?void 0:o.length)>1?f.split("\n").join(" "):f;p(function(){if(null==G||G(U),U)return function(){null==G||G(!1)}},[U,G]);var V="string"==typeof f?f:f[0],B=null!=D?D:function(i){var n,o;return e(a,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(o=null==i?void 0:i.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(l=null==k?void 0:k.arrow)&&void 0!==l?l:{}),O=null!=S?S:function(i){var n,o;return e(d,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(o=null==i?void 0:i.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(u=null==k?void 0:k.arrow)&&void 0!==u?u:{}),L=t("div",i({style:{boxSizing:"border-box",border:U?"none":"1px solid #E4E7EC",borderRadius:U?0:"8px",overflow:"hidden",marginTop:U?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:U?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:e("button",i({onClick:function(){H(function(i){return!i})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:e(U?x:b,{})}))})),e("div",i({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:e(W,{href:g,children:f,metaData:C,citationTitle:V,citationType:_,citationReason:y,isFullscreen:U})}))]}));return t("span",i({style:i({display:"inline"},k.relativeWrapper||{})},{children:[e("div",i({style:i({display:"inline",marginTop:0},k.citationButtonWrapper||{})},{children:t("button",i({type:"button",onClick:function(){return M(function(i){return!i})},style:i({display:(null==C?void 0:C.webGpt)?"inline":"inline-flex",alignItems:(null==C?void 0:C.webGpt)?void 0:"center",gap:(null==C?void 0:C.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==C?void 0:C.webGpt)?600:700,color:(null==C?void 0:C.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},k.citationButton||{})},{children:[(null==C?void 0:C.webGpt)&&e(r,{size:null!==(s=null===(c=k.arrow)||void 0===c?void 0:c.fontSize)&&void 0!==s?s:"1em",color:null!==(m=null===(h=k.arrow)||void 0===h?void 0:h.color)&&void 0!==m?m:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e("span",{children:z}),e("span",i({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==C?void 0:C.webGpt)?"3px":void 0,verticalAlign:(null==C?void 0:C.webGpt)?"-0.125em":void 0}},{children:E?B:O}))]}))})),E&&(U?e(w,i({open:U,onClose:function(){return H(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:R,m:0,maxHeight:R,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:L})):L)]}))};export{H as default};
|
|
1
|
+
import{__assign as i,__awaiter as n,__generator as t}from"tslib";import{jsxs as o,jsx as e,Fragment as l}from"react/jsx-runtime";import{Globe as r,ChevronUp as a,ChevronDown as d,Maximize2 as u,X as c,ExternalLink as s}from"lucide-react";import{useState as v,useEffect as p,useMemo as m,useRef as h}from"react";import g from"./ResizableSplitPane.js";import f from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as b,DefaultFullScreenIcon as x}from"../../assests/svg/PdfViewerIcons.js";import _ from"react-markdown";import y from"rehype-raw";import{Dialog as w,Box as C}from"@mui/material";import{SHARED_MARKDOWN_STYLES as F}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as D}from"./CompareContext.js";import{processGuidelinesMarkdown as P}from"./Guidelines/utils/processGuidelinesMarkdown.js";import T from"../GptWebCitation/GptWebCitation.js";import{CitationType as S}from"../GptWebCitation/types.js";import"./MoreFunctionsPopup.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";var k=function(i){var n,t,o;return(null===(o=null===(t=null===(n=(null==i?void 0:i.extraMetaData)||i)||void 0===n?void 0:n.aiReasoningCitation)||void 0===t?void 0:t.gpt_citation)||void 0===o?void 0:o[0])||null},N="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",j="sai.siddhartha@techolution.com",I="672e32f7a0e8fe2e8e50bcba",R="TNV Sai Siddhartha",G="90vh",U="calc(".concat(G," - 120px)"),E=function(){var i;return"function"==typeof(null===(i=globalThis.crypto)||void 0===i?void 0:i.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var n=Math.floor(16*Math.random());return("x"===i?n:n%4+8).toString(16)})},M=function(i,n){var t=function(i){var n;return(null==i?void 0:i.payloadCitationId)||(null===(n=null==i?void 0:i.extraMetaData)||void 0===n?void 0:n.payloadCitationId)||""}(i)||n||E();return function(i,n){i&&"object"==typeof i&&(i.payloadCitationId=n,i.extraMetaData&&"object"==typeof i.extraMetaData&&(i.extraMetaData.payloadCitationId=n))}(i,t),t},A=function(o){var l,r=o.metaData,g=o.isFullscreen,f=void 0!==g&&g,b=D().gptWebCitationConfig,x=m(function(){return function(i){return{endpoint:(null==i?void 0:i.endpoint)||N,userEmail:(null==i?void 0:i.userEmail)||j,userId:(null==i?void 0:i.userId)||I,userName:(null==i?void 0:i.userName)||R,headers:null==i?void 0:i.headers}}(b)},[b]),_=null==r?void 0:r.webGpt,y=h(null);y.current||(y.current=E());var w=m(function(){return function(i,n,t){var o,e,l=k(i),r=(null==l?void 0:l.customMetaData)||{},a=(null==r?void 0:r.value)||{},d=(null==i?void 0:i.webSearchAnswer)||{},u=(null==i?void 0:i.extraMetaData)||i||{};return{userEmail:(null==i?void 0:i.userEmail)||(null==d?void 0:d.userEmail)||(null==n?void 0:n.userEmail)||"",userId:(null==i?void 0:i.userId)||(null==d?void 0:d.userId)||(null==n?void 0:n.userId)||"",userName:(null==i?void 0:i.userName)||(null==d?void 0:d.userName)||(null==n?void 0:n.userName)||"",citationId:M(i,t),citationUrl:(null==a?void 0:a.citationUrl)||(null==d?void 0:d.citationUrl)||"",content:(null==u?void 0:u.Reasoning)||(null==d?void 0:d.enhanced_content)||"",citationType:(null==a?void 0:a.citationType)||"web",citatioNumber:null!==(e=null!==(o=null==r?void 0:r.citation_number)&&void 0!==o?o:null==l?void 0:l.citation_number)&&void 0!==e?e:Number((null==i?void 0:i.reasoningId)||0)}}(_,x,y.current||void 0)},[_,x]),C=m(function(){return k(_)},[_]),F=(null===(l=null==C?void 0:C.customMetaData)||void 0===l?void 0:l.value)||{},P=(null==_?void 0:_.extraMetaData)||_||{},G=v(),A=G[0],H=G[1],W=v("pending"),z=W[0],O=W[1],V=v(!0),B=V[0],L=V[1];p(function(){var o=!0;return n(void 0,void 0,void 0,function(){var n,e,l,r;return t(this,function(t){switch(t.label){case 0:if(!x.endpoint||!(null==w?void 0:w.citationUrl)||!(null==w?void 0:w.content))return O("error"),[2];O("pending"),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,fetch(x.endpoint,{method:"POST",headers:i({"actor-id":w.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},x.headers||{}),body:JSON.stringify(w)})];case 2:if(!(n=t.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return e=t.sent(),l=(null==e?void 0:e.responseData)||(null==e?void 0:e.result)||(null==e?void 0:e.data)||e,o?(H(l),O("success"),[3,5]):[2];case 4:return r=t.sent(),o?(console.error("Failed to load GPT web citation",r),O("error"),[3,5]):[2];case 5:return[2]}})}),function(){o=!1}},[w,x]);var J=m(function(){return{item:{confidence_score:Number((null==P?void 0:P.Confidence_score)||0),text:(null==F?void 0:F.paraphrase)||"Web citation reasoning",dataSource:(null==F?void 0:F.text)||(null==P?void 0:P.Reasoning)||"",paraphrase:(null==F?void 0:F.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==w?void 0:w.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:d,ChevronUpIcon:a,MaximizeIcon:u,CloseIcon:c}}},[F,null==w?void 0:w.citatioNumber,P]),$=m(function(){return i(i({},J),f?{bodyHeight:U}:{})},[J,f]);return e(T,{gptCitation:$,defaultCitationUrl:(null==w?void 0:w.citationUrl)||"",citationType:S.GPT_WEB,webCitationData:A,webCitationStatus:z,showWebCitation:B,onToggleCitationView:function(){return L(function(i){return!i})},iconsConfig:{MaximizeIcon:u,ExternalLinkIcon:s},isFixedHeight:!0})},H=function(n){var t,o,r,a,d,u,c,s=n.href,v=n.metaData,p=n.citationTitle,h=n.citationType,b=n.citationReason,x=n.isFullscreen,w=D().guidelinesData,T=function(i){try{var n=function(i){var n=i.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(n)try{var t=i.indexOf("?"),o=t>=0?i.slice(t):"";return{citationNumber:n[1],parsedUrl:new URL(o||"./",window.location.origin)}}catch(i){return{citationNumber:n[1],parsedUrl:null}}try{var e=new URL(i,window.location.origin);return{citationNumber:e.searchParams.get("citationNumber")||e.searchParams.get("citation_number"),parsedUrl:e}}catch(i){return{citationNumber:null,parsedUrl:null}}}(i),t=n.citationNumber,o=n.parsedUrl;return{citationNumber:t,phraseToHighlight:(null==o?void 0:o.searchParams.get("phrase_to_highlight"))||null,citationTypeFromHref:(null==o?void 0:o.searchParams.get("citation_type"))||null}}catch(i){return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}}(s),S=T.citationNumber,k=T.phraseToHighlight,N=T.citationTypeFromHref,j=h||N||void 0,I="il_rulebook_citation"===j?"rulebook_citation":j,R=S&&(null===(t=null==v?void 0:v.citations)||void 0===t?void 0:t[S])||{},G=(null===(o=null==v?void 0:v.docData)||void 0===o?void 0:o.documents)||{},U=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},E=Object.keys((null==v?void 0:v.citations)||{}).length>0||Object.keys((null==v?void 0:v.docData)||{}).length>0,M=null==U?void 0:U[0],H=null==U?void 0:U[1],W=M?G[M]:null,z=H?G[H]:null,O=M?R[M]:null,V=H?R[H]:null,B=m(function(){var i,n,t,o;return O&&W?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==W?void 0:W.title,pdfUrl:null==W?void 0:W.signed_url,highlightText:[null!==(i=null==O?void 0:O.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==O?void 0:O.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==O?void 0:O.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==O?void 0:O.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==W?void 0:W.title,null==W?void 0:W.signed_url,null==O?void 0:O.highlighted_text,null===(a=null==O?void 0:O.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(d=null==O?void 0:O.custom_metadata)||void 0===d?void 0:d.pdf_end_page_number]),L=m(function(){var i,n,t,o;return V&&z?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==z?void 0:z.title,pdfUrl:null==z?void 0:z.signed_url,jumpToPageValue:1,highlightText:[null!==(i=null==V?void 0:V.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==V?void 0:V.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==V?void 0:V.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==V?void 0:V.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==z?void 0:z.title,null==z?void 0:z.signed_url,null==V?void 0:V.highlighted_text,null===(u=null==V?void 0:V.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(c=null==V?void 0:V.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]),J="dual_citation"===I,$=J&&!!(null==v?void 0:v.webGpt),q=m(function(){if(!B)return null;var n=$?e(A,{metaData:v,isFullscreen:x}):"rulebook_citation"===I?e(l,{children:e(C,i({sx:i(i({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},F),{overflow:"auto"})},{children:e(_,i({rehypePlugins:[y]},{children:P({guidelinesData:w,targetHighlights:[k],labelColor:"#FEF08A"})}))}))}):L;return n?e(g,{leftComponent:B,rightComponent:n,isFullscreen:x}):B},[B,L,I,$,v,x,w,k]);return(null==v?void 0:v.webGpt)&&!E?e(A,{metaData:v,isFullscreen:x}):S?"rulebook_citation"===I?e("div",O?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):i({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:b||"Rulebook citation selected."})):J?O||V?e("div",i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q})):(null==v?void 0:v.webGpt)?e(A,{metaData:v,isFullscreen:x}):e("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(p)?e("div",O||V?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):{children:"Missing PDF Citation. Please try again later"}):e("div",{children:"No Citation Found. Please try again later"}):null},W=function(n){var t,l,u,c,s,m,h,g=n.href,f=n.children,_=n.citationType,y=n.citationReason,C=n.metaData,F=n.chevronUpComponent,D=void 0===F?null:F,P=n.chevronDownComponent,T=void 0===P?null:P,S=n.customStyle,k=void 0===S?{}:S,N=n.defaultState,j=void 0!==N&&N,I=n.onFullscreenChange,R=v(j),U=R[0],E=R[1],M=v(!1),A=M[0],W=M[1],z="string"==typeof f&&(null===(t=null==f?void 0:f.split("\n"))||void 0===t?void 0:t.length)>1?f.split("\n").join(" "):f;p(function(){if(null==I||I(A),A)return function(){null==I||I(!1)}},[A,I]);var O="string"==typeof f?f:f[0],V=null!=D?D:function(i){var n,t;return e(a,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(l=null==k?void 0:k.arrow)&&void 0!==l?l:{}),B=null!=T?T:function(i){var n,t;return e(d,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(u=null==k?void 0:k.arrow)&&void 0!==u?u:{}),L=o("div",i({style:{boxSizing:"border-box",border:A?"none":"1px solid #E4E7EC",borderRadius:A?0:"8px",overflow:"hidden",marginTop:A?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:A?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:e("button",i({onClick:function(){W(function(i){return!i})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:e(A?b:x,{})}))})),e("div",i({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:e(H,{href:g,children:f,metaData:C,citationTitle:O,citationType:_,citationReason:y,isFullscreen:A})}))]}));return o("span",i({style:i({display:"inline"},k.relativeWrapper||{})},{children:[e("div",i({style:i({display:"inline",marginTop:0},k.citationButtonWrapper||{})},{children:o("button",i({type:"button",onClick:function(){return E(function(i){return!i})},style:i({display:(null==C?void 0:C.webGpt)?"inline":"inline-flex",alignItems:(null==C?void 0:C.webGpt)?void 0:"center",gap:(null==C?void 0:C.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==C?void 0:C.webGpt)?600:700,color:(null==C?void 0:C.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},k.citationButton||{})},{children:[(null==C?void 0:C.webGpt)&&e(r,{size:null!==(s=null===(c=k.arrow)||void 0===c?void 0:c.fontSize)&&void 0!==s?s:"1em",color:null!==(h=null===(m=k.arrow)||void 0===m?void 0:m.color)&&void 0!==h?h:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e("span",{children:z}),e("span",i({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==C?void 0:C.webGpt)?"3px":void 0,verticalAlign:(null==C?void 0:C.webGpt)?"-0.125em":void 0}},{children:U?V:B}))]}))})),U&&(A?e(w,i({open:A,onClose:function(){return W(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:G,m:0,maxHeight:G,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:L})):L)]}))};export{W as default};
|
|
2
2
|
//# sourceMappingURL=CitationAnchor.js.map
|