"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),t=require("react"),i=require("./CitationLink.js"),r=require("@e-llm-studio/citation"),o=require("./_svg/ButtonCognitiveIcon.js"),a=require("./MarkdownComponents/MarkdownElements.js"),s=t.memo(function(s){var l=s.citation,c=s.citations;s.fieldName,s.fieldValue;var u=s.isVisible,d=void 0!==u&&u,g=function(n,e){var t,i="";if(!(i="string"==typeof e?e:(null===(t=null==e?void 0:e.customMetaData)||void 0===t?void 0:t.content)?e.customMetaData.content:String(e)))return null;var r=new RegExp("<".concat(n,"[^>]*>([\\s\\S]*?)<\\/").concat(n,">"),"i"),o=i.match(r);return o?o[1].replace(/\\n/g,"\n"):null},p=t.useMemo(function(){return g("reason",l)},[l]),f=t.useMemo(function(){return g("gap",l)},[l]),x=t.useMemo(function(){return g("relevance_score",l)},[l]),m=t.useCallback(function(n,e){return c&&c.find(function(t){return t.customMetaData.citation_number&&"Cognitive Decisioning"!==t.customMetaData.citation_title&&t.customMetaData.source===e&&String(t.customMetaData.citation_number)===String(n)})||null},[c]),_=t.useMemo(function(){return{p:function(t){t.node;var i=n.__rest(t,["node"]);return e.jsx("p",n.__assign({},i,{style:{margin:0}},{children:null==i?void 0:i.children}))},li:function(t){t.node;var i=t.index,r=n.__rest(t,["node","index"]);return e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"flex-start",marginBottom:"6px"}},{children:[e.jsx("span",n.__assign({style:{fontSize:"12px",fontWeight:400,color:"#55585fff",flexShrink:0,minWidth:"18px"}},{children:"number"==typeof i?"".concat(i+1,"."):"•"})),e.jsx("span",n.__assign({style:{fontSize:"12px",color:"#4B5563",lineHeight:"1.5",flex:1}},{children:r.children}))]}))},a:function(t){t.node;var r=t.href,o=t.children,s=n.__rest(t,["node","href","children"]);if(!r)return e.jsx("a",n.__assign({},s,{children:o}));var l=r.match(/citationNumber=([^&]+)/),c=l?l[1]:null;if(c){var u=a.getSourceFromUrl(r),d=m(c,u);if(d)return e.jsx("span",n.__assign({style:{display:"inline",alignItems:"center",fontSize:"14px !important",gap:"3px",color:"#2563EB",verticalAlign:"middle"}},{children:e.jsx(i.default,{citation:d,linkTitle:o,fontSize:12})}))}return e.jsx("a",n.__assign({href:r,target:"_blank",rel:"noopener noreferrer",style:{color:"#2563EB",textDecoration:"none"}},s,{children:o}))}}},[m]),h=function(n){return n?n.replace(/(\[[^\]]+\]\()([^)]+)(\))/g,function(n,e,t,i){return"".concat(e).concat(t.replace(/\s/g,"%20")).concat(i)}).replace(/`([^`\n]+)`/g,"**$1**"):""},v=t.useMemo(function(){return{header:{backgroundColor:"#F5F3FF",padding:"8px 16px"},sectionButton:{paddingLeft:"24px",paddingRight:"24px",paddingBottom:"12px"},textContent:{fontSize:"12px",paddingLeft:"30px",paddingRight:"24px",paddingBottom:"20px"},badge:{fontSize:"11px",color:"#1E293B",borderColor:"#C4B5FD",padding:"8px 8px"},pill:{gap:"2px",border:"none",backgroundColor:"transparent"}}},[]);return d?e.jsx(r.CognitiveDecisioningCard,{headerIcon:e.jsx(o.ButtonCognitiveIcon,{}),isOpen:!0,hideTrigger:!0,onToggle:function(){},reasoning:h(p)||"",gap:h(f)||"",score:x,mdComponents:_,styles:v}):null},function(n,e){return n.isVisible===e.isVisible&&n.fieldValue===e.fieldValue&&n.fieldName===e.fieldName&&JSON.stringify(n.citation)===JSON.stringify(e.citation)&&JSON.stringify(n.citations)===JSON.stringify(e.citations)});s.displayName="InputDataReasoningCard",exports.InputDataReasoningCard=s;
//# sourceMappingURL=InputDataReasoningCard.js.map
