import{o as s}from"./rolldown-runtime-iuO8RvI4.js";import{Eh as e}from"./shared-0-C4kdVF7Y.js";import{Mi as i,ki as t}from"./vendor-frame-CwiylG4Y.js";import{Am as a,Mh as r,Pm as o,Sr as n}from"./shared-1-3-6x7RKF.js";import{rn as c}from"./vendor-all-2-BJdkbLSj.js";import{w as d}from"./shared-frame-DbQbH4Yr.js";import{a as l,r as m}from"./c147e6f61-W6WnVYX9.js";import{Po as p}from"./shared-4-6CEyRAHb.js";import{Kt as f,Wt as h,tn as u}from"./shared-8-C1HP2d2B.js";var j=s(i()),x=t();function b({isOpen:s,onClose:i,recipe:t,toolUseId:b,messageUuid:v,conversationUuid:g,publishedArtifactUuid:C}){const U=c(),{publishedArtifactsBaseUrl:_}=e(),{copyToClipboard:A}=p(),{addError:P}=r(),{mutateAsync:S,isPending:k}=f(),[y,$]=(0,j.useState)(),w=C??y,R=!!w,z=`${_}/public/artifacts/${w}`,E=(0,j.useCallback)(()=>{const s=u(t);s?S({title:t.title??"",artifact_type:n.Recipe,message_uuid:v,conversation_uuid:g,artifact_identifier:h(b),content:s}).then(({published_artifact_uuid:s})=>{$(s),A(`${_}/public/artifacts/${s}`)}).catch(()=>{}):P(o({id:"1q4xfo9",intl:U}))},[S,t,v,g,b,A,_,P,U]);return(0,x.jsx)(d.Root,{open:s,onOpenChange:s=>{s||i()},children:(0,x.jsxs)(d.Popup,{size:"lg",children:[(0,x.jsx)(d.Header,{showClose:!0,children:R?(0,x.jsx)(a,{id:"1xvcvim"}):(0,x.jsx)(a,{id:"1biepfz"})}),(0,x.jsx)("div",{className:"mt-2 flex flex-col gap-2.5",children:R?(0,x.jsx)(m,{artifactUuid:w,publishedLink:z,onClose:i,hideRepublishNote:!0}):(0,x.jsx)(l,{canScreenshot:!1,title:t.title??"",isLoading:k,fetchScreenshot:async()=>{},setScreenshot:()=>{},handlePublishArtifact:E})})]})})}export{b as RecipePublishModal};