"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[7521],{67521:(e,t,r)=>{r.r(t),r.d(t,{default:()=>s}),r(67294);var n=r(51115),l=r(67190),a=r(10581),i=r(63475),c=r(6915),u=r(11965);function s(e){let{height:t,width:r,echartOptions:s,formData:o,onContextMenu:d,setDataMask:h,filterState:f,emitCrossFilters:v,refs:p,coltypeMapping:m}=e;const g=e=>{if(null==e||!e.name||null==e||!e.col)return;const{name:t,col:r}=e,n=Object.values((null==f?void 0:f.selectedValues)||{});let l;return l=n.includes(t)?n.filter((e=>e!==t)):[t],{dataMask:{extraFormData:{filters:l.length?[{col:r,op:"IN",val:l}]:[]},filterState:{value:l.length?l:null,selectedValues:l.length?l:null}},isCurrentValueSelected:n.includes(t)}},w={click:e=>{var t;if(!v||!h)return;e.event.stop();const r=s.series[0].data.find((t=>t.id===e.data.id)),n=null==(t=g(r))?void 0:t.dataMask;n&&h(n)},contextmenu:e=>{if(d){e.event.stop();const t=e.event.event,r=s.series[0].data,i="node"===e.dataType?(t=>{const r=t.find((t=>t.id===e.data.id));if(null!=r&&r.name)return[{col:r.col,op:"==",val:r.name,formattedVal:r.name}]})(r):(t=>{var r,n;const l=null==(r=t.find((t=>t.id===e.data.source)))?void 0:r.name,a=null==(n=t.find((t=>t.id===e.data.target)))?void 0:n.name;if(l&&a)return[{col:o.source,op:"==",val:l,formattedVal:l},{col:o.target,op:"==",val:a,formattedVal:a}]})(r),u=r.find((t=>t.id===e.data.id));d(t.clientX,t.clientY,{drillToDetail:i,crossFilter:g(u),drillBy:u&&{filters:[{col:u.col,op:"==",val:u.name,formattedVal:(0,c.mj)(u.name,{timeFormatter:(0,n.bt)(o.dateFormat),numberFormatter:(0,l.JB)(o.numberFormat),coltype:null==m?void 0:m[(0,a.Z)(u.col)]})}],groupbyFieldName:u.col===o.source?"source":"target"}})}}};return(0,u.tZ)(i.Z,{refs:p,height:t,width:r,echartOptions:s,eventHandlers:w})}},63475:(e,t,r)=>{r.d(t,{Z:()=>s});var n=r(67294),l=r(51995),a=r(31431),i=r(11965);const c=l.iK.div`
  height: ${e=>{let{height:t}=e;return t}};
  width: ${e=>{let{width:t}=e;return t}};
`;function u(e,t){let{width:r,height:l,echartOptions:u,eventHandlers:s,zrEventHandlers:o,selectedValues:d={},refs:h}=e;const f=(0,n.useRef)(null);h&&(h.divRef=f);const v=(0,n.useRef)(),p=(0,n.useMemo)((()=>Object.keys(d)||[]),[d]),m=(0,n.useRef)([]);(0,n.useImperativeHandle)(t,(()=>({getEchartInstance:()=>v.current}))),(0,n.useEffect)((()=>{f.current&&(v.current||(v.current=(0,a.S1)(f.current)),Object.entries(s||{}).forEach((e=>{var t,r;let[n,l]=e;null==(t=v.current)||t.off(n),null==(r=v.current)||r.on(n,l)})),Object.entries(o||{}).forEach((e=>{var t,r;let[n,l]=e;null==(t=v.current)||t.getZr().off(n),null==(r=v.current)||r.getZr().on(n,l)})),v.current.setOption(u,!0))}),[u,s,o]),(0,n.useEffect)((()=>{v.current&&(v.current.dispatchAction({type:"downplay",dataIndex:m.current.filter((e=>!p.includes(e)))}),p.length&&v.current.dispatchAction({type:"highlight",dataIndex:p}),m.current=p)}),[p]);const g=(0,n.useCallback)((e=>{let{width:t,height:r}=e;v.current&&v.current.resize({width:t,height:r})}),[]);return(0,n.useEffect)((()=>(g({width:r,height:l}),()=>{var e;return null==(e=v.current)?void 0:e.dispose()})),[]),(0,n.useLayoutEffect)((()=>{g({width:r,height:l})}),[r,l,g]),(0,i.tZ)(c,{ref:f,height:l,width:r})}const s=(0,n.forwardRef)(u)}}]);
//# sourceMappingURL=1ce67434db6756343ef6.chunk.js.map