{"version":3,"file":"script.min.js","sources":["../../../../block-editor/blocks/tabs/script.js"],"sourcesContent":["class Tabs {\n\n\tconstructor(node, config = {}) {\n\t\tthis.index = -1;\n\t\tthis.node = node;\n\n\t\tthis.config = Object.assign({\n\t\t\tcontentsActiveClass\t\t: 'tabs__tab--active',\n\t\t\tcontentsClass \t\t: 'tabs__tab',\n\t\t\tinteractiveClass \t\t: 'tabs--interactive',\n\t\t\tnavClass \t\t: 'tabs__nav',\n\t\t\tnavActiveClass \t\t: 'tabs__nav--active',\n\t\t\tnavItemClass \t\t: 'tabs__nav-item',\n\t\t\tnavItemActiveClass \t\t: 'tabs__nav-item--active',\n\t\t\tnavLinkClass \t\t: 'tabs__nav-link',\n\t\t\tcurrentItemClass \t\t: 'tabs__nav-current',\n\t\t\tcurrentActiveItemClass : 'tabs__nav-current--active',\n\t\t}, config);\n\n\t\tif (!this.node || this.node.classList.contains(this.config.interactiveClass)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hashMap = {};\n\n\t\tthis.nav = this.node.querySelector(`.${this.config.navClass}`);\n\t\tconst navItems = Array.from(this.node.querySelectorAll(`.${this.config.navItemClass}`));\n\t\tconst navLinks = Array.from(this.node.querySelectorAll(`.${this.config.navLinkClass}`));\n\n\t\tthis.currentItem = this.node.querySelector(`.${this.config.currentItemClass}`);\n\n\t\tif ( this.currentItem && this.nav ) {\n\t\t\tthis.currentItemText = this.currentItem.querySelector('span');\n\n\t\t\tthis.currentItem.addEventListener( 'click', () => {\n\t\t\t\tthis.currentItem.classList.toggle( this.config.currentActiveItemClass );\n\t\t\t\tthis.nav.classList.toggle( this.config.navActiveClass );\n\t\t\t} );\n\t\t}\n\n\t\tthis.tabs = Array.from(this.node.querySelectorAll(`.${this.config.contentsClass}`)).map((content, index) => {\n\t\t\tconst link = navLinks[index];\n\t\t\tconst navItem = navItems[index];\n\t\t\tconst hash = link.getAttribute('href').replace(/^#/, '');\n\n\t\t\tcontent.setAttribute('role', 'tabpanel');\n\t\t\tcontent.setAttribute('tabindex', -1);\n\n\t\t\tthis.hashMap[hash] = index;\n\n\t\t\treturn {\n\t\t\t\topened: false,\n\t\t\t\tcontent,\n\t\t\t\thash,\n\t\t\t\tlink,\n\t\t\t\tnavItem,\n\t\t\t}\n\t\t});\n\n\t\tthis.nav.addEventListener('click', (e) => {\n\t\t\tlet target = e.target;\n\n\t\t\twhile (target && target !== this.nav) {\n\t\t\t\tif (target.classList.contains(this.config.navLinkClass) && target.hash) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tthis.nav.classList.remove( this.config.navActiveClass );\n\t\t\t\t\tthis.goToHash(target.hash);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\ttarget = target.parentNode;\n\t\t\t}\n\t\t});\n\n\t\tif (window.location.hash) {\n\t\t\tthis.goToHash(window.location.hash, false);\n\t\t}\n\n\t\twindow.addEventListener('hashchange', () => this.goToHash(window.location.hash));\n\t\twindow.addEventListener('popstate', () => this.goToHash(window.location.hash));\n\n\t\tif (this.index === -1) {\n\t\t\tthis.goTo(0, false);\n\t\t}\n\n\t\tthis.node.classList.add(this.config.interactiveClass);\n\t}\n\n\tgoToHash(hash, history = true) {\n\t\thash = hash.replace(/^#/, '');\n\n\t\tif (this.hashMap[hash] > -1) {\n\t\t\tthis.goTo(this.hashMap[hash], history);\n\t\t}\n\t}\n\n\tgoTo(index, history = true) {\n\t\tif (this.index > -1) {\n\t\t\tif (this.tabs[this.index].navItem) {\n\t\t\t\tthis.tabs[this.index].navItem.classList.remove(this.config.navItemActiveClass);\n\t\t\t}\n\n\t\t\tthis.tabs[this.index].content.classList.remove(this.config.contentsActiveClass);\n\t\t\tthis.tabs[this.index].content.setAttribute('tabindex', '-1');\n\t\t\tthis.tabs[this.index].content.removeAttribute('aria-selected');\n\t\t}\n\n\t\tthis.index = index;\n\n\t\tif (!this.tabs[this.index]) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.tabs[this.index].navItem) {\n\t\t\tthis.tabs[this.index].navItem.classList.add(this.config.navItemActiveClass);\n\t\t}\n\n\t\tthis.tabs[this.index].content.classList.add(this.config.contentsActiveClass);\n\t\tthis.tabs[this.index].content.setAttribute('aria-selected', 'true');\n\t\tthis.tabs[this.index].content.removeAttribute('tabindex', '-1');\n\t\tthis.tabs[this.index].content.focus();\n\n\t\tif ( history && window.location.hash !== `#${this.tabs[this.index].hash}`) {\n\t\t\twindow.history.replaceState( '', '', `#${this.tabs[this.index].hash}` );\n\t\t}\n\n\t\tif ( this.currentItemText ) {\n\t\t\tthis.currentItemText.innerText = this.tabs[this.index].link.innerText.trim();\n\t\t}\n\n\t\twindow.dispatchEvent(new CustomEvent('resize'));\n\t}\n\n\topen(index, history) {\n\t\tthis.tabs[index].opened = true;\n\t\tthis.tabs[index].content.classList.add(this.config.contentsOpenClass);\n\t\tthis.goTo(index, history);\n\t}\n\n\tclose(index) {\n\t\tthis.tabs[index].opened = false;\n\t\tthis.tabs[index].content.classList.remove(this.config.contentsOpenClass);\n\t}\n\n\ttoggle(index) {\n\t\treturn this.tabs[index].opened ? this.close(index) : this.open(index);\n\t}\n\n}\n\nTabs.instances = Array.from(document.querySelectorAll('.tabs')).map(n => new Tabs(n));\n\nexport default Tabs;\n"],"names":["Tabs","constructor","node","config","this","index","Object","assign","contentsActiveClass","contentsClass","interactiveClass","navClass","navActiveClass","navItemClass","navItemActiveClass","navLinkClass","currentItemClass","currentActiveItemClass","classList","contains","hashMap","nav","querySelector","navItems","Array","from","querySelectorAll","navLinks","currentItem","currentItemText","addEventListener","toggle","tabs","map","content","link","navItem","hash","getAttribute","replace","setAttribute","opened","e","target","preventDefault","remove","goToHash","parentNode","window","location","goTo","add","history","removeAttribute","focus","replaceState","innerText","trim","dispatchEvent","CustomEvent","open","contentsOpenClass","close","instances","document","n"],"mappings":"uGAAA,MAAMA,EAELC,WAAAA,CAAYC,EAAMC,EAAS,IAiB1B,GAhBAC,KAAKC,OAAS,EACdD,KAAKF,KAAOA,EAEZE,KAAKD,O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