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