import{__rest as n,__assign as t}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import{memo as r,useMemo as o,useCallback as a}from"react";import l from"./CitationLink.js";import{CognitiveDecisioningCard as c}from"@e-llm-studio/citation";import{ButtonCognitiveIcon as d}from"./_svg/ButtonCognitiveIcon.js";import{getSourceFromUrl as u}from"./MarkdownComponents/MarkdownElements.js";var p=r(function(r){var p=r.citation,f=r.citations;r.fieldName,r.fieldValue;var s=r.isVisible,g=void 0!==s&&s,m=function(n,t){var i,e="";if(!(e="string"==typeof t?t:(null===(i=null==t?void 0:t.customMetaData)||void 0===i?void 0:i.content)?t.customMetaData.content:String(t)))return null;var r=new RegExp("<".concat(n,"[^>]*>([\\s\\S]*?)<\\/").concat(n,">"),"i"),o=e.match(r);return o?o[1].replace(/\\n/g,"\n"):null},x=o(function(){return m("reason",p)},[p]),h=o(function(){return m("gap",p)},[p]),v=o(function(){return m("relevance_score",p)},[p]),y=a(function(n,t){return f&&f.find(function(i){return i.customMetaData.citation_number&&"Cognitive Decisioning"!==i.customMetaData.citation_title&&i.customMetaData.source===t&&String(i.customMetaData.citation_number)===String(n)})||null},[f]),S=o(function(){return{p:function(e){e.node;var r=n(e,["node"]);return i("p",t({},r,{style:{margin:0}},{children:null==r?void 0:r.children}))},li:function(r){r.node;var o=r.index,a=n(r,["node","index"]);return e("div",t({style:{display:"flex",alignItems:"flex-start",marginBottom:"6px"}},{children:[i("span",t({style:{fontSize:"12px",fontWeight:400,color:"#55585fff",flexShrink:0,minWidth:"18px"}},{children:"number"==typeof o?"".concat(o+1,"."):"•"})),i("span",t({style:{fontSize:"12px",color:"#4B5563",lineHeight:"1.5",flex:1}},{children:a.children}))]}))},a:function(e){e.node;var r=e.href,o=e.children,a=n(e,["node","href","children"]);if(!r)return i("a",t({},a,{children:o}));var c=r.match(/citationNumber=([^&]+)/),d=c?c[1]:null;if(d){var p=u(r),f=y(d,p);if(f)return i("span",t({style:{display:"inline",alignItems:"center",fontSize:"14px !important",gap:"3px",color:"#2563EB",verticalAlign:"middle"}},{children:i(l,{citation:f,linkTitle:o,fontSize:12})}))}return i("a",t({href:r,target:"_blank",rel:"noopener noreferrer",style:{color:"#2563EB",textDecoration:"none"}},a,{children:o}))}}},[y]),b=function(n){return n?n.replace(/(\[[^\]]+\]\()([^)]+)(\))/g,function(n,t,i,e){return"".concat(t).concat(i.replace(/\s/g,"%20")).concat(e)}).replace(/`([^`\n]+)`/g,"**$1**"):""},C=o(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 g?i(c,{headerIcon:i(d,{}),isOpen:!0,hideTrigger:!0,onToggle:function(){},reasoning:b(x)||"",gap:b(h)||"",score:v,mdComponents:S,styles:C}):null},function(n,t){return n.isVisible===t.isVisible&&n.fieldValue===t.fieldValue&&n.fieldName===t.fieldName&&JSON.stringify(n.citation)===JSON.stringify(t.citation)&&JSON.stringify(n.citations)===JSON.stringify(t.citations)});p.displayName="InputDataReasoningCard";export{p as InputDataReasoningCard};
//# sourceMappingURL=InputDataReasoningCard.js.map
