import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t,t as n}from"./jsx-runtime-CiQ1k8xo.js";import{t as r}from"./clsx-BcPLHiun.js";import{lt as i}from"./vscode-api-DjORcpSo.js";import{c as a,o}from"./lib-MoKmYgcO.js";import{t as s}from"./tooltip-BBqUFIYI.js";import{t as c}from"./button-Bi7lGVi1.js";import{t as l}from"./check-md-BzLzXDM7.js";import{t as u}from"./copy-d11cB-0i.js";var d=i(),f=e(t(),1);function p(){let e=(0,d.c)(3),t=(0,f.useRef)(!1),n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>(t.current=!0,()=>{t.current=!1}),r=[],e[0]=n,e[1]=r):(n=e[0],r=e[1]),(0,f.useEffect)(n,r);let i;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>t.current,e[2]=i):i=e[2],i}var m=n();function h(e){let t=(0,d.c)(27),{buttonText:n,shouldChangeText:i,iconClassName:h,Icon:g,onCopy:_,className:v,iconOnly:y,textPosition:b}=e,x=i===void 0?!0:i,S=h===void 0?`icon-sm`:h,C=g===void 0?u:g,w=y===void 0?!1:y,T=b===void 0?`right`:b,E=a(),[D,O]=(0,f.useState)(!1),k=p(),A;t[0]!==k||t[1]!==_?(A=e=>{e.stopPropagation(),_(e),O(!0),setTimeout(()=>{k()&&O(!1)},2e3)},t[0]=k,t[1]=_,t[2]=A):A=t[2];let j=A,M=n;if(x&&D){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,m.jsx)(o,{id:`copyButton.copied`,defaultMessage:`Copied`,description:`Text displayed when the content has been copied`}),t[3]=e):e=t[3],M=e}else if(n===!0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,m.jsx)(o,{id:`copyButton.copy`,defaultMessage:`Copy`,description:`Text displayed when the content can be copied`}),t[4]=e):e=t[4],M=e}let N;t[5]!==C||t[6]!==n||t[7]!==v||t[8]!==D||t[9]!==j||t[10]!==S||t[11]!==w||t[12]!==E||t[13]!==M||t[14]!==T?(N=!D&&(0,m.jsx)(s,{tooltipContent:n??(0,m.jsx)(o,{id:`CopyButton.copyTooltip`,defaultMessage:`Copy`,description:`Tooltip on copy message icon button`}),disabled:!w,children:(0,m.jsxs)(c,{color:`ghost`,size:`icon`,onClick:j,className:v,"aria-label":E.formatMessage({id:`copyButton.copyAriaLabel`,defaultMessage:`Copy`,description:`Aria label for a button for content that can be copied`}),children:[T===`left`&&!w&&M,(0,m.jsx)(C,{className:S}),T===`right`&&!w&&M]})}),t[5]=C,t[6]=n,t[7]=v,t[8]=D,t[9]=j,t[10]=S,t[11]=w,t[12]=E,t[13]=M,t[14]=T,t[15]=N):N=t[15];let P;t[16]!==v||t[17]!==D||t[18]!==S||t[19]!==w||t[20]!==E||t[21]!==M||t[22]!==T?(P=D&&(0,m.jsxs)(c,{color:`ghost`,size:`icon`,className:r(`text-token-foreground`,v),"aria-label":E.formatMessage({id:`copyButton.copiedAriaLabel`,defaultMessage:`Copied`,description:`Aria label for a button state when text has been copied`}),children:[T===`left`&&!w&&M,(0,m.jsx)(l,{className:S}),T===`right`&&!w&&M]}),t[16]=v,t[17]=D,t[18]=S,t[19]=w,t[20]=E,t[21]=M,t[22]=T,t[23]=P):P=t[23];let F;return t[24]!==N||t[25]!==P?(F=(0,m.jsxs)(m.Fragment,{children:[N,P]}),t[24]=N,t[25]=P,t[26]=F):F=t[26],F}export{p as n,h as t};
//# sourceMappingURL=copy-button-BnCzhh_Q.js.map