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