{"version":3,"file":"tags-row.js","sources":["../../FrontEnd/PDP-FE/src/scripts/modules/tags-row.ts"],"sourcesContent":["import { Component } from '@verndale/core';\n\nclass TagsRow extends Component {\n constructor(el: HTMLElement) {\n super(el);\n }\n\n setupDefaults() {\n this.dom = {\n el: this.el,\n printDropdown: this.el.querySelector('.boat-header__print-dropdown'),\n shareBtn: this.el.querySelector('.boat-header__share'),\n printBtn: this.el.querySelector('.boat-header__print'),\n boatHeaderTitle: document.querySelector('.boat-header__title'),\n toastElement: document.querySelector('#toast')\n };\n }\n\n addListeners() {\n (this.dom.shareBtn as HTMLElement).addEventListener('click', this.handleShareClick.bind(this));\n (this.dom.printBtn as HTMLElement).addEventListener('click', this.handlePrintClick.bind(this));\n (this.dom.printDropdown as HTMLElement).addEventListener(\n 'mouseleave',\n this.handleCloseDropdown.bind(this)\n );\n document.addEventListener('click', this.handleClickOutside.bind(this));\n }\n\n handleShareClick() {\n const urlToShare = window.location.href.split('?')[0];\n\n if (navigator.share) {\n navigator\n .share({\n title: document.title,\n text: (this.dom.boatHeaderTitle as HTMLElement).textContent || '',\n url: urlToShare\n })\n .then(() => console.log('Successful share'))\n .catch(error => console.log('Error sharing', error));\n } else {\n navigator.clipboard.writeText(urlToShare);\n (this.dom.toastElement as HTMLElement)?.classList.add('show');\n setTimeout(() => {\n (this.dom.toastElement as HTMLElement)?.classList.remove('show');\n }, 3000);\n }\n }\n\n handleClickOutside(e: Event) {\n const target = e.target as HTMLElement;\n if (target !== this.dom.printBtn) {\n (this.dom.printDropdown as HTMLElement).classList.remove('show');\n }\n }\n\n handleCloseDropdown(e: Event) {\n const target = e.target as HTMLElement;\n target.classList.remove('show');\n }\n\n handlePrintClick() {\n (this.dom.printDropdown as HTMLElement).classList.toggle('show');\n }\n}\n\nexport default TagsRow;\n"],"names":["TagsRow","Component","el","urlToShare","error","_a","e"],"mappings":"gCAEA,MAAMA,UAAgBC,CAAU,CAC9B,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,CACV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