import{aj as t,aJ as e,k as o,E as a,e as i}from"./vendor-element-plus.js?ver=3.1.10";import{aQ as s,W as n,Y as c,a5 as p,ab as l,a8 as r}from"./vendor.js?ver=3.1.10";import{_ as d,I as u}from"./fc-bits-ui.js?ver=3.1.10";const m=d({name:"ItemCopier",components:{Icons:u,Check:t},props:{text:{type:String,required:!0},showViewButton:{type:Boolean,default:!1}},data:()=>({copy_success:!1}),computed:{copyTooltipText(){return this.copy_success?this.$t("Copied"):this.$t("Copy")},viewTooltipText(){return this.$t("View in new tab")}},methods:{copyItem(){this.copy_success=!1;const t=this.text;let e=!1;if(window.clipboardData&&window.clipboardData.setData)window.clipboardData.clipboardData.setData("Text",t),e=!0;else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){const a=document.createElement("textarea");a.textContent=t,a.style.position="fixed",document.body.appendChild(a),a.select();try{document.execCommand("copy"),e=!0}catch(o){console.warn("Copy to clipboard failed.",o),e=!1}finally{document.body.removeChild(a)}}e?(this.copy_success=!0,this.$notify({message:this.$t("Copied to your clipboard"),position:"bottom-right",customClass:"bottom_right",type:"success"}),setTimeout(()=>{this.copy_success=!1},2e3)):this.$notify({message:this.$t("Your Browser does not support JS copy. Please copy manually"),position:"bottom-right",customClass:"bottom_right",type:"error"})},openUrl(){if(this.text){const t=window.open(this.text,"_blank");t&&(t.opener=null)}}}},[["render",function(t,d,u,m,y,h){const b=s("Check"),f=a,v=s("Icons"),w=o,C=e,x=i;return n(),c(x,{size:"small",readonly:!0,"model-value":u.text,"aria-label":t.$t("Copyable item value"),class:"fc-item-copier-input"},{append:p(()=>[l(C,{content:h.copyTooltipText,placement:"top"},{default:p(()=>[l(w,{class:"copy-btn","native-type":"button","aria-label":h.copyTooltipText,onClick:h.copyItem},{default:p(()=>[y.copy_success?(n(),c(f,{key:0,"aria-hidden":"true"},{default:p(()=>[l(b)],void 0,!0),_:1})):(n(),c(v,{key:1,"icon-name":"duplicate","aria-hidden":"true"}))],void 0,!0),_:1},8,["aria-label","onClick"])],void 0,!0),_:1},8,["content"]),u.showViewButton?(n(),c(C,{key:0,content:h.viewTooltipText,placement:"top"},{default:p(()=>[l(w,{type:"primary",class:"view-btn","native-type":"button","aria-label":h.viewTooltipText,onClick:h.openUrl},{default:p(()=>[l(v,{"icon-name":"externalLink","aria-hidden":"true"})],void 0,!0),_:1},8,["aria-label","onClick"])],void 0,!0),_:1},8,["content"])):r("",!0)]),_:1},8,["model-value","aria-label"])}]]);export{m as I};
