"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[704],{33738:(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var l=r(78580),a=r.n(l),n=r(67294),s=r(16355),c=r(5364),u=r(51115),i=r(67190),o=r(10581),h=r(63475),d=r(6915),p=r(11965);function f(e){let{height:t,width:r,echartOptions:l,setDataMask:f,labelMap:g,labelMapB:b,groupby:m,groupbyB:v,selectedValues:y,formData:w,emitCrossFilters:k,seriesBreakdown:F,onContextMenu:x,xValueFormatter:E,xAxis:C,refs:V,coltypeMapping:I}=e;const M=(0,n.useCallback)((e=>e<F),[F]),O=(0,n.useCallback)(((e,t)=>{const r=Object.values(y||{});let l;l=a()(r).call(r,e)?r.filter((t=>t!==e)):[e];const n=M(t)?m:v,s=M(t)?g:b,c=l.map((e=>null==s?void 0:s[e])).filter((e=>!!e));return{dataMask:{extraFormData:{filters:0===l.length?[]:[...n.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:l.length?l:null}},isCurrentValueSelected:a()(r).call(r,e)}}),[m,v,M,g,b,y]),B=(0,n.useCallback)(((e,t)=>{k&&f(O(e,t).dataMask)}),[k,f,O]),N={click:e=>{const{seriesName:t,seriesIndex:r}=e;B(t,r)},contextmenu:async e=>{if(x){e.event.stop();const{data:t,seriesName:r,seriesIndex:l}=e,a=e.event.event,n=[],h=[],p=M(l),f=[...e.name?[e.name]:[],...(p?g:b)[e.seriesName]];t&&C.type===s.we.time&&n.push({col:C.label===c.W3?w.granularitySqla:C.label,grain:w.timeGrainSqla,op:"==",val:t[0],formattedVal:E(t[0])}),[...t&&C.type===s.we.category?[C.label]:[],...p?w.groupby:w.groupbyB].forEach(((e,t)=>n.push({col:e,op:"==",val:f[t],formattedVal:String(f[t])}))),[...p?w.groupby:w.groupbyB].forEach(((e,t)=>h.push({col:e,op:"==",val:f[t],formattedVal:(0,d.mj)(f[t],{timeFormatter:(0,u.bt)(w.dateFormat),numberFormatter:(0,i.JB)(w.numberFormat),coltype:null==I?void 0:I[(0,o.Z)(e)]})}))),x(a.clientX,a.clientY,{drillToDetail:n,crossFilter:O(r,l),drillBy:{filters:h,groupbyFieldName:p?"groupby":"groupby_b",adhocFilterFieldName:p?"adhoc_filters":"adhoc_filters_b"}})}}};return(0,p.tZ)(h.Z,{refs:V,height:t,width:r,echartOptions:l,eventHandlers:N,selectedValues:y})}},63475:(e,t,r)=>{r.d(t,{Z:()=>h});var l=r(78580),a=r.n(l),n=r(67294),s=r(51995),c=r(31431),u=r(11965);const i=s.iK.div`
  height: ${e=>{let{height:t}=e;return t}};
  width: ${e=>{let{width:t}=e;return t}};
`;function o(e,t){let{width:r,height:l,echartOptions:s,eventHandlers:o,zrEventHandlers:h,selectedValues:d={},refs:p}=e;const f=(0,n.useRef)(null);p&&(p.divRef=f);const g=(0,n.useRef)(),b=(0,n.useMemo)((()=>Object.keys(d)||[]),[d]),m=(0,n.useRef)([]);(0,n.useImperativeHandle)(t,(()=>({getEchartInstance:()=>g.current}))),(0,n.useEffect)((()=>{f.current&&(g.current||(g.current=(0,c.S1)(f.current)),Object.entries(o||{}).forEach((e=>{var t,r;let[l,a]=e;null==(t=g.current)||t.off(l),null==(r=g.current)||r.on(l,a)})),Object.entries(h||{}).forEach((e=>{var t,r;let[l,a]=e;null==(t=g.current)||t.getZr().off(l),null==(r=g.current)||r.getZr().on(l,a)})),g.current.setOption(s,!0))}),[s,o,h]),(0,n.useEffect)((()=>{g.current&&(g.current.dispatchAction({type:"downplay",dataIndex:m.current.filter((e=>!a()(b).call(b,e)))}),b.length&&g.current.dispatchAction({type:"highlight",dataIndex:b}),m.current=b)}),[b]);const v=(0,n.useCallback)((e=>{let{width:t,height:r}=e;g.current&&g.current.resize({width:t,height:r})}),[]);return(0,n.useEffect)((()=>(v({width:r,height:l}),()=>{var e;return null==(e=g.current)?void 0:e.dispose()})),[]),(0,n.useLayoutEffect)((()=>{v({width:r,height:l})}),[r,l,v]),(0,u.tZ)(i,{ref:f,height:l,width:r})}const h=(0,n.forwardRef)(o)}}]);
//# sourceMappingURL=e962bd9b067986c8313c.chunk.js.map