{"version":3,"file":"copy_to_clipboard_controller-DPlSrQid.js","sources":["../../../app/javascript/controllers/copy_to_clipboard_controller.js"],"sourcesContent":["import ApplicationController from './application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n text: String,\n copiedLabel: { type: String, default: \"Copied!\" },\n successTimeout: { type: Number, default: 3000 }\n }\n\n static targets = [\"button\", \"success\"]\n static classes = [\"hidden\"]\n\n initialize() {\n this.copiedLabelValue = this.translations.actions.copied\n }\n\n connect() {\n this.originalContent = this.buttonTarget.cloneNode(true)\n }\n\n async copy() {\n await navigator.clipboard.writeText(this.textValue)\n\n if(this.hasSuccessTarget) {\n this.buttonTarget.classList.add(this.invisibilityClasses)\n this.successTarget.classList.remove(this.invisibilityClasses)\n\n setTimeout(() => {\n this.buttonTarget.classList.remove(this.invisibilityClasses)\n this.successTarget.classList.add(this.invisibilityClasses)\n }, this.successTimeoutValue)\n } else {\n clearTimeout(this.timeout)\n\n this.buttonTarget.blur()\n this.buttonTarget.innerText = this.copiedLabelValue\n\n this.timeout = setTimeout(() => {\n this.buttonTarget.replaceWith(this.originalContent.cloneNode(true))\n }, this.successTimeoutValue)\n }\n }\n\n // private\n\n get invisibilityClasses() {\n return this.hasHiddenClass ? this.hiddenClasses : \"hidden\"\n }\n}\n"],"names":["CopyController","ApplicationController","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAUjD,YAAa,CACX,KAAK,iBAAmB,KAAK,aAAa,QAAQ,MACtD,CAEE,SAAU,CACR,KAAK,gBAAkB,KAAK,aAAa,UAAU,EAAI,CAC3D,CAEE,MAAM,MAAO,CACX,MAAM,UAAU,UAAU,UAAU,KAAK,SAAS,EAE/C,KAAK,kBACN,KAAK,aAAa,UAAU,IAAI,KAAK,mBAAmB,EACxD,KAAK,cAAc,UAAU,OAAO,KAAK,mBAAmB,EAE5D,WAAW,IAAM,CACf,KAAK,aAAa,UAAU,OAAO,KAAK,mBAAmB,EAC3D,KAAK,cAAc,UAAU,IAAI,KAAK,mBAAmB,CAC1D,EAAE,KAAK,mBAAmB,IAE3B,aAAa,KAAK,OAAO,EAEzB,KAAK,aAAa,KAAI,EACtB,KAAK,aAAa,UAAY,KAAK,iBAEnC,KAAK,QAAU,WAAW,IAAM,CAC9B,KAAK,aAAa,YAAY,KAAK,gBAAgB,UAAU,EAAI,CAAC,CACnE,EAAE,KAAK,mBAAmB,EAEjC,CAIE,IAAI,qBAAsB,CACxB,OAAO,KAAK,eAAiB,KAAK,cAAgB,QACtD,CACA,CA7CEC,EADkBF,EACX,SAAS,CACd,KAAM,OACN,YAAa,CAAE,KAAM,OAAQ,QAAS,SAAW,EACjD,eAAgB,CAAE,KAAM,OAAQ,QAAS,GAAI,CACjD,GAEEE,EAPkBF,EAOX,UAAU,CAAC,SAAU,SAAS,GACrCE,EARkBF,EAQX,UAAU,CAAC,QAAQ"}