{"version":3,"file":"view-script.min.js","sources":["../../../../assets/js/modules/animations/_util.js","../../../../assets/js/modules/animations/_lines.js","../../../../assets/js/modules/animations/_block.js","../../../../block-editor/blocks/page-intro/view-script.js"],"sourcesContent":["/**\n * Basic dom node selector\n *\n * @param {String|Array|NodeList|HTMLElement} selector what nodes to select\n * @returns {Array[HTMLElement]}\n */\nexport function select( selector ) {\n\tlet nodes = [];\n\n\tif ( Array.isArray( selector ) ) {\n\t\tnodes = selector;\n\t} else if ( selector instanceof NodeList ) {\n\t\tnodes = Array.from( selector );\n\t} else if ( selector instanceof HTMLElement ) {\n\t\tnodes = [ selector ];\n\t} else if ( typeof selector === 'string' ) {\n\t\tnodes = Array.from( document.querySelectorAll( selector ) );\n\t} else {\n\t\tconsole.error( \"Invalid node selector\", selector );\n\t}\n\n\tnodes = nodes.filter( node => node instanceof HTMLElement );\n\n\treturn nodes;\n}\n\n/**\n * Observe an elements scroll position and resolve a promise after it's passed it's threshold visibility\n *\n * @param {HTMLElement} node the element to observe it's scroll position\n * @param {Object} opts\n * @returns {Promise}\n */\nexport function observe( node, opts = { threshold: 50 } ) {\n\treturn new Promise(( resolve, reject ) => {\n\t\tlet threshold = parseFloat( opts.threshold );\n\n\t\tif ( isNaN( threshold ) ) {\n\t\t\tthreshold = 50;\n\t\t}\n\n\t\tthreshold = Math.min( 100, Math.max( 0, threshold ) ) / 100;\n\n\t\tconst observer = new IntersectionObserver(\n\t\t\t(entries) => {\n\t\t\t\tentries.forEach( entry => {\n\t\t\t\t\tif ( entry.isIntersecting ) {\n\t\t\t\t\t\tresolve( entry );\n\t\t\t\t\t\tobserver.disconnect();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\t{\n\t\t\t\tthreshold,\n\t\t\t}\n\t\t);\n\n\t\tobserver.observe( node );\n\t});\n}\n\n/**\n * Normalize a duration variable that defaults to ms without a time unit\n *\n * @param {Number|String} duration\n * @returns {String}\n */\nexport function parseDuration( duration ) {\n\tif ( Number.isInteger( duration ) || ! isNaN( parseFloat( duration ) ) ) {\n\t\treturn `${duration}ms`;\n\t}\n\n\treturn duration;\n}\n\n","import { select, observe } from './_util.js';\n\nclass Lines {\n\tconstructor( node, opts = {} ) {\n\t\tthis.node = node;\n\t\tthis.opts = {\n\t\t\tdelay: 1,\n\t\t\tduration: null,\n\t\t\tinterval: 125,\n\t\t\tthreshold: 50,\n\t\t\t...opts\n\t\t}\n\n\t\tthis.node.classList.add( 'animated-lines' );\n\n\t\tthis.words = this.node.textContent.split( ' ' );\n\t\tthis.wordQueue = [];\n\n\t\tthis.placeholder = document.createElement( 'span' );\n\t\tthis.placeholder.classList.add( 'animated-lines__placeholder' );\n\n\t\tArray.from( this.node.childNodes ).forEach( childNode => this.placeholder.appendChild( childNode ) );\n\t\tthis.node.appendChild( this.placeholder );\n\n\t\tconst computedStyle = getComputedStyle( this.node );\n\n\t\tthis.lines = document.createElement('span');\n\t\tthis.lines.classList.add( 'animated-lines__lines' );\n\t\tthis.lines.setAttribute( 'aria-hidden', true );\n\n\t\t[\n\t\t\t'paddingTop',\n\t\t\t'paddingBottom',\n\t\t\t'borderTopWidth',\n\t\t\t'borderBottomWidth',\n\t\t].forEach( prop => {\n\t\t\tif ( parseInt( computedStyle[ prop ], 10 ) > 0 ) {\n\t\t\t\tthis.lines.style[ prop ] = computedStyle[ prop ];\n\t\t\t}\n\t\t} );\n\n\t\tthis.node.appendChild( this.lines );\n\n\t\tobserve( this.node, { threshold: this.opts.threshold } ).then( () => {\n\t\t\tthis.prepare().then( () => {\n\t\t\t\tsetTimeout( () => this.animate(), this.opts.delay );\n\t\t\t} );\n\t\t} );\n\t}\n\n\tlineItems() {\n\t\treturn this.node.querySelectorAll('.animated-lines__line');\n\t}\n\n\tprepare() {\n\t\tconst wordQueue = [ ...this.words ];\n\n\t\t// empty the lines node\n\t\twhile ( this.lines.firstChild ) {\n\t\t\tthis.lines.removeChild( this.lines.firstChild );\n\t\t}\n\n\t\tconst processWords = () => {\n\t\t\treturn new Promise(( resolve, reject ) => {\n\t\t\t\tconst word = wordQueue.shift();\n\n\t\t\t\tconst wordNode = document.createElement( 'span' );\n\t\t\t\twordNode.classList.add( 'animated-lines__word' );\n\t\t\t\twordNode.appendChild( document.createTextNode( word ) );\n\n\t\t\t\t// add a slight delay to the measurements so they're more accurate\n\t\t\t\tsetTimeout( () => {\n\t\t\t\t\tif ( ! this.lines.lastElementChild ) {\n\t\t\t\t\t\tthis.appendLine();\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.lines.lastElementChild.appendChild( document.createTextNode( ' ' ) );\n\t\t\t\t\tthis.lines.lastElementChild.appendChild( wordNode );\n\n\t\t\t\t\t// append each word to a 'line' and if the offsetTop doesn't match the previous word, move it to the next 'line'\n\t\t\t\t\tif ( wordNode.offsetParent && wordNode.offsetLeft + wordNode.offsetWidth > wordNode.offsetParent.offsetWidth ) {\n\t\t\t\t\t\tthis.appendLine();\n\t\t\t\t\t\tthis.lines.lastElementChild.appendChild( wordNode );\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( wordQueue.length ) {\n\t\t\t\t\t\tresolve( processWords() );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t}, 1);\n\t\t\t});\n\t\t}\n\n\t\treturn processWords();\n\t}\n\n\tappendLine() {\n\t\tconst newLine = document.createElement( 'span' );\n\t\tnewLine.classList.add( 'animated-lines__line' );\n\t\tthis.lines.appendChild( newLine );\n\t}\n\n\treset() {\n\t\tconst linesNode = this.node.querySelector( '.animated-lines__lines' );\n\n\t\tif ( linesNode ) {\n\t\t\tlinesNode.parentNode.removeChild( linesNode );\n\t\t}\n\n\t\tif ( this.placeholder && this.placeholder.parentNode ) {\n\t\t\tthis.placeholder.childNodes.forEach( childNode => this.node.appendChild( childNode ) );\n\t\t\tthis.placeholder.parentNode.removeChild( this.placeholder );\n\t\t}\n\n\t\tthis.node.classList.remove( 'animated-lines' );\n\n\t\tthis.node.dataset.animated = true;\n\n\t\treturn this;\n\t}\n\n\tanimate() {\n\t\treturn new Promise( ( resolve ) => {\n\t\t\tthis.lineItems().forEach( ( line, lineIndex, lines ) => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tline.classList.add( 'animated-lines__line--active' );\n\n\t\t\t\t\t\tif ( lineIndex === lines.length - 1 ) {\n\t\t\t\t\t\t\tlet duration = this.opts.duration;\n\n\t\t\t\t\t\t\tif ( ! duration ) {\n\t\t\t\t\t\t\t\tduration = parseFloat( getComputedStyle( line ).animationDuration ) * 1000;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsetTimeout( () => resolve( this.reset() ), duration * 2 );\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tthis.opts.interval * ( lineIndex + 1 )\n\t\t\t\t);\n\t\t\t} );\n\t\t});\n\t}\n}\n\n/**\n * Animate each line of a textNode in individually\n *\n * @param {String|Array|NodeList|HTMLElement} selector\n * @param {Object} opts\n * @returns {Array}\n */\nexport function lines( selector, opts = {} ) {\n\treturn select( selector ).map( node => new Lines( node, opts ) );\n}\n","import { select, observe, parseDuration } from './_util.js';\n\n/**\n * Reveal an entire block when visible\n *\n * @param {String|Array|NodeList|HTMLElement} selector\n * @param {object} opts\n * @returns {Array}\n */\nexport function block( selector, opts = {} ) {\n\topts = {\n\t\tdelay: 10,\n\t\tduration: null,\n\t\t...opts\n\t}\n\n\treturn select( selector ).forEach( ( node ) => {\n\t\tnode.classList.add('animated-block');\n\n\t\tif ( opts.duration ) {\n\t\t\tnode.style.animationDuration = parseDuration( opts.duration );\n\t\t}\n\n\t\tobserve( node ).then( () => setTimeout( () => node.classList.add('animated-block--active'), opts.delay ) );\n\t} );\n}\n","import { block, lines } from '../../../assets/js/modules/_animations.js';\n\ndocument.querySelectorAll( '.page-intro' ).forEach( node => {\n\tlines( node.querySelectorAll( '.wp-block-pullquote p' ) );\n\tblock( node.querySelector( '.wp-block-columns > .wp-block-column:nth-child(2)' ), { delay: 200 } );\n} );\n"],"names":["select","selector","nodes","Array","isArray","NodeList","from","HTMLElement","document","querySelectorAll","console","error","filter","node","observe","opts","threshold","Promise","resolve","reject","parseFloat","isNaN","Math","min","max","observer","IntersectionObserver","entries","forEach","entry","isIntersecting","disconnect","Lines","constructor","this","delay","duration","interval","classList","add","words","textContent","split","wordQueue","placeholder","createElement","childNodes","childNode","appendChild","computedStyle","getComputedStyle","lines","setAttribute","prop","parseInt","style","then","prepare","setTimeout","animate","lineItems","firstChild","removeChild","processWords","word","shift","wordNode","createTextNode","lastElementChild","appendLine","offsetParent","offsetLeft","offsetWidth","length","newLine","reset","linesNode","querySelector","parentNode","remove","dataset","animated","line","lineIndex","animationDuration","block","Number","isInteger","map"],"mappings":"yBAMO,SAASA,EAAQC,GACvB,IAAIC,EAAQ,GAgBZ,OAdKC,MAAMC,QAASH,GACnBC,EAAQD,EACGA,aAAoBI,SAC/BH,EAAQC,MAAMG,KAAML,GACTA,aAAoBM,YAC/BL,EAAQ,CAAED,GACqB,iBAAbA,EAClBC,EAAQC,MAAMG,KAAME,SAASC,iBAAkBR,IAE/CS,QAAQC,MAAO,wBAAyBV,GAGzCC,EAAQA,EAAMU,QAAQC,GAAQA,aAAgBN,cAEvCL,CACR,CASO,SAASY,EAASD,EAAME,EAAO,CAAEC,UAAW,KAClD,OAAO,IAAIC,SAAQ,CAAEC,EAASC,KAC7B,IAAIH,EAAYI,WAAYL,EAAKC,WAE5BK,MAAOL,KACXA,EAAY,IAGbA,EAAYM,KAAKC,IAAK,IAAKD,KAAKE,IAAK,EAAGR,IAAgB,IAExD,MAAMS,EAAW,IAAIC,sBACnBC,IACAA,EAAQC,SAASC,IACXA,EAAMC,iBACVZ,EAASW,GACTJ,EAASM,aACV,GACC,GAEH,CACCf,cAIFS,EAASX,QAASD,EAAM,GAE1B,CCzDA,MAAMmB,EACLC,WAAAA,CAAapB,EAAME,EAAO,IACzBmB,KAAKrB,KAAOA,EACZqB,KAAKnB,KAAO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