import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{pt as t}from"./vendor-primevue-7po8Zk9v.js";import{l as n}from"./vendor-vueuse-ChSVzIZz.js";import{o as r}from"./i18n-DjEVEIh2.js";function useCopyToClipboard(){let{copy:e,copied:i}=n(),a=t(),showSuccessToast=()=>{a.add({severity:`success`,summary:r(`g.success`),detail:r(`clipboard.successMessage`),life:3e3})},showErrorToast=()=>{a.add({severity:`error`,summary:r(`g.error`),detail:r(`clipboard.errorMessage`)})};function fallbackCopy(e){let t=document.createElement(`textarea`);t.setAttribute(`readonly`,``),t.value=e,t.style.position=`absolute`,t.style.left=`-9999px`,t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`tabindex`,`-1`),t.style.width=`1px`,t.style.height=`1px`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`)?showSuccessToast():showErrorToast()}catch{showErrorToast()}finally{t.remove()}}let copyToClipboard=async t=>{try{await e(t),i.value?showSuccessToast():fallbackCopy(t)}catch{fallbackCopy(t)}};return{copyToClipboard}}export{useCopyToClipboard as t};
//# sourceMappingURL=useCopyToClipboard-CUuoo5Dm.js.map