{"version":3,"file":"script.min.js","sources":["../../../../node_modules/@babel/runtime/helpers/esm/classCallCheck.js","../../../../node_modules/@babel/runtime/helpers/esm/createClass.js","../../../../block-editor/blocks/state-map/script.js"],"sourcesContent":["export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}","// add an slight delay to requestAnimationFrame\nconst requestAnimationFrame = function(fn) {\n\treturn window.requestAnimationFrame(() => window.requestAnimationFrame(fn));\n}\n\n// note: ie11 or jquery do not support classList/addClass on svg elements - manipulate class attribute directly\nconst addSvgClass = function( node, className ) {\n\tlet nodeClass = `${node.getAttribute('class')} ${className}`;\n\tnode.setAttribute( 'class', nodeClass );\n\n\treturn nodeClass;\n}\n\nconst removeSvgClass = function( node, className ) {\n\tlet nodeClass = node.getAttribute('class').replace( ( new RegExp( `\\\\b${className}\\\\b`) ), '' ).trim();\n\tnode.setAttribute( 'class', nodeClass );\n\n\treturn nodeClass;\n}\n\nclass MapState {\n\tconstructor( map, node ) {\n\t\tthis.map = map;\n\t\tthis.node = node;\n\n\t\tthis.detail = document.createElement( 'div' );\n\t\tthis.detail.className = 'state-profiles-map__detail';\n\t\tthis.detailActiveClass = 'state-profiles-map__detail--active';\n\t\tthis.activeClass = 'state-profiles-map__state--active';\n\t\tthis.active = false;\n\n\t\tthis.resetCoords();\n\n\t\tthis.key = this.node.getAttribute('abbr');\n\t\tthis.status = this.node.getAttribute('status');\n\n\t\tif ( 'active' === this.status ) {\n \n\t\t\tthis.node.addEventListener( 'click', (e) => {\n\t\t\t\tif ( this.active ) {\n\t\t\t\t\tthis.map.deactivate( this.key );\n\t\t\t\t} else {\n\t\t\t\t\t// set custom coords originating from mouse click and not center of the state\n\t\t\t\t\tthis.coords = { x: e.clientX, y: e.clientY };\n\n\t\t\t\t\t// on desktop be relative to the map and not fixed\n\t\t\t\t\tif ( this.map.getMode() === 'desktop' ) {\n\t\t\t\t\t\tlet mapRect = this.map.node.getBoundingClientRect();\n\t\t\t\t\t\tthis.coords.x -= mapRect.left;\n\t\t\t\t\t\tthis.coords.y -= mapRect.top;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.map.activate( this.key );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tresetCoords() {\n\t\tconst rect = this.node.getBoundingClientRect();\n\t\t\n\t\tthis.coords = {\n\t\t\tx: rect.left + ( rect.width / 2 ),\n\t\t\ty: rect.top + ( rect.height / 2 ),\n\t\t}\n\t}\n\n\tactivate() {\n\t\tthis.template();\n\n\t\taddSvgClass( this.node, this.activeClass );\n\t\t\n\t\tthis.detail.style.left = `${this.coords.x - 20}px`;\n\t\tthis.detail.style.top = `${this.coords.y - 150}px`;\n\t\tthis.map.node.appendChild( this.detail );\n\t\trequestAnimationFrame(() => {\n\t\t\tthis.detail.classList.add( this.detailActiveClass );\n\t\t\t// this.detail.style.top = '';\n\t\t\t// this.detail.style.left = '';\n\t\t});\n\n\t\tthis.active = true;\n\t}\n\n\tdeactivate() {\n\t\tthis.detail.style.left = `${this.coords.x}px`;\n\t\tthis.detail.style.top = `${this.coords.y}px`;\n\t\tremoveSvgClass( this.node, this.activeClass );\n\n\t\trequestAnimationFrame(() => {\n\t\t\tthis.detail.classList.remove( this.detailActiveClass );\n\n\t\t\tlet transitionend = (e) => {\n\t\t\t\tif ( e.target === this.detail && e.propertyName === 'transform' ) {\n\t\t\t\t\tthis.detail.removeEventListener('transitionend', transitionend);\n\t\t\t\t\tthis.detail.parentNode.removeChild(this.detail);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.detail.addEventListener('transitionend', transitionend);\n\t\t});\n\n\t\tthis.active = false;\n\t}\n\n\ttemplate() {\n\t\tif ( ! this.detail.innerHTML ) {\n\t\t\tconst closeDiv = document.createElement('div');\n\t\t\tconst close = document.createElement('button');\n\t\t\tclose.className = 'state-profiles-map__close';\n\t\t\tclose.addEventListener('click', () => this.map.deactivate() );\n\t\t\tclose.innerHTML = '×';\n\t\t\tcloseDiv.appendChild(close);\n\n\t\t\tthis.detail.appendChild(closeDiv);\n// window.addEventListener('click', () => this.map.deactivate() );\n\t\t\tconst contentDiv = document.createElement('div');\n\t\t\tcontentDiv.className = 'state-profiles-map__detail-content';\n\t\t\tthis.detail.appendChild(contentDiv);\n\t\t\tif ( this.node.getAttribute('name') ) {\n\t\t\t\tcontentDiv.insertAdjacentHTML( 'beforeend', `