"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[8371],{88371:(e,t,n)=>{n.r(t),n.d(t,{default:()=>u});var r=n(67294),l=n(63475),c=n(6915),a=n(11965);function u({formData:e,height:t,width:n,echartOptions:u,groupby:s,labelMap:i,selectedValues:o,setDataMask:d,legendData:h=[]}){const{emitFilter:f,stack:g}=e,p=(0,r.useRef)(null),m=(0,r.useRef)(Date.now()),v=(0,r.useRef)(""),b=(0,r.useRef)(),I=(0,r.useCallback)((e=>{var t;const n=null==(t=p.current)?void 0:t.getEchartInstance();e?h.forEach((t=>{t===e?(c.aI.legend=t,null==n||n.dispatchAction({type:"legendSelect",name:t})):null==n||n.dispatchAction({type:"legendUnSelect",name:t})})):(c.aI.legend="",null==n||n.dispatchAction({type:"legendAllSelect"}))}),[h]),w=(0,r.useCallback)((e=>{if(!f)return;const t=e.map((e=>i[e]));d({extraFormData:{filters:0===e.length?[]:s.map(((e,n)=>{const r=t.map((e=>e[n]));return null==r?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:r}}))},filterState:{label:t.length?t:void 0,value:t.length?t:null,selectedValues:e.length?e:null}})}),[s,i,d]),k={click:e=>{b.current&&clearTimeout(b.current),b.current=setTimeout((()=>{const{seriesName:t}=e,n=Object.values(o);n.includes(t)?w(n.filter((e=>e!==t))):w([t])}),300)},mouseout:()=>{c.aI.name=""},mouseover:e=>{c.aI.name=e.seriesName},legendselectchanged:e=>{const t=Date.now();t-m.current<300&&v.current===e.name?I(e.name):(m.current=t,v.current=e.name),Object.values(e.selected).every((e=>!e))&&I()}},y={dblclick:e=>{var t;b.current&&clearTimeout(b.current);const n=[e.offsetX,e.offsetY],r=null==(t=p.current)?void 0:t.getEchartInstance();if(null!=r&&r.containPixel("grid",n)){var l;if(!g&&"ec-polygon"===(null==(l=e.target)?void 0:l.type))return;const t=r.getModel(),n=((e,t)=>{let n=e,r=null;for(;n;){const e=n.__ecComponentInfo;if(null!=e){r=t.getComponent(e.mainType,e.index);break}n=n.parent}return r})(e.target,t),c=t.getSeriesCount(),a=t.getCurrentSeriesIndices();if(n){const{name:e}=n;c!==a.length?I():I(e)}}}};return(0,a.tZ)(l.Z,{ref:p,height:t,width:n,echartOptions:u,eventHandlers:k,zrEventHandlers:y,selectedValues:o})}},63475:(e,t,n)=>{n.d(t,{Z:()=>i});var r=n(67294),l=n(51995),c=n(29027),a=n(11965);const u=l.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function s({width:e,height:t,echartOptions:n,eventHandlers:l,zrEventHandlers:s,selectedValues:i={}},o){const d=(0,r.useRef)(null),h=(0,r.useRef)(),f=(0,r.useMemo)((()=>Object.keys(i)||[]),[i]),g=(0,r.useRef)([]);return(0,r.useImperativeHandle)(o,(()=>({getEchartInstance:()=>h.current}))),(0,r.useEffect)((()=>{d.current&&(h.current||(h.current=(0,c.S1)(d.current)),Object.entries(l||{}).forEach((([e,t])=>{var n,r;null==(n=h.current)||n.off(e),null==(r=h.current)||r.on(e,t)})),Object.entries(s||{}).forEach((([e,t])=>{var n,r;null==(n=h.current)||n.getZr().off(e),null==(r=h.current)||r.getZr().on(e,t)})),h.current.setOption(n,!0))}),[n,l,s]),(0,r.useEffect)((()=>{h.current&&(h.current.dispatchAction({type:"downplay",dataIndex:g.current.filter((e=>!f.includes(e)))}),f.length&&h.current.dispatchAction({type:"highlight",dataIndex:f}),g.current=f)}),[f]),(0,r.useEffect)((()=>{h.current&&h.current.resize({width:e,height:t})}),[e,t]),(0,a.tZ)(u,{ref:d,height:t,width:e})}const i=(0,r.forwardRef)(s)}}]);