{"version":3,"file":"script.min.js","sources":["../../../../block-editor/blocks/panels/script.js"],"sourcesContent":["import caretDown from '../../../assets/svg/carat-down.svg';\n\nclass Panel {\n\tconstructor(node, opts = {}) {\n\t\tthis.node = node;\n\t\tthis.opts = Object.assign(\n\t\t\t{\n\t\t\t\ttitleSelector: '.panels__title',\n\t\t\t\tcontentSelector: '.panels__content',\n\t\t\t\topenedClass: 'panels__panel--opened',\n\t\t\t\ttransition: 'height 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55)',\n\t\t\t},\n\t\t\topts,\n\t\t);\n\n\t\tthis.opened = this.node.classList.contains(this.opts.openedClass);\n\t\tthis.title = this.node.querySelector(this.opts.titleSelector);\n\t\tthis.content = this.node.querySelector(this.opts.contentSelector);\n\n\t\tif (this.title) {\n\t\t\tthis.title.insertAdjacentHTML('beforeend', `${caretDown}`);\n\t\t\tthis.title.addEventListener('click', this.toggle.bind(this));\n\t\t}\n\t}\n\n\topen() {\n\t\tthis.node.classList.add(this.opts.openedClass);\n\n\t\tthis.content.style.display = 'block';\n\t\tthis.content.style.position = 'absolute';\n\t\tconst height = this.content.offsetHeight;\n\t\tthis.content.style.position = '';\n\t\tthis.content.style.height = '0px';\n\t\tthis.content.style.overflow = 'hidden';\n\n\t\tlet transitionend = (e) => {\n\t\t\tthis.content.removeEventListener('transitionend', transitionend);\n\t\t\tthis.content.removeAttribute('style');\n\t\t\tthis.opened = true;\n\t\t\tthis.node.dispatchEvent(new CustomEvent('panel:open'));\n\t\t}\n\n\t\tthis.content.addEventListener('transitionend', transitionend);\n\t\tthis.content.style.transition = this.opts.transition;\n\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tthis.content.style.height = `${height}px`;\n\t\t\t\tthis.content.style.opacity = 1;\n\t\t\t})\n\t\t});\n\t}\n\n\tclose() {\n\t\tthis.node.classList.remove(this.opts.openedClass);\n\n\t\tthis.content.style.display = 'block';\n\t\tthis.content.style.overflow = 'hidden';\n\t\tthis.content.style.height = `${this.content.offsetHeight}px`;\n\t\tthis.content.style.transition = this.opts.transition;\n\n\t\tlet transitionend = () => {\n\t\t\tthis.content.removeAttribute('style');\n\t\t\tthis.opened = false;\n\t\t\tthis.content.removeEventListener('transitionend', transitionend);\n\t\t\tthis.node.dispatchEvent(new CustomEvent('panel:close'));\n\t\t}\n\n\t\tthis.content.addEventListener('transitionend', transitionend);\n\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tthis.content.style.height = '0';\n\t\t\t\tthis.content.style.opacity = 0;\n\t\t\t})\n\t\t});\n\t}\n\n\ttoggle() {\n\t\treturn this.opened ? this.close() : this.open();\n\t}\n}\n\nclass Panels {\n\tconstructor(node, opts = {}) {\n\t\tthis.node = node;\n\t\tthis.node.classList.add('panels--interactive');\n\t\tthis.panels = Array.from(this.node.querySelectorAll('.panels__panel')).map(node => new Panel(node, opts));\n\t}\n}\n\nPanels.instances = Array.from(document.querySelectorAll('.panels')).map(p => new Panels(p));\n\nexport default Panels;\n"],"names":["Panel","constructor","node","opts","arguments","length","undefined","this","Object","assign","titleSelector","contentSelector","openedClass","transition","opened","classList","contains","title","querySelector","content","insertAdjacentHTML","addEventListener","toggle","bind","open","add","style","display","position","height","offsetHeight","overflow","transitionend","e","removeEventListener","removeAttribute","dispatchEvent","CustomEvent","requestAnimationFrame","opacity","close","remove","Panels","panels","Array","from","querySelectorAll","map","instances","document","p"],"mappings":"yGAEA,MAAMA,EACLC,WAAAA,CAAYC,GAAiB,IAAXC,EAAIC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EACxBG,KAAKL,KAAOA,EACZK,KAAKJ,KAAOK,OAAOC,OAClB,CACCC,cAAe,iBACfC,gBAAiB,mBACjBC,YAAa,wBACbC,WAAY,6GAEbV,GAGDI,KAAKO,OAASP,KAAKL,KAAKa,UAAUC,SAAST,KAAKJ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