import{__assign as e}from"tslib";import{jsxs as n,jsx as i}from"react/jsx-runtime";import{forwardRef as o,useRef as t,useCallback as r,useEffect as l}from"react";import a from"../../_svg/CognitiveDecisioning.js";import{AlertTriangle as c,ChevronUpIcon as s,ChevronDownIcon as d}from"lucide-react";import p from"../../TooltipComponent.js";import{ConflictReasoningCard as u}from"../../ConflictingReasoningCard.js";var x=o(function(o,x){var g=o.rows,f=void 0===g?1:g,h=o.placeholder,m=o.value,b=o.onChange,v=o.onFocus,y=o.isHighlighted,w=void 0!==y&&y,C=o.customClass,k=o.showNumber,z=o.numberIndex,S=o.isReadOnly,I=void 0!==S&&S,R=o.isOpen,T=void 0!==R&&R,E=o.onToggle,D=o.showCognitiveIcon,j=void 0!==D&&D,F=o.cognitiveIcon,M=o.tooltipDescription,O=o.isConflicting,H=o.conflictMsg,L=o.conflictingReasoning,N=o.decisionStrength,V=o.conflictingGap,W=o.errorMessage,A=o.inputReadOnly,B=void 0!==A&&A,G=o.citations,Y=void 0===G?[]:G,_=function(){return F||i(a,{})},q=t(null),J=r(function(e){e.style.height="auto",e.style.height="".concat(e.scrollHeight,"px")},[]);l(function(){var e=function(){q.current&&J(q.current)};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[J]);var K=r(function(e){q.current=e,x&&("function"==typeof x?x(e):x.current=e),e&&J(e)},[x,J]);return n("div",e({style:{width:"100%"}},{children:[n("div",e({style:{display:"flex",flexDirection:"column",width:"100%",border:"1px solid ".concat(O||W?"#ef4444":w?"#2563EB":"#ccc"),borderRadius:"0.5rem",backgroundColor:I?"#f9fafb":"white",opacity:I?.8:1,cursor:I?"not-allowed":"text",pointerEvents:"auto",transition:"all 0.3s ease-in-out",overflow:"hidden",boxShadow:O&&w?"0 0 20px 3px rgba(239, 68, 68, 0.45)":w?"\n          0 0 12px 3px rgba(37, 99, 235, 0.3),\n          -6px 0 10px rgba(37, 99, 235, 0.2),\n          6px 0 10px rgba(37, 99, 235, 0.2)\n        ":"none"},onMouseEnter:function(e){w||O||I||(e.currentTarget.style.border="1px solid black"),I&&(e.currentTarget.style.cursor="not-allowed")},onMouseLeave:function(e){w||O||I||(e.currentTarget.style.border="1px solid #ccc")}},{children:[i("div",e({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:O&&H&&i("div",e({style:{padding:"12px 12px 0 12px"}},{children:n("div",e({style:{display:"inline-flex",alignItems:"center",gap:"6px",backgroundColor:"#FFE9E980",padding:"4px 10px",borderRadius:"16px",color:"#b91c1c",fontSize:"12px",fontWeight:500}},{children:[i(c,{size:14,strokeWidth:2}),H]}))}))})),n("div",e({style:{display:"flex",alignItems:"flex-start"}},{children:[k&&void 0!==z&&n("span",e({style:{fontSize:"14px",padding:"12px 0",width:"40px",textAlign:"center",color:"#666"}},{children:[z,"."]})),i("textarea",{ref:K,rows:f,placeholder:h,className:"textarea ".concat(C),value:m,onChange:b,onFocus:v,readOnly:B,style:{border:"none",background:"transparent",flex:1,padding:"12px 12px 12px 12px",fontFamily:"inherit",fontSize:"14px",color:"#101828",resize:"both",width:"100%",boxSizing:"border-box",maxHeight:"200px",overflowY:"auto",outline:"none",display:"block",margin:"0 auto",alignSelf:"center",cursor:B?"default":"text"},onInput:function(e){return J(e.target)}}),O&&L&&i(p,e({description:"View Conflict Details"},{children:n("button",e({onClick:function(e){e.preventDefault(),null==E||E()},style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",border:"none",backgroundColor:"transparent",borderRadius:"4px",margin:"8px",cursor:"pointer",flexShrink:0}},{children:[_(),i(T?s:d,{size:14})]}))})),j&&!O&&i(p,e({description:null!=M?M:""},{children:n("button",e({onClick:function(e){e.preventDefault(),null==E||E()},style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",border:"none",backgroundColor:"transparent",borderRadius:"4px",margin:"8px",cursor:"pointer",flexShrink:0}},{children:[_(),i(T?s:d,{size:14})]}))}))]}))]})),O&&T&&i("div",e({style:{marginTop:"8px"}},{children:i(u,{isVisible:!0,decisionStrength:N,reasoning:L,gap:V,citations:Y})})),W&&i("div",e({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:W}))]}))});x.displayName="Textarea";export{x as Textarea};
//# sourceMappingURL=Textarea.js.map
