{"ast":null,"code":"import { useCallback, useEffect, useRef, useState } from 'react';\nimport { maskColor, primaryColor, textColor } from '~/utils/style';\n\nconst useECharts = options => {\n  const ref = useRef(null);\n  const echartInstance = useRef(null);\n  const {\n    0: echart,\n    1: setEchart\n  } = useState(null);\n  const createChart = useCallback(() => {\n    (async () => {\n      const echarts = await import('echarts');\n\n      if (options.gl) {\n        await import('echarts-gl');\n      }\n\n      echartInstance.current = echarts.init(ref.current);\n\n      if (options.zoom) {\n        setTimeout(() => {\n          var _echartInstance$curre;\n\n          (_echartInstance$curre = echartInstance.current) === null || _echartInstance$curre === void 0 ? void 0 : _echartInstance$curre.dispatchAction({\n            type: 'takeGlobalCursor',\n            key: 'dataZoomSelect',\n            dataZoomSelectActive: true\n          });\n        }, 0);\n      }\n\n      setEchart(echartInstance);\n    })();\n  }, [options.gl, options.zoom]);\n  const destroyChart = useCallback(() => {\n    var _echartInstance$curre2;\n\n    (_echartInstance$curre2 = echartInstance.current) === null || _echartInstance$curre2 === void 0 ? void 0 : _echartInstance$curre2.dispose();\n    setEchart(null);\n  }, []);\n  useEffect(() => {\n    if (false) {\n      createChart();\n      return () => destroyChart();\n    }\n  }, [createChart, destroyChart]);\n  useEffect(() => {\n    if (false && echart) {\n      if (options.loading) {\n        var _echartInstance$curre3;\n\n        (_echartInstance$curre3 = echartInstance.current) === null || _echartInstance$curre3 === void 0 ? void 0 : _echartInstance$curre3.showLoading('default', {\n          text: '',\n          color: primaryColor,\n          textColor,\n          maskColor,\n          zlevel: 0\n        });\n      } else {\n        var _echartInstance$curre4;\n\n        (_echartInstance$curre4 = echartInstance.current) === null || _echartInstance$curre4 === void 0 ? void 0 : _echartInstance$curre4.hideLoading();\n      }\n    }\n  }, [options.loading, echart]);\n  return {\n    ref,\n    echart\n  };\n};\n\nexport default useECharts;","map":null,"metadata":{},"sourceType":"module"}