{"version":3,"file":"static/chunks/40381.31c1223d086d210c.js","sources":["webpack://_N_E/./src/LegacyApp/client/components/tooltip/tooltip.jsx"],"sourceRoot":"","sourcesContent":["import 'tippy.js/dist/tippy.css';\n\nimport React, { Children } from 'react';\nimport PropTypes from 'prop-types';\nimport Tippy from '@tippyjs/react';\nimport { connect } from 'react-redux';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport classnames from 'classnames';\n\nimport { isFunction } from '@common/methods/isFunction';\nimport { trans } from '@legacyApp/client/modules/translation/translate';\nimport { enhanceComponent } from '@legacyApp/client/wrappers/enhanceComponent';\n\nTippy.defaultProps = {\n\t...Tippy.defaultProps,\n\tarrow: true,\n};\n\nclass ChildrenWithInstance extends React.PureComponent {\n\tstatic propTypes = {\n\t\tchildren: PropTypes.any,\n\t\tinstance: PropTypes.any,\n\t};\n\n\trender() {\n\t\treturn Children.map(this.props.children, (child) => {\n\t\t\t// console.log({child, instance: this.props.instance});\n\t\t\treturn React.cloneElement(child, {\n\t\t\t\ttippyinstance: this.props.instance,\n\t\t\t\t...child.props,\n\t\t\t});\n\t\t});\n\t}\n}\n\nclass Tooltip extends React.PureComponent {\n\tstatic propTypes = {\n\t\tlocalTheme: PropTypes.any,\n\t\tcontent: PropTypes.any,\n\t\tisVisible: PropTypes.any,\n\t\tvisible: PropTypes.any,\n\t\tenabled: PropTypes.bool,\n\t\thideOnClick: PropTypes.any,\n\t\tchildren: PropTypes.any,\n\t\tpassInstance: PropTypes.bool,\n\t\thandleComponentError: PropTypes.func,\n\t\tmodal: PropTypes.any,\n\t\tonModal: PropTypes.bool,\n\t\tdispatch: PropTypes.func,\n\t\tmobile: PropTypes.bool,\n\t\tmobileEnable: PropTypes.bool,\n\t\tnamespace: PropTypes.string,\n\t\tchatVisible: PropTypes.bool,\n\t\tsideMenuVisible: PropTypes.bool,\n\t\tzIndex: PropTypes.number,\n\t\tclassName: PropTypes.string,\n\t\tcloseOnScrollElemClass: PropTypes.string,\n\t};\n\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tinstance: '',\n\t\t\tforceHide: false,\n\t\t};\n\t\tthis.modalResizeObserver =\n\t\t\tprocess.browser && ResizeObserver\n\t\t\t\t? new ResizeObserver(() => {\n\t\t\t\t\t\tthis.popperForceUpdate();\n\t\t\t\t })\n\t\t\t\t: null;\n\t\tthis.strategy = React.createRef();\n\t\tthis.element = React.createRef();\n\t}\n\n\tcomponentDidMount() {\n\t\tthis.setForceHide();\n\t\tthis.setOnModalResize();\n\t\tthis.closeOnScrollEventAdd();\n\t}\n\n\tcomponentWillUnmount() {\n\t\tconst modalElement = this.getModalElement();\n\t\tif (modalElement && isFunction(this.modalResizeObserver?.unobserve)) {\n\t\t\tthis.modalResizeObserver.unobserve(modalElement);\n\t\t}\n\n\t\tthis.closeOnScrollEventRemove();\n\t}\n\n\tsetInstance = (instance) => {\n\t\tthis.setState({\n\t\t\tinstance,\n\t\t});\n\t};\n\n\tcomponentDidUpdate(prevProps) {\n\t\tif (\n\t\t\tprevProps.modal !== this.props.modal ||\n\t\t\tprevProps.mobile !== this.props.mobile ||\n\t\t\tprevProps.chatVisible !== this.props.chatVisible ||\n\t\t\tprevProps.sideMenuVisible !== this.props.sideMenuVisible\n\t\t) {\n\t\t\tthis.popperForceUpdate();\n\t\t\tthis.setForceHide();\n\t\t}\n\n\t\tif (\n\t\t\tprevProps.content !== this.props.content ||\n\t\t\t!!prevProps.visible !== !!this.props.visible\n\t\t) {\n\t\t\tthis.setOnModalResize();\n\t\t}\n\t}\n\n\tisOnModal = () => {\n\t\treturn typeof this.props.onModal === 'boolean'\n\t\t\t? this.props.onModal\n\t\t\t: this.getModalElement();\n\t};\n\n\tgetModalElement = () => {\n\t\treturn this.element.current ? this.element.current.closest('.modal') : null;\n\t};\n\n\tpopperForceUpdate = () => {\n\t\tsetTimeout(() => {\n\t\t\tif (isFunction(this.state.instance?.popperInstance?.forceUpdate)) {\n\t\t\t\tthis.state.instance.popperInstance.forceUpdate();\n\t\t\t}\n\t\t}, 300);\n\t};\n\n\tsetOnModalResize = () => {\n\t\tconst modalElement = this.getModalElement();\n\t\tif (modalElement && isFunction(this.modalResizeObserver?.observe)) {\n\t\t\tthis.modalResizeObserver.observe(modalElement);\n\t\t}\n\t};\n\n\tsetForceHide = () => {\n\t\tconst onModal = this.isOnModal();\n\t\tthis.setState({\n\t\t\tforceHide:\n\t\t\t\t(this.props.modal && !onModal) ||\n\t\t\t\t(!onModal &&\n\t\t\t\t\tthis.props.mobile &&\n\t\t\t\t\t(this.props.chatVisible || this.props.sideMenuVisible)),\n\t\t});\n\t};\n\n\tonShown = () => {\n\t\tconst input = this.element?.current?.querySelector?.('input');\n\t\tif (!input) {\n\t\t\treturn;\n\t\t}\n\t\tconst isInputFocus = document.activeElement === input;\n\t\tif (!isInputFocus) {\n\t\t\tinput.focus();\n\t\t}\n\t};\n\n\tcloseOnScroll = () => {\n\t\tif (this.state.instance.state.isVisible) {\n\t\t\tthis.state.instance.hide();\n\t\t}\n\t};\n\n\tcloseOnScrollEventAdd = () => {\n\t\tif (!this.props.closeOnScrollElemClass) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst elem = document.querySelector(\n\t\t\t`.${this.props.closeOnScrollElemClass}`,\n\t\t);\n\n\t\telem?.addEventListener('scroll', this.closeOnScroll, false);\n\t};\n\n\tcloseOnScrollEventRemove = () => {\n\t\tif (!this.props.closeOnScrollElemClass) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst elem = document.querySelector(\n\t\t\t`.${this.props.closeOnScrollElemClass}`,\n\t\t);\n\n\t\telem?.removeEventListener('scroll', this.closeOnScroll, false);\n\t};\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tpassInstance,\n\t\t\tlocalTheme,\n\t\t\tnamespace,\n\t\t\tclassName,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tdelete props.handleComponentError;\n\t\tdelete props.modal;\n\t\tdelete props.className;\n\t\tdelete props.dispatch;\n\t\tdelete props.onModal;\n\t\tdelete props.mobile;\n\t\tdelete props.mobileEnable;\n\t\tdelete props.chatVisible;\n\t\tdelete props.sideMenuVisible;\n\t\tdelete props.closeOnScrollElemClass;\n\n\t\tif (!children) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!props.content || typeof props.content === 'boolean') {\n\t\t\treturn children;\n\t\t}\n\n\t\tif (\n\t\t\t(props.content &&\n\t\t\t\ttypeof props.content === 'object' &&\n\t\t\t\t('message' in props.content || 'values' in props.content)) ||\n\t\t\tnamespace\n\t\t) {\n\t\t\tprops.content = trans({ label: props.content, namespace });\n\t\t}\n\n\t\tconst content = (\n\t\t\t