import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{ov as a}from"./shared-0-C4kdVF7Y.js";import{Ei as s,Mi as t,ki as r}from"./vendor-frame-CwiylG4Y.js";import{nn as i,rn as n}from"./vendor-all-2-BJdkbLSj.js";import{Ln as l}from"./vendor-all-6-BsAVZMtu.js";import{Cc as o,Dr as d,Mr as m,jr as c}from"./shared-5-UQAFGbWu.js";import{i as u,r as f,t as g}from"./c18e80207-fe73_kvz.js";var b=e(t(),1),x=new Map([["regular",b.createElement(b.Fragment,null,b.createElement("path",{d:"M96.26,37.05A8,8,0,0,1,102,27.29a104.11,104.11,0,0,1,52,0,8,8,0,0,1-2,15.75,8.15,8.15,0,0,1-2-.26,88.09,88.09,0,0,0-44,0A8,8,0,0,1,96.26,37.05ZM53.79,55.14a104.05,104.05,0,0,0-26,45,8,8,0,0,0,15.42,4.27,88,88,0,0,1,22-38.09A8,8,0,0,0,53.79,55.14ZM43.21,151.55a8,8,0,1,0-15.42,4.28,104.12,104.12,0,0,0,26,45,8,8,0,0,0,11.41-11.22A88.14,88.14,0,0,1,43.21,151.55ZM150,213.22a88,88,0,0,1-44,0,8,8,0,1,0-4,15.49,104.11,104.11,0,0,0,52,0,8,8,0,0,0-4-15.49ZM222.65,146a8,8,0,0,0-9.85,5.58,87.91,87.91,0,0,1-22,38.08,8,8,0,1,0,11.42,11.21,104,104,0,0,0,26-45A8,8,0,0,0,222.65,146Zm-9.86-41.54a8,8,0,0,0,15.42-4.28,104,104,0,0,0-26-45,8,8,0,1,0-11.41,11.22A88,88,0,0,1,212.79,104.45Z"}))]]),v=b.forwardRef((e,a)=>b.createElement(l,{ref:a,...e,weights:x}));v.displayName="CircleDashedIcon";var j=v,p=r();function M({toolUseId:e,input:t,toolResult:r,isStreaming:l,shareType:x}){const v=n(),M=(0,b.useMemo)(()=>f(t),[t]),{chatResourceState:{files:h,selectedItem:N}}=c(),w=m(),{setIsDrawerExpanded:A}=d(),E=a("(min-width: 768px)"),I=(0,b.useMemo)(()=>M?g(h,M.imageIndex):void 0,[h,M]),y=(0,b.useCallback)((a,s,t)=>{A(!0),t&&o.getState().setTriggerElement(t),w({type:"SELECT_IMAGE_ANNOTATION",toolUseId:e??"",file:s,annotation:a})},[w,A,e]),L=(0,b.useRef)(!1),T=(0,b.useRef)(void 0===r),C=void 0!==r&&!r.is_error;if((0,b.useEffect)(()=>{!L.current&&T.current&&C&&E&&!x&&M&&I&&(L.current=!0,y(M,I,null))},[C,E,x,M,I,y]),r?.is_error||!M)return null;const R="image_annotation"===N?.type&&N.toolUseId===e,Z=Boolean(I),_=l&&void 0===r,k=M.label?u(M.label):null;return(0,p.jsx)("div",{className:"my-3",children:(0,p.jsxs)("button",{type:"button",disabled:!Z,"aria-expanded":R,onClick:e=>I&&y(M,I,e.currentTarget),className:"group/annotation flex w-full max-w-md items-center gap-3 rounded-lg border-0.5 border-border-300 bg-bg-000 p-2 text-left transition hover:border-border-200 hover:bg-bg-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-200 disabled:cursor-default disabled:hover:border-border-300 disabled:hover:bg-bg-000","aria-label":k?v.formatMessage({defaultMessage:"Open annotated image: {label}",id:"M7HJaTn8JL"},{label:k}):v.formatMessage({defaultMessage:"Open annotated image",id:"RfjCWNL9cB"}),children:[(0,p.jsx)("div",{className:"size-12 shrink-0 overflow-hidden rounded-md bg-bg-200",children:I?(0,p.jsx)("img",{src:I.thumbnail_asset.url,alt:"",className:"size-full select-none object-cover",draggable:!1}):(0,p.jsx)("div",{className:"flex size-full items-center justify-center text-text-400",children:(0,p.jsx)(j,{size:20})})}),(0,p.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,p.jsx)("div",{className:s("truncate text-sm font-medium text-text-100",_&&"animate-pulse"),children:_?(0,p.jsx)(i,{defaultMessage:"Annotating image\u2026",id:"aMi61Pj/D3"}):k||(0,p.jsx)(i,{defaultMessage:"Annotated image",id:"wL51Js4/qx"})}),(0,p.jsx)("div",{className:"truncate text-xs text-text-400",children:I?(0,p.jsx)(i,{defaultMessage:"Annotated image",id:"wL51Js4/qx"}):(0,p.jsx)(i,{defaultMessage:"Image not available",id:"Y7FG5MdL98"})})]})]})})}export{M as ImageAnnotationToolUseCell};