{"version":3,"file":"view-script.min.js","sources":["../../../../block-editor/blocks/panels/view-script.js"],"sourcesContent":["class Panel {\n\tconstructor( node ) {\n\t\tthis.node = node;\n\t\tthis.openedClass = 'panels__panel--opened';\n\t\tthis.opened = this.node.classList.contains(this.openedClass);\n\t\tthis.title = this.node.querySelector('.panels__title');\n\t\tthis.content = this.node.querySelector('.panels__content');\n\n\t\tif ( this.title ) {\n\t\t\tthis.title.addEventListener( 'click', () => this.toggle() );\n\t\t}\n\t}\n\n\topen() {\n\t\tthis.node.classList.add( this.openedClass );\n\t\tthis.title.setAttribute( 'aria-expanded','true' );\n\n\t\tthis.content.style.display = 'block';\n\t\tthis.content.style.position = 'absolute';\n\n\t\tlet height = this.content.offsetHeight;\n\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.removeAttribute('style');\n\t\t\tthis.opened = true;\n\t\t\tthis.content.removeEventListener('transitionend', transitionend);\n\n\t\t\tthis.node.dispatchEvent( new CustomEvent( 'panel:opened', { bubbles: true, cancelable: false } ) );\n\t\t}\n\n\t\tthis.content.addEventListener('transitionend', transitionend);\n\n\t\tthis.content.style.transitionProperty = 'height, opacity';\n\t\tthis.content.style.transitionDuration = '300ms';\n\t\tthis.content.style.transitionTimingFunction = 'cubic-bezier(0.68, -0.55, 0.265, 1.55), linear';\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.openedClass);\n\t\tthis.title.setAttribute('aria-expanded','false');\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.transitionProperty = 'height, opacity';\n\t\tthis.content.style.transitionDuration = '300ms';\n\t\tthis.content.style.transitionTimingFunction = 'cubic-bezier(0.68, -0.55, 0.265, 1.55), linear';\n\n\t\tlet transitionend = (e) => {\n\t\t\tthis.content.removeAttribute( 'style' );\n\t\t\tthis.opened = false;\n\t\t\tthis.content.removeEventListener( 'transitionend', transitionend );\n\n\t\t\tthis.node.dispatchEvent( new CustomEvent( 'panel:closed', { bubbles: true, cancelable: false } ) );\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) {\n\t\tthis.node = node;\n\t\tthis.node.classList.add('panels--interactive');\n\n\t\tthis.panels = Array.from(this.node.querySelectorAll('.panels__panel')).map(node => new Panel(node));\n\t\tthis.expander = this.node.querySelector('.panels__expand');\n\t\tthis.expandText = this.expander ? this.expander.querySelector( '.panels__expand-text--expand' ) : null;\n\t\tthis.collapseText = this.expander ? this.expander.querySelector( '.panels__expand-text--collapse' ) : null;\n\t\tthis.expanded = false;\n\n\t\tif ( this.expander ) {\n\t\t\tthis.expander.addEventListener('click', (e) => {\n\t\t\t\te.preventDefault();\n\n\t\t\t\tthis.expanded ? this.collapse() : this.expand();\n\t\t\t});\n\t\t}\n\n\t\tconst onPanelToggle = () => {\n\t\t\tconst opened = this.panels.filter( panel => panel.opened ).length;\n\n\t\t\tif ( opened === this.panels.length ) {\n\t\t\t\tthis.expand();\n\t\t\t} else if ( 0 === opened ) {\n\t\t\t\tthis.collapse();\n\t\t\t}\n\t\t}\n\n\t\tthis.node.addEventListener( 'panel:opened', onPanelToggle );\n\t\tthis.node.addEventListener( 'panel:closed', onPanelToggle );\n\t}\n\n\tcollapse() {\n\t\tthis.expanded = false;\n\t\tthis.panels.filter( panel => panel.opened ).forEach( panel => panel.close() );\n\n\t\tif ( this.collapseText ) {\n\t\t\tthis.collapseText.hidden = true;\n\t\t}\n\n\t\tif ( this.expandText ) {\n\t\t\tthis.expandText.removeAttribute('hidden');\n\t\t}\n\t}\n\n\texpand() {\n\t\tthis.expanded = true;\n\t\tthis.panels.filter( panel => ! panel.opened ).forEach( panel => panel.open() );\n\n\t\tif ( this.expandText ) {\n\t\t\tthis.expandText.hidden = true;\n\t\t}\n\n\t\tif ( this.collapseText ) {\n\t\t\tthis.collapseText.removeAttribute('hidden');\n\t\t}\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","this","openedClass","opened","classList","contains","title","querySelector","content","addEventListener","toggle","open","add","setAttribute","style","display","position","height","offsetHeight","overflow","transitionend","e","removeAttribute","removeEventListener","dispatchEvent","CustomEvent","bubbles","cancelable","transitionProperty","transitionDuration","transitionTimingFunction","requestAnimationFrame","opacity","close","remove","Panels","panels","Array","from","querySelectorAll","map","expander","expandText","collapseText","expanded","preventDefault","collapse","expand","onPanelToggle","filter","panel","length","forEach","hidden","instances","document","p"],"mappings":"kEAAA,MAAMA,EACLC,WAAAA,CAAaC,GACZC,KAAKD,KAAcA,EACnBC,KAAKC,YAAc,wBACnBD,KAAKE,OAAcF,KAAKD,KAAKI,UAAUC,SAASJ,KAAKC,aACrDD,KAAKK,MAAcL,KAAKD,KAAKO,cAAc,kBAC3CN,KAAKO,QAAcP,KAAKD,KAAKO,cAAc,oBAEtCN,KAAKK,OACTL,KAAKK,MAAMG,iBAAkB,SAAS,IAAMR,KAAKS,UAEnD,CAEAC,IAAAA,GACCV,KAAKD,KAAKI,UAAUQ,IAAKX,KAAKC,aAC9BD,KAAKK,MAAMO,aAAc,gBAAgB,QAEzCZ,KAAKO,QAAQM,MAAMC,QAAW,QAC9Bd,KAAKO,QAAQM,MAAME,SAAW,WAE9B,IAAIC,EAAShB,KAAKO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